From 944201b3bb49d1d6a8b43c42a5929206f4473f31 Mon Sep 17 00:00:00 2001 From: Luc Bijl Date: Thu, 14 Aug 2025 20:09:43 +0000 Subject: [PATCH 1/4] README.md: update --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ce0a5ca..e5d75a7 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # notifiers +A set of scripts that use [libnotify](https://gitlab.gnome.org/GNOME/libnotify) to notify about various states of a Linux system. From 479ed6be92a6ef597dd8c1f0d2b8290b20ff0934 Mon Sep 17 00:00:00 2001 From: Luc Bijl Date: Thu, 14 Aug 2025 20:33:09 +0000 Subject: [PATCH 2/4] src/audio: update Update icon path, remove minor error and change steps to 5%. --- src/audio | 67 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/src/audio b/src/audio index 3a7c8d7..0a9d5cd 100755 --- a/src/audio +++ b/src/audio @@ -5,7 +5,7 @@ function notify_state { case "$type" in "sink") # Handle notifications for audio sink (output) # Read the last audio sink notification ID from state, or set default if it does not exist - sink_last_notify_id="$(cat $HOME/.local/state/audio/sink || echo "1024")" + sink_last_notify_id="$(cat "$HOME/.local/state/audio/sink" || echo "1024")" # Get the volume level and mute status of the default audio sink local volume="$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{print $2 * 100}')" @@ -16,22 +16,22 @@ function notify_state { # Send a different notification based on the volume level if [ $volume -gt 67 ]; then - sink_last_notify_id="$(notify-send "Volume sink: ${volume}%" -h int:value:${volume} -h string:synchronous: -i $sink_high -t 2000 -r $sink_last_notify_id -p)" + sink_last_notify_id="$(notify-send "Volume sink: ${volume}%" -h int:value:$volume -h string:synchronous: -i $sink_high -t 2000 -r $sink_last_notify_id -p)" elif [ $volume -gt 33 ]; then - sink_last_notify_id="$(notify-send "Volume sink: ${volume}%" -h int:value:${volume} -h string:synchronous: -i $sink_medium -t 2000 -r $sink_last_notify_id -p)" + sink_last_notify_id="$(notify-send "Volume sink: ${volume}%" -h int:value:$volume -h string:synchronous: -i $sink_medium -t 2000 -r $sink_last_notify_id -p)" else - sink_last_notify_id="$(notify-send "Volume sink: ${volume}%" -h int:value:${volume} -h string:synchronous: -i $sink_low -t 2000 -r $sink_last_notify_id -p)" + sink_last_notify_id="$(notify-send "Volume sink: ${volume}%" -h int:value:$volume -h string:synchronous: -i $sink_low -t 2000 -r $sink_last_notify_id -p)" fi else - sink_last_notify_id="$(notify-send "Volume sink: muted" -h int:value:${volume} -h string:synchronous: -i $sink_muted -t 2000 -r $sink_last_notify_id -p)" + sink_last_notify_id="$(notify-send "Volume sink: muted" -h int:value:$volume -h string:synchronous: -i $sink_muted -t 2000 -r $sink_last_notify_id -p)" fi # Write the last audio sink notification ID to state - echo $sink_last_notify_id > $HOME/.local/state/audio/sink + echo "$sink_last_notify_id" > "$HOME/.local/state/audio/sink" ;; "source") # Handle notifications for audio source (input) - # Read the last audio source notification from state, or set default if it does not exist - source_last_notify_id="$(cat $HOME/.local/state/audio/source || echo "1024")" + # Read the last audio source notification ID from state, or set default if it does not exist + source_last_notify_id="$(cat "$HOME/.local/state/audio/source" || echo "1024")" # Get the volume level and mute status of the default audio source local volume="$(wpctl get-volume @DEFAULT_AUDIO_SOURCE@ | awk '{print $2 * 100}')" @@ -42,18 +42,18 @@ function notify_state { # Send a different notification based on the volume level if [ $volume -gt 67 ]; then - source_last_notify_id="$(notify-send "Volume source: ${volume}%" -h int:value:${volume} -h string:synchronous: -i $source_high -t 2000 -r $source_last_notify_id -p)" + source_last_notify_id="$(notify-send "Volume source: ${volume}%" -h int:value:$volume -h string:synchronous: -i $source_high -t 2000 -r $source_last_notify_id -p)" elif [ $volume -gt 33 ]; then - source_last_notify_id="$(notify-send "Volume source: ${volume}%" -h int:value:${volume} -h string:synchronous: -i $source_medium -t 2000 -r $source_last_notify_id -p)" + source_last_notify_id="$(notify-send "Volume source: ${volume}%" -h int:value:$volume -h string:synchronous: -i $source_medium -t 2000 -r $source_last_notify_id -p)" else - source_last_notify_id="$(notify-send "Volume source: ${volume}%" -h int:value:${volume} -h string:synchronous: -i $source_low -t 2000 -r $source_last_notify_id -p)" + source_last_notify_id="$(notify-send "Volume source: ${volume}%" -h int:value:$volume -h string:synchronous: -i $source_low -t 2000 -r $source_last_notify_id -p)" fi else - source_last_notify_id="$(notify-send "Volume source: muted" -h int:value:${volume} -h string:synchronous: -i $source_muted -t 2000 -r $source_last_notify_id -p)" + source_last_notify_id="$(notify-send "Volume source: muted" -h int:value:$volume -h string:synchronous: -i $source_muted -t 2000 -r $source_last_notify_id -p)" fi # Write the last audio source notification ID to state - echo $source_last_notify_id > $HOME/.local/state/audio/source + echo "$source_last_notify_id" > "$HOME/.local/state/audio/source" ;; esac } @@ -62,30 +62,31 @@ function notify_state { type="$1" action="$2" -# Define icon theme -icon_theme="tela-circle-black" +# Define icon theme and path +icon_theme="Tela-circle-black-dark" +icon_path="/usr/share/icons/${icon_theme}/24/panel" -# Define paths to icon files for different audio sink states -sink_high="/usr/share/icons/${icon_theme}/24/panel/audio-volume-high.svg" -sink_medium="/usr/share/icons/${icon_theme}/24/panel/audio-volume-medium.svg" -sink_low="/usr/share/icons/${icon_theme}/24/panel/audio-volume-low.svg" -sink_muted="/usr/share/icons/${icon_theme}/24/panel/audio-volume-muted.svg" +# Define icon files for different audio sink states +sink_high="${icon_path}/audio-volume-high.svg" +sink_medium="${icon_path}/audio-volume-medium.svg" +sink_low="${icon_path}/audio-volume-low.svg" +sink_muted="${icon_path}/audio-volume-muted.svg" -# Define paths to icon files for different audio source states -source_high="/usr/share/icons/${icon_theme}/24/panel/mic-volume-high.svg" -source_medium="/usr/share/icons/${icon_theme}/24/panel/mic-volume-medium.svg" -source_low="/usr/share/icons/${icon_theme}/24/panel/mic-volume-low.svg" -source_muted="/usr/share/icons/${icon_theme}/24/panel/mic-volume-muted.svg" +# Define icon files for different audio source states +source_high="${icon_path}/mic-volume-high.svg" +source_medium="${icon_path}/mic-volume-medium.svg" +source_low="${icon_path}/mic-volume-low.svg" +source_muted="${icon_path}/mic-volume-muted.svg" # Determine action to take based on type case "$type" in "sink") # Actions for audio sink case "$action" in - "volup") # Increase audio sink volume by 10% - wpctl set-volume @DEFAULT_AUDIO_SINK@ 10%+ + "volup") # Increase audio sink volume by 5% + wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+ ;; - "voldown") # Decrease audio sink volume by 10% - wpctl set-volume @DEFAULT_AUDIO_SINK@ 10%- + "voldown") # Decrease audio sink volume by 5% + wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- ;; "toggle") # Toggle audio sink mute wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle @@ -98,11 +99,11 @@ case "$type" in ;; "source") # Actions for audio source case "$action" in - "volup") # Increase audio source volume by 10% - wpctl set-volume @DEFAULT_AUDIO_SOURCE@ 10%+ + "volup") # Increase audio source volume by 5% + wpctl set-volume @DEFAULT_AUDIO_SOURCE@ 5%+ ;; - "voldown") # Decrease audio source volume by 10% - wpctl set-volume @DEFAULT_AUDIO_SOURCE@ 10%- + "voldown") # Decrease audio source volume by 5% + wpctl set-volume @DEFAULT_AUDIO_SOURCE@ 5%- ;; "toggle") # Toggle audio source mute wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle From b5796746f202efffef479afff4ddc30ecc3f3860 Mon Sep 17 00:00:00 2001 From: Luc Bijl Date: Thu, 14 Aug 2025 20:34:04 +0000 Subject: [PATCH 3/4] src/battery: add --- src/battery | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 src/battery diff --git a/src/battery b/src/battery new file mode 100755 index 0000000..5e6c0d8 --- /dev/null +++ b/src/battery @@ -0,0 +1,52 @@ +#!/bin/sh + +# Define icon theme and path +icon_theme="Tela-circle-black-dark" +icon_path="/usr/share/icons/${icon_theme}/24/panel" + +# Define icon files for different discharging battery states +discharging_empty="${icon_path}/battery-000.svg" +discharging_low="${icon_path}/battery-020.svg" +discharging_medium="${icon_path}/battery-050.svg" +discharging_good="${icon_path}/battery-080.svg" +discharging_full="${icon_path}/battery-100.svg" + +# Define icon files for different charging battery states +charging_empty="${icon_path}/battery-020" +charging_low="${icon_path}/battery-020-charging.svg" +charging_medium="${icon_path}/battery-050-charging.svg" +charging_good="${icon_path}/battery-080-charging.svg" +charging_full="${icon_path}/battery-100-charged.svg" + +# Get the capacity and charging state of the battery +capacity="$(cat "/sys/class/power_supply/BAT0/capacity")" +charging="$(cat "/sys/class/power_supply/AC/online")" + +# Send a different notification based on the charging state +if [ $charging -eq 0 ]; then + # send a different notification based on the capacity + if [ $capacity -gt 90 ]; then + notify-send "Capacity: ${capacity}%" -h int:value:$capacity -h string:synchronous: -i $discharging_full -t 4000 + elif [ $capacity -gt 70 ]; then + notify-send "Capacity: ${capacity}%" -h int:value:$capacity -h string:synchronous: -i $discharging_good -t 4000 + elif [ $capacity -gt 40 ]; then + notify-send "Capacity: ${capacity}%" -h int:value:$capacity -h string:synchronous: -i $discharging_medium -t 4000 + elif [ $capacity -gt 10 ]; then + notify-send "Capacity: ${capacity}%" -h int:value:$capacity -h string:synchronous: -i $discharging_low -t 4000 + else + notify-send "Capacity: ${capacity}%" -h int:value:$capacity -h string:synchronous: -i $discharging_empty -t 4000 + fi +else + # Send a different notification based on the capacity + if [ $capacity -gt 90 ]; then + notify-send "Capacity: ${capacity}%" -h int:value:$capacity -h string:synchronous: -i $charging_full -t 4000 + elif [ $capacity -gt 70 ]; then + notify-send "Capacity: ${capacity}%" -h int:value:$capacity -h string:synchronous: -i $charging_good -t 4000 + elif [ $capacity -gt 40 ]; then + notify-send "Capacity: ${capacity}%" -h int:value:$capacity -h string:synchronous: -i $charging_medium -t 4000 + elif [ $capacity -gt 10 ]; then + notify-send "Capacity: ${capacity}%" -h int:value:$capacity -h string:synchronous: -i $charging_low -t 4000 + else + notify-send "Capacity: ${capacity}%" -h int:value:$capacity -h string:synchronous: -i $charging_empty -t 4000 + fi +fi From c56fc16b7d6bbd5e1a6aa1bb030c17d1752ff166 Mon Sep 17 00:00:00 2001 From: Luc Bijl Date: Thu, 14 Aug 2025 20:34:21 +0000 Subject: [PATCH 4/4] src/brightness: add --- src/brightness | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 src/brightness diff --git a/src/brightness b/src/brightness new file mode 100755 index 0000000..9e1d497 --- /dev/null +++ b/src/brightness @@ -0,0 +1,26 @@ +#!/bin/sh + +# Define icon theme and path +icon_theme="Tela-circle-black-dark" +icon_path="/usr/share/icons/${icon_theme}/24/panel" + +# Define icon file +brightness_lcd="${icon_path}/gpm-brightness-lcd.svg" + +# Loop through each backlight +for backlight_path in /sys/class/backlight/*; do + # Extract backlight from path + backlight="${backlight_path##*/}" + + # Read the last brightness notification ID from state, or set default if it does not exist. + last_notify_id="$(cat "$HOME/.local/state/brightness/$backlight" || echo "1024")" + + # Get the brightness percentage of the backlight + brightness="$(( 100 * $(cat "$backlight_path/brightness") / $(cat "$backlight_path/max_brightness") ))" + + # Send the brightness notification + last_notify_id="$(notify-send "Brightness ${brightness}%" -h int:value:$brightness -h string:synchronous: -i $brightness_lcd -t 2000 -r $last_notify_id -p)" + + # Write the last brightness notification ID to state + echo "$last_notify_id" > "$HOME/.local/state/brightness/$backlight" +done