merge: work

This commit is contained in:
AngeD 2022-09-21 15:50:19 +02:00
commit 2f9f5740cb
2 changed files with 33 additions and 12 deletions

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
xrandr \ xrandr \
--output HDMI-2 --auto --primary \ --output eDP-1 --primary \
--output eDP-1 --left-of HDMI-2 --output HDMI-2 --right-of-eDP-1
exec awesome exec awesome

View File

@ -1,26 +1,47 @@
#!/bin/bash #!/bin/bash
set -e set -e
SINK='@DEFAULT_SINK@' PACTL_SINK='@DEFAULT_SINK@'
CUR="$(pactl get-sink-volume "$SINK" | awk '$1 == "Volume:" {print substr($5, 1, length($5) - 1)}')" SINK="$PACTL_SINK"
CUR="$((CUR - CUR % "$1"))"
function get_vol() {
VOL="$(pactl get-sink-volume "$SINK" 2> /dev/null)"
if [ -n "$VOL" ]; then
CMD='pactl set-sink-volume'
else
CMD='amixer sset'
SINK='Master'
VOL="$(amixer sget "$SINK")"
fi
}
set +e
get_vol
set -e
VOL="$(echo "$VOL" | grep -o -E '[0-9]{,3}%' | head -n 1)"
# Remove everything after first '%'
VOL="${VOL%%%*}"
VOL="$((VOL - VOL % "$1"))"
case "${1:0:1}" in case "${1:0:1}" in
'') '')
exit 1 exit 1
;; ;;
'+'|'-') '+'|'-')
NEW="$((CUR + "$1"))" VOL="$((VOL + "$1"))"
;; ;;
*) *)
NEW="$1" VOL="$1"
;; ;;
esac esac
[ "$NEW" -lt 0 ] && NEW=0 [ "$VOL" -lt 0 ] && VOL=0
[ "$NEW" -gt 100 ] && NEW=100 [ "$VOL" -gt 100 ] && VOL=100
pactl set-sink-volume "$SINK" "$NEW%" $CMD "$SINK" "$VOL%" > /dev/null
pactl set-sink-mute "$SINK" 0 pactl set-sink-mute "$PACTL_SINK" 0
echo "$NEW" echo "$VOL"