summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
author--global <ik.boikov.public@protonmail.com>2022-01-02 23:04:59 +0100
committer--global <ik.boikov.public@protonmail.com>2022-01-02 23:04:59 +0100
commit45f90b28c5325bedb96ef14eed0e456a0f79b1e9 (patch)
tree6c61da54a180dd56f6ebe349cfc57f9d09c7329e /scripts
parent8667da4ba41aef6c9484eb2fb6ff7ec471708cc4 (diff)
load xresources in xinitrc
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/.local/bin/chsink34
-rwxr-xr-xscripts/.local/bin/setsink35
2 files changed, 33 insertions, 36 deletions
diff --git a/scripts/.local/bin/chsink b/scripts/.local/bin/chsink
index 0ae374b..90355e6 100755
--- a/scripts/.local/bin/chsink
+++ b/scripts/.local/bin/chsink
@@ -1,2 +1,34 @@
#!/bin/sh
-pactl list sinks short | awk '{print $2}' | cdmenu -l 100 | setsink
+
+setsink() {
+ tgtdevname=$(cat -)
+ if [ -z "$tgtdevname" ]; then
+ echo "No device passed"
+ return
+ fi
+
+ tgtdev=$(pactl list sinks short | grep $tgtdevname)
+ tgtdevid=$(echo $tgtdev | awk '{print $1}')
+ curdevid=$(pactl list sinks short | grep RUNNING | awk '{print $1}')
+
+ echo "Swapping to device $tgtdev"
+ echo "Device ID $tgtdevid"
+ echo "Device name $tgtdevname"
+ echo "Current device ID $curdevid"
+ notify-send "Swapping to $tgtdevname"
+
+ pactl set-default-sink $tgtdevid
+ if [ -n "$curdevid" ]; then
+ pactl suspend-sink $curdevid 1
+ fi
+ pactl suspend-sink $tgtdevid 0
+
+ #move all audio streams to the new sink
+ pactl list short sink-inputs | while read stream; do
+ streamId=$(echo $stream | awk '{print $1}')
+ echo 'Moving stream' $stream 'with id' $streamId
+ pactl move-sink-input "$streamId" "$tgtdevid"
+ done
+}
+
+pactl list sinks short | awk '{print $2}' | cdmenu -l 32 | setsink
diff --git a/scripts/.local/bin/setsink b/scripts/.local/bin/setsink
deleted file mode 100755
index 793cfbf..0000000
--- a/scripts/.local/bin/setsink
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/zsh
-
-export DISPLAY=:0.0
-
-devname=$(cat -)
-if [[ -z "$devname" ]]; then
- echo "No device passed"
- return
-fi
-
-device=$(pactl list sinks short | grep $devname)
-devid=$(echo $device | awk '{print $1}')
-curdevid=$(pactl list sinks short | grep RUNNING | awk '{print $1}')
-
-echo "Swapping to device $device"
-echo "Device ID $devid"
-echo "Device name $devname"
-echo "Current device ID $curdevid"
-notify-send "Swapping to $devname"
-
-pacmd set-default-sink $devid
-if [[ -n "$curdevid" ]]; then
- pacmd suspend-sink $curdevid 1
-fi
-pacmd suspend-sink $devid 0
-
-#move all audio streams to the new sink
-pactl list short sink-inputs | while read stream; do
- streamId=$(echo $stream | awk '{print $1}')
- echo 'Moving stream' $stream 'with id' $streamId
- pacmd move-sink-input "$streamId" "$devid"
-done
-
-
-