src/audio: update
Update icon path, remove minor error and change steps to 5%.
This commit is contained in:
parent
944201b3bb
commit
479ed6be92
1 changed files with 34 additions and 33 deletions
67
src/audio
67
src/audio
|
@ -5,7 +5,7 @@ function notify_state {
|
||||||
case "$type" in
|
case "$type" in
|
||||||
"sink") # Handle notifications for audio sink (output)
|
"sink") # Handle notifications for audio sink (output)
|
||||||
# Read the last audio sink notification ID from state, or set default if it does not exist
|
# 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
|
# Get the volume level and mute status of the default audio sink
|
||||||
local volume="$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{print $2 * 100}')"
|
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
|
# Send a different notification based on the volume level
|
||||||
if [ $volume -gt 67 ]; then
|
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
|
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
|
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
|
fi
|
||||||
else
|
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
|
fi
|
||||||
|
|
||||||
# Write the last audio sink notification ID to state
|
# 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)
|
"source") # Handle notifications for audio source (input)
|
||||||
# Read the last audio source notification from state, or set default if it does not exist
|
# 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")"
|
source_last_notify_id="$(cat "$HOME/.local/state/audio/source" || echo "1024")"
|
||||||
|
|
||||||
# Get the volume level and mute status of the default audio source
|
# Get the volume level and mute status of the default audio source
|
||||||
local volume="$(wpctl get-volume @DEFAULT_AUDIO_SOURCE@ | awk '{print $2 * 100}')"
|
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
|
# Send a different notification based on the volume level
|
||||||
if [ $volume -gt 67 ]; then
|
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
|
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
|
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
|
fi
|
||||||
else
|
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
|
fi
|
||||||
|
|
||||||
# Write the last audio source notification ID to state
|
# 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
|
esac
|
||||||
}
|
}
|
||||||
|
@ -62,30 +62,31 @@ function notify_state {
|
||||||
type="$1"
|
type="$1"
|
||||||
action="$2"
|
action="$2"
|
||||||
|
|
||||||
# Define icon theme
|
# Define icon theme and path
|
||||||
icon_theme="tela-circle-black"
|
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
|
# Define icon files for different audio sink states
|
||||||
sink_high="/usr/share/icons/${icon_theme}/24/panel/audio-volume-high.svg"
|
sink_high="${icon_path}/audio-volume-high.svg"
|
||||||
sink_medium="/usr/share/icons/${icon_theme}/24/panel/audio-volume-medium.svg"
|
sink_medium="${icon_path}/audio-volume-medium.svg"
|
||||||
sink_low="/usr/share/icons/${icon_theme}/24/panel/audio-volume-low.svg"
|
sink_low="${icon_path}/audio-volume-low.svg"
|
||||||
sink_muted="/usr/share/icons/${icon_theme}/24/panel/audio-volume-muted.svg"
|
sink_muted="${icon_path}/audio-volume-muted.svg"
|
||||||
|
|
||||||
# Define paths to icon files for different audio source states
|
# Define icon files for different audio source states
|
||||||
source_high="/usr/share/icons/${icon_theme}/24/panel/mic-volume-high.svg"
|
source_high="${icon_path}/mic-volume-high.svg"
|
||||||
source_medium="/usr/share/icons/${icon_theme}/24/panel/mic-volume-medium.svg"
|
source_medium="${icon_path}/mic-volume-medium.svg"
|
||||||
source_low="/usr/share/icons/${icon_theme}/24/panel/mic-volume-low.svg"
|
source_low="${icon_path}/mic-volume-low.svg"
|
||||||
source_muted="/usr/share/icons/${icon_theme}/24/panel/mic-volume-muted.svg"
|
source_muted="${icon_path}/mic-volume-muted.svg"
|
||||||
|
|
||||||
# Determine action to take based on type
|
# Determine action to take based on type
|
||||||
case "$type" in
|
case "$type" in
|
||||||
"sink") # Actions for audio sink
|
"sink") # Actions for audio sink
|
||||||
case "$action" in
|
case "$action" in
|
||||||
"volup") # Increase audio sink volume by 10%
|
"volup") # Increase audio sink volume by 5%
|
||||||
wpctl set-volume @DEFAULT_AUDIO_SINK@ 10%+
|
wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+
|
||||||
;;
|
;;
|
||||||
"voldown") # Decrease audio sink volume by 10%
|
"voldown") # Decrease audio sink volume by 5%
|
||||||
wpctl set-volume @DEFAULT_AUDIO_SINK@ 10%-
|
wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-
|
||||||
;;
|
;;
|
||||||
"toggle") # Toggle audio sink mute
|
"toggle") # Toggle audio sink mute
|
||||||
wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle
|
wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle
|
||||||
|
@ -98,11 +99,11 @@ case "$type" in
|
||||||
;;
|
;;
|
||||||
"source") # Actions for audio source
|
"source") # Actions for audio source
|
||||||
case "$action" in
|
case "$action" in
|
||||||
"volup") # Increase audio source volume by 10%
|
"volup") # Increase audio source volume by 5%
|
||||||
wpctl set-volume @DEFAULT_AUDIO_SOURCE@ 10%+
|
wpctl set-volume @DEFAULT_AUDIO_SOURCE@ 5%+
|
||||||
;;
|
;;
|
||||||
"voldown") # Decrease audio source volume by 10%
|
"voldown") # Decrease audio source volume by 5%
|
||||||
wpctl set-volume @DEFAULT_AUDIO_SOURCE@ 10%-
|
wpctl set-volume @DEFAULT_AUDIO_SOURCE@ 5%-
|
||||||
;;
|
;;
|
||||||
"toggle") # Toggle audio source mute
|
"toggle") # Toggle audio source mute
|
||||||
wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle
|
wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue