From 93bae97df7c9f844fa85a1203ff6a86ed51bb029 Mon Sep 17 00:00:00 2001 From: Saumit Dinesan <79687674+Saumit-D@users.noreply.github.com> Date: Mon, 29 Nov 2021 20:44:01 +0530 Subject: Add files via upload --- scripts/spotifyvolinc.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 scripts/spotifyvolinc.py (limited to 'scripts/spotifyvolinc.py') 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%']) -- cgit v1.2.3