feat: set-vol now chooses between pactl and amixer
This commit is contained in:
parent
a87cc556f9
commit
414570a9e4
4
.xinitrc
4
.xinitrc
@ -1,8 +1,8 @@
|
|||||||
#!/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
|
||||||
|
|
||||||
# fix touchscreen
|
# fix touchscreen
|
||||||
xinput --map-to-output 'Raydium Corporation Raydium Touch System' 'eDP-1'
|
xinput --map-to-output 'Raydium Corporation Raydium Touch System' 'eDP-1'
|
||||||
|
39
bin/set-vol
39
bin/set-vol
@ -1,32 +1,47 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
SINK='@DEFAULT_SINK@'
|
PACTL_SINK='@DEFAULT_SINK@'
|
||||||
CUR_FILE=/var/tmp/current_volume
|
SINK="$PACTL_SINK"
|
||||||
|
|
||||||
|
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
|
set +e
|
||||||
CUR="$(cat "$CUR_FILE" || echo 50)"
|
get_vol
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
CUR="$((CUR - CUR % "$1"))"
|
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" > "$CUR_FILE"
|
echo "$VOL"
|
||||||
echo "$NEW"
|
|
||||||
|
Loading…
Reference in New Issue
Block a user