Compare commits
4 Commits
a361543acf
...
48ef0718cc
Author | SHA1 | Date | |
---|---|---|---|
48ef0718cc | |||
a2b2ff9441 | |||
82b8648ff6 | |||
766f64c4a6 |
@ -1,43 +1,33 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
CACHE_DIR="$HOME/.cache/audio-control"
|
|
||||||
|
|
||||||
[ "$#" -eq 0 ] &&
|
if [ "$#" -eq 0 ]
|
||||||
echo "Requires a command. Run with 'help' for a list of commands." &&
|
then
|
||||||
|
echo "Requires a command. Run with 'help' for a list of commands."
|
||||||
exit 1
|
exit 1
|
||||||
[ "$#" -gt 1 ] &&
|
fi
|
||||||
echo "Too many arguments. Run with 'help' for a list of commands." &&
|
if [ "$#" -gt 1 ]
|
||||||
|
then
|
||||||
|
echo "Too many arguments. Run with 'help' for a list of commands."
|
||||||
exit 1
|
exit 1
|
||||||
|
fi
|
||||||
[ -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
|
|
||||||
}
|
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
"mute")
|
"mute")
|
||||||
pactl set-sink-mute 0 toggle
|
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")
|
"vol-up")
|
||||||
pactl set-sink-volume 0 +5%
|
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")
|
"vol-down")
|
||||||
pactl set-sink-volume 0 -5%
|
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")
|
"reset")
|
||||||
pactl set-sink-volume 0 50%
|
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;;
|
pactl list sinks | grep '^[[:space:]]Volume:' | head -n $(( SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,'
|
||||||
"toggle-port")
|
;;
|
||||||
query_outport;;
|
|
||||||
"help")
|
"help")
|
||||||
echo "USAGE: audio-control <command>
|
echo "USAGE: audio-control <command>
|
||||||
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
UPDATES=$(checkupdates | wc -l)
|
|
||||||
echo "$UPDATES" > ~/.cache/update_count
|
|
@ -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
|
|
@ -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"
|
|
Loading…
x
Reference in New Issue
Block a user