From 7d779dbf3f0f4d933457f3114983c1cdca11f35b Mon Sep 17 00:00:00 2001 From: Ryan Kes Date: Sun, 8 Mar 2020 22:43:12 +0100 Subject: [PATCH] show notifications on brightness/volume change --- deadd/.local/bin/brightness | 12 ++++++++++++ deadd/.local/bin/volume | 32 ++++++++++++++++++++++++++++++++ sxhkd/.config/sxhkd/sxhkdrc | 14 +++++++------- 3 files changed, 51 insertions(+), 7 deletions(-) create mode 100755 deadd/.local/bin/brightness create mode 100755 deadd/.local/bin/volume diff --git a/deadd/.local/bin/brightness b/deadd/.local/bin/brightness new file mode 100755 index 0000000..42dd7a9 --- /dev/null +++ b/deadd/.local/bin/brightness @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +if [ "$1" == "inc" ]; then + xbacklight -inc 20 +fi + +if [ "$1" == "dec" ]; then + xbacklight -dec 20 +fi +notify-send.py "Screen Brightness" "$(printf "%.0f\n" "$(xbacklight -get)")" \ + --hint string:image-path:video-display boolean:transient:true \ + --replaces-process "brightness-popup" diff --git a/deadd/.local/bin/volume b/deadd/.local/bin/volume new file mode 100755 index 0000000..93ff133 --- /dev/null +++ b/deadd/.local/bin/volume @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +if [ "$1" == "inc" ]; then + amixer -q sset Master 5%+ +fi + +if [ "$1" == "dec" ]; then + amixer -q sset Master 5%- +fi + +if [ "$1" == "mute" ]; then + amixer -q sset Master toggle +fi + + +AMIXER=$(amixer sget Master) +VOLUME=$(echo "$AMIXER" | grep 'Mono:' | awk -F'[][]' '{ print $2 }' | tr -d "%") +MUTE=$(echo "$AMIXER" | grep -o '\[off\]' | tail -n 1) +if [ "$MUTE" == "[off]" ]; then + ICON=audio-volume-muted +elif [ "$VOLUME" -le 20 ]; then + ICON=audio-volume-low +elif [ "$VOLUME" -le 60 ]; then + ICON=audio-volume-medium +else + ICON=audio-volume-high +fi + + +notify-send.py "Volume" "$VOLUME/100" \ + --hint string:image-path:$ICON boolean:transient:true \ + --replaces-process "volume-popup" diff --git a/sxhkd/.config/sxhkd/sxhkdrc b/sxhkd/.config/sxhkd/sxhkdrc index eb3c409..57b2f9d 100644 --- a/sxhkd/.config/sxhkd/sxhkdrc +++ b/sxhkd/.config/sxhkd/sxhkdrc @@ -8,17 +8,17 @@ Print # Audio controls XF86AudioRaiseVolume - pactl set-sink-volume @DEFAULT_SINK@ +5% + ~/.local/bin/volume inc XF86AudioLowerVolume - pactl set-sink-volume @DEFAULT_SINK@ -5% + ~/.local/bin/volume dec XF86AudioMute - pactl set-sink-mute @DEFAULT_SINK@ toggle + ~/.local/bin/volume mute # Screen brightness controls -XF86MonBrightnessUp - xbacklight -inc 20 -XF86MonBrightnessDown - xbacklight -dec 20 +XF86MonBrightnessUp + ~/.local/bin/brightness inc +XF86MonBrightnessDown + ~/.local/bin/brightness dec # lock screen super + F1