Rofi scripts for extra menus
This commit is contained in:
Executable
+65
@@ -0,0 +1,65 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# rofi-audio-switch: pick a PulseAudio/PipeWire sink via rofi
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Get list of sinks: index, name, description
|
||||||
|
mapfile -t sinks < <(pactl list sinks | awk -F': ' '
|
||||||
|
/^Sink #/ { idx=$2 }
|
||||||
|
/Name:/ { name=$2 }
|
||||||
|
/Description:/ { desc=$2; print idx"\t"name"\t"desc }
|
||||||
|
')
|
||||||
|
|
||||||
|
if [ "${#sinks[@]}" -eq 0 ]; then
|
||||||
|
notify-send "Audio Switch" "No sinks found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
current_sink=$(pactl get-default-sink)
|
||||||
|
|
||||||
|
# Build rofi menu: show description, mark current with a star
|
||||||
|
menu=""
|
||||||
|
for line in "${sinks[@]}"; do
|
||||||
|
name=$(echo "$line" | cut -f2)
|
||||||
|
desc=$(echo "$line" | cut -f3)
|
||||||
|
if [ "$name" = "$current_sink" ]; then
|
||||||
|
menu+="* $desc\n"
|
||||||
|
else
|
||||||
|
menu+=" $desc\n"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
chosen=$(echo -e "$menu" | rofi -dmenu -i -p "Audio Output" -markup-rows \
|
||||||
|
-theme-str 'listview { lines: 3; }' \
|
||||||
|
-theme-str 'window { height: 220px; }')
|
||||||
|
|
||||||
|
[ -z "$chosen" ] && exit 0
|
||||||
|
|
||||||
|
# Strip the leading marker to match description text
|
||||||
|
chosen_desc=$(echo "$chosen" | sed 's/^[* ] //')
|
||||||
|
|
||||||
|
# Find matching sink name for that description
|
||||||
|
target_name=""
|
||||||
|
for line in "${sinks[@]}"; do
|
||||||
|
desc=$(echo "$line" | cut -f3)
|
||||||
|
if [ "$desc" = "$chosen_desc" ]; then
|
||||||
|
target_name=$(echo "$line" | cut -f2)
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$target_name" ]; then
|
||||||
|
notify-send "Audio Switch" "Could not resolve selection"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set as default sink
|
||||||
|
pactl set-default-sink "$target_name"
|
||||||
|
|
||||||
|
# Move all currently running streams to the new sink
|
||||||
|
mapfile -t inputs < <(pactl list short sink-inputs | cut -f1)
|
||||||
|
for input in "${inputs[@]}"; do
|
||||||
|
pactl move-sink-input "$input" "$target_name"
|
||||||
|
done
|
||||||
|
|
||||||
|
notify-send "Audio Switch" "Switched to: $chosen_desc"
|
||||||
Executable
+24
@@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# rofi-power-menu: logout / restart / shutdown via rofi
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
options=" Logout\n Restart\n Shutdown"
|
||||||
|
|
||||||
|
chosen=$(echo -e "$options" | rofi -dmenu -i -p "Power" -markup-rows \
|
||||||
|
-theme-str 'listview { lines: 3; }' \
|
||||||
|
-theme-str 'window { height: 240px; }')
|
||||||
|
|
||||||
|
[ -z "$chosen" ] && exit 0
|
||||||
|
|
||||||
|
case "$chosen" in
|
||||||
|
*Logout*)
|
||||||
|
awesome-client "awesome.quit()" 2>/dev/null || echo "awesome.quit()" | awesome-client
|
||||||
|
;;
|
||||||
|
*Restart*)
|
||||||
|
loginctl reboot
|
||||||
|
;;
|
||||||
|
*Shutdown*)
|
||||||
|
loginctl poweroff
|
||||||
|
;;
|
||||||
|
esac
|
||||||
Reference in New Issue
Block a user