Compare commits

...

4 Commits

Author SHA1 Message Date
48ef0718cc audio-control unnecessary '$' for arithmetic variables. 2024-12-30 18:51:37 +01:00
a2b2ff9441 audio-control: remove references to CACHE_DIR
No longer used.
2024-12-30 18:51:01 +01:00
82b8648ff6 audio-control: make conditionals more readable. 2024-12-30 18:48:59 +01:00
766f64c4a6 Remove status-update, space-usage-update, and count-updates
These scripts were primarily used in conjunction with DWM, which I no
longer use.
2024-12-30 18:44:34 +01:00
4 changed files with 16 additions and 52 deletions

View File

@ -1,43 +1,33 @@
#!/bin/bash
CACHE_DIR="$HOME/.cache/audio-control"
[ "$#" -eq 0 ] &&
echo "Requires a command. Run with 'help' for a list of commands." &&
if [ "$#" -eq 0 ]
then
echo "Requires a command. Run with 'help' for a list of commands."
exit 1
[ "$#" -gt 1 ] &&
echo "Too many arguments. Run with 'help' for a list of commands." &&
fi
if [ "$#" -gt 1 ]
then
echo "Too many arguments. Run with 'help' for a list of commands."
exit 1
[ -d $CACHE_DIR ] ||
mkdir -p $CACHE_DIR
query_outport() {
active_port="$(pactl list sinks | grep 'Active Port')"
if [[ $active_port == *"speaker"* ]]
then
echo "SPK" > $CACHE_DIR/port
else
echo "HDF" > $CACHE_DIR/port
fi
pactl list sinks | awk '/Mute/ { if ($2 == "no") print "VOL"; else print "MUT"; }' > $CACHE_DIR/vol_status
pactl list sinks | grep '^[[:space:]]Volume:' | head -n $(( $SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,' > $CACHE_DIR/vol_level
}
fi
case $1 in
"mute")
pactl set-sink-mute 0 toggle
pactl list sinks | awk '/Mute/ { if ($2 == "no") print "VOL"; else print "MUT"; }' > $CACHE_DIR/vol_status;;
pactl list sinks | awk '/Mute/ { if ($2 == "no") print "VOL"; else print "MUT"; }'
;;
"vol-up")
pactl set-sink-volume 0 +5%
pactl list sinks | grep '^[[:space:]]Volume:' | head -n $(( $SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,' > $CACHE_DIR/vol_level;;
pactl list sinks | grep '^[[:space:]]Volume:' | head -n $(( SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,'
;;
"vol-down")
pactl set-sink-volume 0 -5%
pactl list sinks | grep '^[[:space:]]Volume:' | head -n $(( $SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,' > $CACHE_DIR/vol_level;;
pactl list sinks | grep '^[[:space:]]Volume:' | head -n $(( SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,'
;;
"reset")
pactl set-sink-volume 0 50%
pactl list sinks | grep '^[[:space:]]Volume:' | head -n $(( $SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,' > $CACHE_DIR/vol_level;;
"toggle-port")
query_outport;;
pactl list sinks | grep '^[[:space:]]Volume:' | head -n $(( SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,'
;;
"help")
echo "USAGE: audio-control <command>

View File

@ -1,3 +0,0 @@
#!/bin/sh
UPDATES=$(checkupdates | wc -l)
echo "$UPDATES" > ~/.cache/update_count

View File

@ -1,2 +0,0 @@
#!/bin/bash
df -h | awk '{ if ($6 == "/") printf "/: " $4; if ($6 == "/home") printf " home: " $4; if ($6 == "/media/music") printf " music: " $4; }' > $HOME/.cache/free-space

View File

@ -1,21 +0,0 @@
#!/bin/bash
for ifname in $(ls /sys/class/net/ | grep -v 'lo')
do
if ! [ -f "/sys/class/net/$ifname/operstate" ]
then
>&2 echo "$ifname has no operstate"
continue
fi
IF_STATUS=$(cat /sys/class/net/$ifname/operstate)
IF_STATE_LIST+=("$ifname: $IF_STATUS")
done
DATE="$(date +"%F %H:%M" )"
NETWORK="${IF_STATE_LIST[*]}"
SPACE="$(cat $HOME/.cache/free-space)"
vol_status="$(cat $HOME/.cache/audio-control/vol_status)"
vol_level="$(cat $HOME/.cache/audio-control/vol_level)%"
VOLUME="$vol_status $vol_level"
UPDATES="Upd: $(cat $HOME/.cache/update_count)"
xsetroot -name "$VOLUME | $NETWORK | $SPACE | $UPDATES | $DATE"