-
Notifications
You must be signed in to change notification settings - Fork 27
Useful tools to help you do things with Wired
There are a few somewhat hidden features to Wired that have been added through random issues and requests. It would be useful to have that knowledge in one place.
Notifications can be tagged to allow them to be easily replaced easily. This is useful for doing something like a volume or brightness control notification.
This works by reading the wired-tag
hint. If two notifications have the same wired-tag
and the same application name, then the notification will be replaced. This behavior happens regardless of the replacing_enabled
config option.
notify-send "Summary" "Body" --hint="string:wired-tag:tag_name"
notify-send "Summary" "A different body" --hint="string:wired-tag:tag_name"
Notifications can also have "note" data associated with them. Think of this like extra information you want to send the notification so that you can identify it. E.g. on your volume notification, you might also want to attach a "mute" note so that you can have a different icon for mute.
The usefulness of this is exclusively through render criteria.
$ notify-send "Volume" --hint="string:wired-note:mute"
# or maybe...
$ notify-send "Volume" --hint="string:wired-tag:volume" --hint="string:wired-note:mute"
Wired has a CLI which you can use to manually trigger shortcuts and a few other things.
$ wired --help
Usage: wired [options]
IDX refers to the Nth most recent notification, unless it is prefixed
by 'id', in which case it refers to a notification via its ID.
E.g.: `wired --drop 0` vs `wired --drop id2589`
Options:
-h, --help print this help menu
-z, --dnd [on|off] enable/disable do not disturb mode
-d, --drop [latest|all|IDX]
drop/close a notification
-a, --action [latest|IDX]:[default|1|2|3]
execute a notification's action
-s, --show N show the last N notifications
-r, --run run the wired daemon
-v, --version print the version of wired and leave
When rendering any sort of text in a Wired layout, it is possible to use markup. Below is a list documenting some of Wired's custom markup properties, and linking to other properties such as Pango Markup.
Wired itself supports a few markup tags for extracting relevant information from the notification:
Tag | Description | Example |
---|---|---|
%s |
Replaced with the notification's summary string. | text: "%s" |
%b |
Replaced with the notification's body string. | text: "%b" |
%t(<format>) |
Replaced with the time that wired saw the notification string. See chrono documentation for time format string details. |
text: "%t(%H:%M %P)" |
%n |
Replaced with the name of the application that sent the notification. | text: "%n" |
%i |
Replaced with the notification's id. | text: "%i" |
%p |
Replaced with the notification's progress/percentage. "None" if no progress present. | text: %p% |
%a |
Specific to ButtonBlock Replaced with the string corresponding to the button's action, if one exists. |
text: "%a" |
Beyond this, it's also possible to use Pango Markup to format notification strings. Using this, you can change a huge variety of things including text color, italics/bold/etc, positioning, and even fonts (I'm not sure changing fonts will actually work, but it should).
Here's an example block which draws the notification's summary and body text in different colors:
name: "summary",
parent: "root",
hook: Hook(parent_anchor: TL, self_anchor: TL),
offset: Vec2(x: 0.0, y: 0.0),
params: TextBlock((
text: "<span background='red'>%s</span> -- <span background='blue'>%b</span>",
font: "Arial Bold 20",
ellipsize: Middle,
color: Color(hex: "#ebdbb2"),
color_hovered: Color(hex: "#fbf1c7"),
padding: Padding(left: 7.0, right: 7.0, top: 7.0, bottom: 7.0),
dimensions: (width: (min: 50, max: 350), height: (min: 0, max: 0)),
)),
Note that markup is only available in config fields. If a notification is sent that contains markup, you'll only get the plain text.
As you may have seen above, Wired has a DnD mode which basically just halts sending notifications until enabled again.
$ wired --dnd on
$ wired --dnd off
You can use this in conjunction with print_to_file
to retrieve the notifications you missed while you were away. I don't plan on adding support for showing all the notifications missed once DnD has been turned off, but a script could do this easily.