moved all desktop utils into this repo
This commit is contained in:
parent
cd7e93374e
commit
2241d30a86
28 changed files with 151 additions and 45 deletions
|
@ -1,24 +1,34 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
generate() {
|
||||
message=$(wpctl get-volume @DEFAULT_AUDIO_SINK@)
|
||||
volume=$(awk '{print $2 * 100}' <<< "$message")
|
||||
min_volume="0"
|
||||
max_volume="100"
|
||||
|
||||
if [[ $(awk '{print $3}' <<< "$message") == "[MUTED]" ]]; then
|
||||
muted=1
|
||||
else
|
||||
muted=0
|
||||
fi
|
||||
# Check if an argument is provided
|
||||
if [[ -z $1 ]]; then
|
||||
echo "Error: Number argument is missing."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo '{"volume":"'"$volume"'","muted":"'"$muted"'"}'
|
||||
}
|
||||
# Retrieve the argument value
|
||||
number_to_add=$1
|
||||
|
||||
generate
|
||||
# Validate if the argument is a number
|
||||
if ! [[ $number_to_add =~ ^-?[0-9]+$ ]]; then
|
||||
echo "Error: Invalid number argument."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pactl subscribe | while read -r event; do
|
||||
if [[ "$event" == *"Event 'change'"* ]]; then
|
||||
|
||||
generate
|
||||
# Read the current brightness value from the file
|
||||
current_volume=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{print $2 * 100}')
|
||||
|
||||
fi
|
||||
done
|
||||
# Add the desired number to the current brightness
|
||||
new_volume=$((current_volume + number_to_add))
|
||||
|
||||
# Enforce minimum and maximum brightness values
|
||||
if (( new_volume < min_volume )); then
|
||||
new_volume=$min_volume
|
||||
elif (( new_volume > max_volume )); then
|
||||
new_volume=$max_volume
|
||||
fi
|
||||
|
||||
wpctl set-volume @DEFAULT_AUDIO_SINK@ "${new_volume}%"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue