summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaumit Dinesan <79687674+Saumit-D@users.noreply.github.com>2021-11-29 20:44:01 +0530
committerGitHub <noreply@github.com>2021-11-29 20:44:01 +0530
commit93bae97df7c9f844fa85a1203ff6a86ed51bb029 (patch)
tree9af387f1ef860553a9056b2eaf9e0a800884b7d2
parentd7f1bc1917edec4440f41d6ef638c1e221186ea6 (diff)
Add files via upload
-rw-r--r--scripts/spotifyvoldec.py24
-rw-r--r--scripts/spotifyvolinc.py25
2 files changed, 49 insertions, 0 deletions
diff --git a/scripts/spotifyvoldec.py b/scripts/spotifyvoldec.py
new file mode 100644
index 0000000..a00e06f
--- /dev/null
+++ b/scripts/spotifyvoldec.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python3
+import subprocess
+import os
+x=0
+y=0
+env = os.environ
+env['LANG'] = 'en_US'
+app = '"Spotify"'
+pactl = subprocess.check_output(['pactl', 'list', 'sink-inputs'], env=env).decode().strip().split()
+if app in pactl:
+ for e in pactl:
+ x += 1
+ if e == app:
+ break
+ for i in pactl[0 : x -1 ]:
+ y += 1
+ if i == 'Sink' and pactl[y] == 'Input' and '#' in pactl[y + 1]:
+ sink_id = pactl[y+1]
+ if i == 'Volume:' and '%' in pactl[y + 3]:
+ volume = pactl[y + 3]
+ sink_id = sink_id[1: ]
+ volume = volume[ : -1 ]
+ if int(volume) < 100:
+ subprocess.run(['pactl', 'set-sink-input-volume', sink_id, '-1%'])
diff --git a/scripts/spotifyvolinc.py b/scripts/spotifyvolinc.py
new file mode 100644
index 0000000..f4d04b4
--- /dev/null
+++ b/scripts/spotifyvolinc.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python3
+#Author: Marcin Kocur, attribution license: https://creativecommons.org/licenses/by/4.0/
+import subprocess
+import os
+x=0
+y=0
+env = os.environ
+env['LANG'] = 'en_US'
+app = '"Spotify"'
+pactl = subprocess.check_output(['pactl', 'list', 'sink-inputs'], env=env).decode().strip().split()
+if app in pactl:
+ for e in pactl:
+ x += 1
+ if e == app:
+ break
+ for i in pactl[0 : x -1 ]:
+ y += 1
+ if i == 'Sink' and pactl[y] == 'Input' and '#' in pactl[y + 1]:
+ sink_id = pactl[y+1]
+ if i == 'Volume:' and '%' in pactl[y + 3]:
+ volume = pactl[y + 3]
+ sink_id = sink_id[1: ]
+ volume = volume[ : -1 ]
+ if int(volume) < 100:
+ subprocess.run(['pactl', 'set-sink-input-volume', sink_id, '+1%'])