misc cleanups
This commit is contained in:
parent
9d612dc9cc
commit
749f79c4b6
10 changed files with 63 additions and 73 deletions
20
scripts/ctl
20
scripts/ctl
|
|
@ -72,29 +72,27 @@ keyboard)
|
|||
esac
|
||||
;;
|
||||
audio)
|
||||
require pactl
|
||||
require wpctl pw-dump jq
|
||||
case "$2" in
|
||||
out)
|
||||
sinks="$(pactl list short sinks | awk '{print $1": "$2}')"
|
||||
sinks="$(pw-dump | jq -r '.[] | select(.info.props."media.class" == "Audio/Sink") | "\(.id)\t\(.info.props."node.description" // .info.props."node.name" // "unknown")"')"
|
||||
[ -z "$sinks" ] && exit 0
|
||||
count="$(printf "%s\n" "$sinks" | wc -l)"
|
||||
if [ "$XDG_SESSION_TYPE" = x11 ]; then
|
||||
choice="$(printf "%s\n" "$sinks" | dmenu -i -l "$count" -p "select sink:" | cut -d: -f1)"
|
||||
choice="$(printf "%s\n" "$sinks" | awk -F'\t' '{print $1": "$2}' | dmenu -i -p "select sink:" | cut -d: -f1)"
|
||||
else
|
||||
choice="$(printf "%s\n" "$sinks" | rofi -dmenu -i -lines "$count" -p "select sink" | cut -d: -f1)"
|
||||
choice="$(printf "%s\n" "$sinks" | awk -F'\t' '{print $1": "$2}' | rofi -dmenu -i -p "select sink" | cut -d: -f1)"
|
||||
fi
|
||||
[ "$choice" ] && pactl set-default-sink "$choice"
|
||||
[ "$choice" ] && wpctl set-default "$choice"
|
||||
;;
|
||||
in)
|
||||
sources="$(pactl list short sources | awk '{print $1": "$2}')"
|
||||
sources="$(pw-dump | jq -r '.[] | select(.info.props."media.class" == "Audio/Source") | "\(.id)\t\(.info.props."node.description" // .info.props."node.name" // "unknown")"')"
|
||||
[ -z "$sources" ] && exit 0
|
||||
count="$(printf "%s\n" "$sources" | wc -l)"
|
||||
if [ "$XDG_SESSION_TYPE" = x11 ]; then
|
||||
choice="$(printf "%s\n" "$sources" | dmenu -i -l "$count" -p "select source:" | cut -d: -f1)"
|
||||
choice="$(printf "%s\n" "$sources" | awk -F'\t' '{print $1": "$2}' | dmenu -i -p "select source:" | cut -d: -f1)"
|
||||
else
|
||||
choice="$(printf "%s\n" "$sources" | rofi -dmenu -i -lines "$count" -p "select source" | cut -d: -f1)"
|
||||
choice="$(printf "%s\n" "$sources" | awk -F'\t' '{print $1": "$2}' | rofi -dmenu -i -p "select source" | cut -d: -f1)"
|
||||
fi
|
||||
[ "$choice" ] && pactl set-default-source "$choice"
|
||||
[ "$choice" ] && wpctl set-default "$choice"
|
||||
;;
|
||||
*)
|
||||
echo "Usage: ctl audio {in|out}" >&2
|
||||
|
|
|
|||
23
scripts/hypr
23
scripts/hypr
|
|
@ -66,26 +66,20 @@ brightness)
|
|||
esac
|
||||
;;
|
||||
volume)
|
||||
require pactl notify-send
|
||||
SINK="@DEFAULT_SINK@"
|
||||
require wpctl notify-send
|
||||
SINK="@DEFAULT_AUDIO_SINK@"
|
||||
VOL_STEP=5
|
||||
get_vol() { pactl get-sink-volume "$SINK" | awk 'NR==1{print $5+0}'; }
|
||||
get_vol() { wpctl get-volume "$SINK" | awk '{printf "%d", $2 * 100}'; }
|
||||
|
||||
case "$1" in
|
||||
up)
|
||||
vol=$(get_vol)
|
||||
[ "$vol" -lt 100 ] && vol=$((vol + VOL_STEP))
|
||||
[ "$vol" -gt 100 ] && vol=100
|
||||
pactl set-sink-volume "$SINK" "${vol}%"
|
||||
wpctl set-volume "$SINK" "${VOL_STEP}%+" --limit 1.0
|
||||
;;
|
||||
down)
|
||||
vol=$(get_vol)
|
||||
vol=$((vol - VOL_STEP))
|
||||
[ "$vol" -lt 0 ] && vol=0
|
||||
pactl set-sink-volume "$SINK" "${vol}%"
|
||||
wpctl set-volume "$SINK" "${VOL_STEP}%-"
|
||||
;;
|
||||
toggle)
|
||||
pactl set-sink-mute "$SINK" toggle
|
||||
wpctl set-mute "$SINK" toggle
|
||||
;;
|
||||
*)
|
||||
echo "Invalid subcommand: $1" >&2
|
||||
|
|
@ -93,11 +87,8 @@ volume)
|
|||
;;
|
||||
esac
|
||||
|
||||
muted=$(pactl get-sink-mute "$SINK" | awk '{print $2}')
|
||||
vol=$(get_vol)
|
||||
[ "$vol" -gt 100 ] && vol=100
|
||||
|
||||
if [ "$muted" = "yes" ]; then
|
||||
if wpctl get-volume "$SINK" | grep -q MUTED; then
|
||||
notify-send -u low -t 2500 -r 5556 "volume: ${vol}% (muted)"
|
||||
else
|
||||
notify-send -u low -t 2500 -r 5556 "volume: ${vol}%"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue