rofi integration
This commit is contained in:
parent
c2533fb7cf
commit
2e0010a327
2 changed files with 13 additions and 10 deletions
|
@ -8,6 +8,13 @@ They are compiled separately, for example:
|
||||||
```nim
|
```nim
|
||||||
nim c pingclock
|
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.
|
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.
|
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.
|
||||||
|
|
14
base.nim
14
base.nim
|
@ -80,13 +80,16 @@ proc getArguments*(): seq[string] =
|
||||||
let args = commandLineParams()
|
let args = commandLineParams()
|
||||||
return args
|
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\"")
|
discard execCmd("i3-msg mode \"default\"")
|
||||||
var cmd = "echo -e \"" & $data.full_text & "\n"
|
var cmd = "echo -e \"" & $data.full_text & "\n"
|
||||||
for opt in opts:
|
for opt in opts:
|
||||||
cmd = cmd & opt & "\n"
|
cmd = cmd & opt & "\n"
|
||||||
cmd.removeSuffix("\n")
|
cmd.removeSuffix("\n")
|
||||||
|
if not rofi:
|
||||||
cmd = cmd & "\" | dmenu"
|
cmd = cmd & "\" | dmenu"
|
||||||
|
else:
|
||||||
|
cmd = cmd & "\" | rofi -dmenu"
|
||||||
cmd = cmd & " -l " & $(len(opts) + 1)
|
cmd = cmd & " -l " & $(len(opts) + 1)
|
||||||
cmd = cmd & " -p \"" & $data.title & "\""
|
cmd = cmd & " -p \"" & $data.title & "\""
|
||||||
cmd = cmd & " -nb \"" & $background & "\""
|
cmd = cmd & " -nb \"" & $background & "\""
|
||||||
|
@ -99,19 +102,12 @@ proc runDMenu*(data: Info, opts: varargs[string]): string =
|
||||||
let option:string = strip(output[0])
|
let option:string = strip(output[0])
|
||||||
return option
|
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.} =
|
proc outputJSON*(data: Info, args: varargs[string]): string {.discardable.} =
|
||||||
var output = ""
|
var output = ""
|
||||||
if dmenu:
|
if dmenu:
|
||||||
output = runDMenu(data, args)
|
output = runDMenu(data, args)
|
||||||
elif rofi:
|
elif rofi:
|
||||||
runRofi(data)
|
output = runDmenu(data,args, rofi = true)
|
||||||
else:
|
else:
|
||||||
var j_data = data
|
var j_data = data
|
||||||
if j_data.html_text != "":
|
if j_data.html_text != "":
|
||||||
|
|
Loading…
Reference in a new issue