added set brightness by number

This commit is contained in:
Paul Wilde 2022-05-01 18:09:07 +01:00
parent 273e3cb436
commit d59ea16991
2 changed files with 17 additions and 6 deletions

View file

@ -28,6 +28,9 @@ or
it can also be run without any arguments to receive a i3bar compatible json string
Personally, I have these bound to key combinations in i3. In fact, I have a seperate `bindsym` mode in which all these tools are accessible i.e. `$mod+i` to get to "info" mode then `p` to show pingclock.
You can also set the volume and brightness levels by typing a numeric figure into the dmenu/rofi input box
There's also an i3bar_tools_threaded folder with tools for use with i3bar/i3blocks which continously update. Currently these are not working as I recently switched from this as primary, to a secondary choice.
These have some configuration variables explicit to me, you'll need to change them for you for them to be useful I imagine.

View file

@ -44,13 +44,21 @@ proc get_brightness*(run_once: bool = false) =
data.selected_color = black
let args = @["up", "down"]
let option = outputJSON(data,args)
case option:
of "up":
discard execCmd("xbacklight -inc 5")
get_brightness(true)
of "down":
discard execCmd("xbacklight -dec 5")
if option in args:
case option:
of "up":
discard execCmd("xbacklight -inc 5")
get_brightness(true)
of "down":
discard execCmd("xbacklight -dec 5")
get_brightness(true)
else:
try:
let i = parseInt(option)
discard execCmd("xbacklight -set " & $i)
get_brightness(true)
except:
echo getCurrentExceptionMsg()
if run_once:
break