From 8590bb0c29c558fb73c4132762a346ded7b986ce Mon Sep 17 00:00:00 2001 From: "tibo.depeuter" Date: Mon, 21 Mar 2022 16:00:53 +0100 Subject: [PATCH] Added notis --- .config/i3/config | 19 +++++++++++-------- .config/i3/scripts/notify.sh | 32 +++++++++++--------------------- 2 files changed, 22 insertions(+), 29 deletions(-) diff --git a/.config/i3/config b/.config/i3/config index 788f529..93b591f 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -213,9 +213,12 @@ bindsym $winkey+Return exec i3-sensible-terminal # Start rofi (a program launcher) bindsym $alt+space exec --no-startup-id rofi -show +# Set notification script +set $notify sh ~/.config/i3/scripts/notify.sh + # Brightness -bindsym XF86MonBrightnessDown exec brightnessctl -e s 5%- -bindsym XF86MonBrightnessUp exec brightnessctl -e s +5% +bindsym XF86MonBrightnessDown exec brightnessctl -e s 5%- && $notify -b +bindsym XF86MonBrightnessUp exec brightnessctl -e s +5% && $notify -b # Media control bindsym F7 exec --no-startup-id playerctl play-pause @@ -223,17 +226,17 @@ bindsym Shift+F8 exec --no-startup-id playerctl previous bindsym Shift+F9 exec --no-startup-id playerctl next # Volume control -bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +5% \ - && $refresh_i3status -bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -5% \ - && $refresh_i3status +bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +2% \ + && $refresh_i3status && $notify -v +bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -2% \ + && $refresh_i3status && $notify -v bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle \ - && $refresh_i3status + && $refresh_i3status && $notify -v bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle \ && $refresh_i3status # Lockscreen -set $lock sh ~/.config/i3/scripts/lock.sh && sleep 1 +set $lock sh ~/.config/i3/scripts/lock.sh && brightnessctl set 25% && sleep 1 bindsym $winkey+Delete exec --no-startup-id $lock # exec --no-startup-id xss-lock --transfer-sleep-lock -- exec $i3lockwall --nofork diff --git a/.config/i3/scripts/notify.sh b/.config/i3/scripts/notify.sh index 868dece..18b53ff 100644 --- a/.config/i3/scripts/notify.sh +++ b/.config/i3/scripts/notify.sh @@ -4,31 +4,21 @@ # Variables duration=3 -bright='' -vol='' -title='' -message='' - -# Functions -function getVol () { - status=$(amixer get Master | grep "^ Front Left" | cut -d ' ' -f 8) - if [[ $status == "[on]" ]] ; then - vol=$(amixer get Master | grep -o "[0-9]*%" | head -n 1) - else - vol="0%" - fi -} ; export -f getVol +value=0 # Get options while getopts ":bvm:" options; do case "${options}" in b) - bright=$(brightnessctl | grep -o "[0-9]*%") - title="Brightness: ${bright}" + value=$(brightnessctl | grep -o "[0-9]*%") + title="Brightness: ${value}" ;; v) - getVol - title="Volume: ${vol:-'0%'}" + status=$(amixer get Master | grep "^ Front Left" | cut -d ' ' -f 8) + if [[ $status == "[on]" ]] ; then + value=$(amixer get Master | grep -o "[0-9]*%" | head -n 1) + fi + title="Volume: ${value:-'0%'}" ;; m) message=${OPTARG} @@ -42,8 +32,8 @@ done shift $((OPTIND - 1)) notify-send "${title:-${message}}" "${message}" \ - -h int:x:100 -h int:y:100 \ + -h int:value:"$(grep -o "[0-9]*" <<< ${value})" \ -h string:x-canonical-private-synchronous:byMe # Replace if not yet gone -# sleep ${duration}; killall notify-osd - + #-h geometry = "400x200-40-40" \ +canberra-gtk-play -i audio-volume-change -d "changeVolume"