From 273e3cb4360319298b6cc1090138b0ab79bf1881 Mon Sep 17 00:00:00 2001 From: Paul Wilde Date: Sun, 1 May 2022 18:05:31 +0100 Subject: [PATCH] added set volume by number --- README.MD | 3 +++ fuzzytime.nim | 0 volume.nim | 36 +++++++++++++++++++++++------------- 3 files changed, 26 insertions(+), 13 deletions(-) mode change 100755 => 100644 fuzzytime.nim mode change 100755 => 100644 volume.nim diff --git a/README.MD b/README.MD index 67cb494..d1d2100 100644 --- a/README.MD +++ b/README.MD @@ -32,4 +32,7 @@ There's also an i3bar_tools_threaded folder with tools for use with i3bar/i3bloc These have some configuration variables explicit to me, you'll need to change them for you for them to be useful I imagine. +### Dependencies +- dmenu, rofi, or i3bar (with i3blocks) + I'm aware my code is messy. I'm aware my code is undocumented. But hopefully these things are simple enough to work out. diff --git a/fuzzytime.nim b/fuzzytime.nim old mode 100755 new mode 100644 diff --git a/volume.nim b/volume.nim old mode 100755 new mode 100644 index 25691bb..b33b1a8 --- a/volume.nim +++ b/volume.nim @@ -59,20 +59,30 @@ proc get_volume*(run_once: bool = false) = data.selected_color = black let args = @["up", "down", "mute", "ncpamixer", "pavucontrol"] let option = outputJSON(data,args) - case option: - of "up": - discard execCmd("pamixer -i 5") + if option in args: + case option: + of "up": + discard execCmd("pamixer -i 5") + get_volume() + of "down": + discard execCmd("pamixer -d 5") + get_volume() + of "mute": + discard execCmd("pamixer -t") + get_volume() + of "ncpamixer": + discard execCmd("ncpamixer") + of "pavucontrol": + discard execCmd("pavucontrol") + else: + try: + let vol = parseInt(option) + discard execCmd("pamixer --set-volume " & $vol) get_volume() - of "down": - discard execCmd("pamixer -d 5") - get_volume() - of "mute": - discard execCmd("pamixer -t") - get_volume() - of "ncpamixer": - discard execCmd("ncpamixer") - of "pavucontrol": - discard execCmd("pavucontrol") + except: + echo getCurrentExceptionMsg() + + if run_once: