17
bin/cycle_pactl.sh
Executable file
17
bin/cycle_pactl.sh
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
default_sink=$(pactl info | grep "Default Sink:" | cut '-d ' -f3)
|
||||||
|
sinks=$(pactl list short sinks | cut -f2)
|
||||||
|
|
||||||
|
# for wrap-around
|
||||||
|
sinks="$sinks
|
||||||
|
$sinks"
|
||||||
|
|
||||||
|
next_sink=$(echo "$sinks" | awk "/$default_sink/{getline x;print x;exit;}")
|
||||||
|
|
||||||
|
pactl set-default-sink "$next_sink"
|
||||||
|
pactl list short sink-inputs | \
|
||||||
|
cut -f1 | \
|
||||||
|
xargs -I{} pactl move-sink-input {} "$next_sink"
|
||||||
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
import pulsectl
|
|
||||||
|
|
||||||
pulse = pulsectl.Pulse('my-client-name')
|
|
||||||
|
|
||||||
|
|
||||||
class my_sink:
|
|
||||||
name = "Here goes the name of the sink"
|
|
||||||
index = -1
|
|
||||||
desc = "Here goes a description"
|
|
||||||
sink = ""
|
|
||||||
|
|
||||||
def __init__(self, sink):
|
|
||||||
self.name = sink.name
|
|
||||||
self.index = sink.index
|
|
||||||
self.desc = sink.description
|
|
||||||
self.sink = sink
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return f"\"{self.name}\" with index {self.index} and description: \"{self.desc}\""
|
|
||||||
|
|
||||||
|
|
||||||
def get_sinks():
|
|
||||||
output_sinks = []
|
|
||||||
print(pulse.sink_list())
|
|
||||||
for s in pulse.sink_list():
|
|
||||||
m = my_sink(s)
|
|
||||||
output_sinks.append(m)
|
|
||||||
|
|
||||||
print(output_sinks)
|
|
||||||
return output_sinks
|
|
||||||
|
|
||||||
|
|
||||||
def next_sink(output_sinks):
|
|
||||||
current_sink = pulse.server_info().default_sink_name
|
|
||||||
position = 0
|
|
||||||
for s in output_sinks:
|
|
||||||
if s.name == current_sink:
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
position += 1
|
|
||||||
|
|
||||||
if position == len(output_sinks) - 1:
|
|
||||||
new_output = output_sinks[0]
|
|
||||||
else:
|
|
||||||
new_output = output_sinks[position+1]
|
|
||||||
|
|
||||||
print(current_sink + " will be switched to " + new_output.name)
|
|
||||||
|
|
||||||
pulse.default_set(new_output.sink)
|
|
||||||
|
|
||||||
|
|
||||||
# Press the green button in the gutter to run the script.
|
|
||||||
if __name__ == '__main__':
|
|
||||||
next_sink(get_sinks())
|
|
||||||
Reference in New Issue
Block a user