added argument parsing in volume and brightness for ease of binding to wm keys
This commit is contained in:
parent
07cc6d48ad
commit
9ce1df6f65
5 changed files with 49 additions and 13 deletions
2
base.nim
2
base.nim
|
@ -32,7 +32,7 @@ type
|
||||||
x*: int
|
x*: int
|
||||||
y*: int
|
y*: int
|
||||||
|
|
||||||
const font = "Hermit-10"
|
const font = "Hermit-12"
|
||||||
const background* = "#000000"
|
const background* = "#000000"
|
||||||
const backgroundalt* = "#bb222222"
|
const backgroundalt* = "#bb222222"
|
||||||
const backgroundalt2* = "#bb333333"
|
const backgroundalt2* = "#bb333333"
|
||||||
|
|
|
@ -37,6 +37,13 @@ proc getDesign(pcnt: float): string =
|
||||||
let text = icon & " " & $percent & "%"
|
let text = icon & " " & $percent & "%"
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
proc brightnessUp() =
|
||||||
|
let cmd = replace(backlight_up,"%v",default_value)
|
||||||
|
discard execCmd(cmd)
|
||||||
|
proc brightnessDown() =
|
||||||
|
let cmd = replace(backlight_down,"%v",default_value)
|
||||||
|
discard execCmd(cmd)
|
||||||
|
|
||||||
proc getBrightness*(run_once: bool = false) =
|
proc getBrightness*(run_once: bool = false) =
|
||||||
var last_pcnt: float = 0
|
var last_pcnt: float = 0
|
||||||
while true:
|
while true:
|
||||||
|
@ -55,12 +62,10 @@ proc getBrightness*(run_once: bool = false) =
|
||||||
if option in args:
|
if option in args:
|
||||||
case option:
|
case option:
|
||||||
of "up":
|
of "up":
|
||||||
let cmd = replace(backlight_up,"%v",default_value)
|
brightnessUp()
|
||||||
discard execCmd(cmd)
|
|
||||||
getBrightness(true)
|
getBrightness(true)
|
||||||
of "down":
|
of "down":
|
||||||
let cmd = replace(backlight_down,"%v",default_value)
|
brightnessDown()
|
||||||
discard execCmd(cmd)
|
|
||||||
getBrightness(true)
|
getBrightness(true)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
|
@ -85,4 +90,14 @@ proc main() =
|
||||||
getBrightness()
|
getBrightness()
|
||||||
|
|
||||||
if isMainModule:
|
if isMainModule:
|
||||||
|
block start:
|
||||||
|
for arg in args:
|
||||||
|
case arg:
|
||||||
|
of "up":
|
||||||
|
brightnessUp()
|
||||||
|
break start
|
||||||
|
of "down":
|
||||||
|
brightnessDown()
|
||||||
|
break start
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
0
compile_all.sh
Executable file → Normal file
0
compile_all.sh
Executable file → Normal file
0
fuzzytime.nim
Executable file → Normal file
0
fuzzytime.nim
Executable file → Normal file
33
volume.nim
Executable file → Normal file
33
volume.nim
Executable file → Normal file
|
@ -1,5 +1,5 @@
|
||||||
import base
|
import base
|
||||||
import std/[os,strutils,sequtils,osproc,math]
|
import std/[os,strutils,sequtils,osproc]
|
||||||
|
|
||||||
const audio_tools = @["ncpamixer", "pavucontrol"]
|
const audio_tools = @["ncpamixer", "pavucontrol"]
|
||||||
const vol_cmd = "pamixer"
|
const vol_cmd = "pamixer"
|
||||||
|
@ -52,6 +52,17 @@ proc getCurrentVolume(): string =
|
||||||
let vol = execCmdEx(vol_get)
|
let vol = execCmdEx(vol_get)
|
||||||
return vol.output
|
return vol.output
|
||||||
|
|
||||||
|
proc volumeUp() =
|
||||||
|
let cmd = replace(vol_up, "%v", vol_default_by)
|
||||||
|
discard execCmd(cmd)
|
||||||
|
|
||||||
|
proc volumeDown() =
|
||||||
|
let cmd = replace(vol_down, "%v", vol_default_by)
|
||||||
|
discard execCmd(cmd)
|
||||||
|
|
||||||
|
proc volumeMute() =
|
||||||
|
discard execCmd(vol_mute)
|
||||||
|
|
||||||
proc getVolume*(run_once: bool = false) =
|
proc getVolume*(run_once: bool = false) =
|
||||||
let vol = getCurrentVolume()
|
let vol = getCurrentVolume()
|
||||||
let (text, main_text) = getDesign(vol)
|
let (text, main_text) = getDesign(vol)
|
||||||
|
@ -74,15 +85,13 @@ proc getVolume*(run_once: bool = false) =
|
||||||
return
|
return
|
||||||
case option:
|
case option:
|
||||||
of "up":
|
of "up":
|
||||||
let cmd = replace(vol_up, "%v", vol_default_by)
|
volumeUp()
|
||||||
discard execCmd(cmd)
|
|
||||||
getVolume()
|
getVolume()
|
||||||
of "down":
|
of "down":
|
||||||
let cmd = replace(vol_down, "%v", vol_default_by)
|
volumeDown()
|
||||||
discard execCmd(cmd)
|
|
||||||
getVolume()
|
getVolume()
|
||||||
of "mute":
|
of "mute":
|
||||||
discard execCmd(vol_mute)
|
volumeMute()
|
||||||
getVolume()
|
getVolume()
|
||||||
of "---":
|
of "---":
|
||||||
getVolume()
|
getVolume()
|
||||||
|
@ -102,4 +111,16 @@ proc main() =
|
||||||
getVolume()
|
getVolume()
|
||||||
|
|
||||||
if isMainModule:
|
if isMainModule:
|
||||||
|
block start:
|
||||||
|
for arg in args:
|
||||||
|
case arg:
|
||||||
|
of "up":
|
||||||
|
volumeUp()
|
||||||
|
break start
|
||||||
|
of "down":
|
||||||
|
volumeDown()
|
||||||
|
break start
|
||||||
|
of "mute":
|
||||||
|
volumeMute()
|
||||||
|
break start
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue