Skip to content

Commit

Permalink
feat: herbe notifications
Browse files Browse the repository at this point in the history
Signed-off-by: Beau Hastings <[email protected]>
  • Loading branch information
hastinbe committed Oct 11, 2020
1 parent f589d4c commit 5ca60b2
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 23 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ Use your keyboard volume keys to increase, decrease, or mute your volume. If you
| ------------ | ------- | ----- |
| ![notify-osd notifications](https://user-images.githubusercontent.com/195790/95647280-c3558780-0b00-11eb-987e-5924f2522bdb.png) | ![dunst notifications](https://user-images.githubusercontent.com/195790/95647273-afaa2100-0b00-11eb-8e2c-eb3eede89d7c.png) | ![xob notifications](https://user-images.githubusercontent.com/195790/95647285-d0727680-0b00-11eb-9600-56e4371b9a58.png) |

| [xosd] |
| ------ |
| ![xosd notifications](https://user-images.githubusercontent.com/195790/95656224-60371580-0b3f-11eb-9463-54698dadfd44.png) |
| [xosd] | [herbe] |
| ------ | ------- |
| ![xosd notifications](https://user-images.githubusercontent.com/195790/95656224-60371580-0b3f-11eb-9463-54698dadfd44.png) | ![herbe notifications](https://user-images.githubusercontent.com/195790/95669559-c6aa4b00-0bb4-11eb-8516-6beb500222f3.png) |

Read about [notifications](https://github.com/hastinbe/i3-volume/wiki/Notifications) for more information.

Expand All @@ -44,7 +44,7 @@ Options:
-m toggle mute
-M <mixer> specify mixer (ex: Headphone), default Master
-n show notifications
-N <libnotify|xosd> notification method (default: libnotify)
-N <libnotify|herbe|xosd> notification method (default: libnotify)
-o <generic|i3blocks|xob|"format"> output the volume according to the provided output format:
generic = output the volume
i3blocks = output the volume for i3blocks
Expand Down Expand Up @@ -75,6 +75,10 @@ See our [example blocklet](https://github.com/hastinbe/i3-volume/wiki/Usage-with

[xosd] notifications can be used by specifying the `-N xosd` option to your volume commands. [See an example](https://github.com/hastinbe/i3-volume/wiki/Usage-with-XOSD).

## herbe

[herbe] notifications can be used by specifying the `-N herbe` option to your volume commands. [See an example](https://github.com/hastinbe/i3-volume/wiki/Usage-with-herbe).

## Help

Having a problem? Try reading our [common issues](https://github.com/hastinbe/i3-volume/wiki/Common-Issues) or open an [issue](https://github.com/hastinbe/i3-volume/issues/new).
Expand All @@ -86,6 +90,7 @@ Copyright (C) 1989, 1991 Free Software Foundation, Inc.

[alsa-utils]: https://alsa.opensrc.org/Alsa-utils
[dunst]: https://dunst-project.org
[herbe]: https://github.com/dudik/herbe
[i3blocks]: https://github.com/vivien/i3blocks
[i3status]: https://github.com/i3/i3status
[i3wm]: https://i3wm.org
Expand Down
56 changes: 37 additions & 19 deletions volume
Original file line number Diff line number Diff line change
Expand Up @@ -327,17 +327,26 @@ notify_muted() {
icon=${icons_symbolic[0]}
fi

if $opt_use_dunstify; then
dunstify -i $icon -t $expires -h int:value:0 -h string:synchronous:volume "Volume muted" -r 1000
else
if [ "$notification_method" = "xosd" ]; then
case "$notification_method" in
xosd)
local delay=$(($expires / 1000))
osd_cat --align center -b percentage -P 0 -d $delay -p top -A center -c "$COLOR_MUTED" -T "Volume muted" -O 2 -u "$COLOR_XOSD_OUTLINE"
else
# libnotify
notify-send -i $icon -t $expires -h int:value:0 -h string:synchronous:volume "Volume muted" -h string:x-canonical-private-synchronous:i3-volume
fi
fi
;;

# There is a patch with a notify-send script for herbe, not in the current version at this time but would make this option irrelevant. See https://github.com/dudik/herbe/pull/10
herbe)
# Dismiss existing/pending notifications to prevent queuing
pkill -SIGUSR1 herbe
herbe "Volume muted" &
;;
*) # libnotify
if $opt_use_dunstify; then
dunstify -i $icon -t $expires -h int:value:0 -h string:synchronous:volume "Volume muted" -r 1000
else
notify-send -i $icon -t $expires -h int:value:0 -h string:synchronous:volume "Volume muted" -h string:x-canonical-private-synchronous:i3-volume
fi
;;
esac
}

# Display a notification indicating the current volume.
Expand All @@ -351,18 +360,27 @@ notify_volume() {
text="$text $progress"
fi

if $opt_use_dunstify; then
dunstify -i "$icon" -t $expires -h int:value:"$vol" -h string:synchronous:volume "$text" -r 1000
else
if [ "$notification_method" = "xosd" ]; then
case "$notification_method" in
xosd)
local color=$(volume_color $vol)
local delay=$(($expires / 1000))
osd_cat --align center -b percentage -P "$vol" -d $delay -p top -A center -c "$color" -T "$text" -O 2 -u "$COLOR_XOSD_OUTLINE" &
else
#libnotify
notify-send -i "$icon" -t $expires -h int:value:"$vol" -h string:synchronous:volume "$text" -h string:x-canonical-private-synchronous:i3-volume
fi
fi
;;

# There is a patch with a notify-send script for herbe, not in the current version at this time but would make this option irrelevant. See https://github.com/dudik/herbe/pull/10
herbe)
# Dismiss existing/pending notifications to prevent queuing
pkill -SIGUSR1 herbe
herbe "$text" &
;;
*) # libnotify
if $opt_use_dunstify; then
dunstify -i "$icon" -t $expires -h int:value:"$vol" -h string:synchronous:volume "$text" -r 1000
else
notify-send -i "$icon" -t $expires -h int:value:"$vol" -h string:synchronous:volume "$text" -h string:x-canonical-private-synchronous:i3-volume
fi
;;
esac
}

# Updates the status line.
Expand Down Expand Up @@ -527,7 +545,7 @@ Options:
-m toggle mute
-M <mixer> specify mixer (ex: Headphone), default Master
-n show notifications
-N <libnotify|xosd> notification method (default: libnotify)
-N <libnotify|herbe|xosd> notification method (default: libnotify)
-o <generic|i3blocks|xob|\"format\"> output the volume according to the provided output format:
generic = output the volume
i3blocks = output the volume for i3blocks
Expand Down

0 comments on commit 5ca60b2

Please sign in to comment.