rofi integration

This commit is contained in:
Paul Wilde 2022-04-29 09:59:28 +01:00
parent c2533fb7cf
commit 2e0010a327
2 changed files with 13 additions and 10 deletions

View file

@ -8,6 +8,13 @@ They are compiled separately, for example:
```nim
nim c pingclock
```
and then run with
```sh
./pingclock dmenu
or
./pingclock rofi
```
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.
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.

View file

@ -80,13 +80,16 @@ proc getArguments*(): seq[string] =
let args = commandLineParams()
return args
proc runDMenu*(data: Info, opts: varargs[string]): string =
proc runDMenu*(data: Info, opts: varargs[string], rofi: bool = false): string =
discard execCmd("i3-msg mode \"default\"")
var cmd = "echo -e \"" & $data.full_text & "\n"
for opt in opts:
cmd = cmd & opt & "\n"
cmd.removeSuffix("\n")
cmd = cmd & "\" | dmenu"
if not rofi:
cmd = cmd & "\" | dmenu"
else:
cmd = cmd & "\" | rofi -dmenu"
cmd = cmd & " -l " & $(len(opts) + 1)
cmd = cmd & " -p \"" & $data.title & "\""
cmd = cmd & " -nb \"" & $background & "\""
@ -99,19 +102,12 @@ proc runDMenu*(data: Info, opts: varargs[string]): string =
let option:string = strip(output[0])
return option
proc runRofi*(data: Info) =
discard execCmd("i3-msg mode \"default\"")
var cmd = "rofi"
cmd = cmd & " -e \"" & $data.full_text & "\""
#echo "Rofi : ", cmd
discard execCmd(cmd)
proc outputJSON*(data: Info, args: varargs[string]): string {.discardable.} =
var output = ""
if dmenu:
output = runDMenu(data, args)
elif rofi:
runRofi(data)
output = runDmenu(data,args, rofi = true)
else:
var j_data = data
if j_data.html_text != "":