diff --git a/README.MD b/README.MD index 10b6cae..1477d6e 100644 --- a/README.MD +++ b/README.MD @@ -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. diff --git a/base.nim b/base.nim index 12bc120..fe3aec2 100644 --- a/base.nim +++ b/base.nim @@ -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 != "":