added tideurrl
This commit is contained in:
parent
92d1eea678
commit
f77e0edd6c
3 changed files with 22 additions and 5 deletions
|
@ -10,6 +10,7 @@ type
|
||||||
run*: Tool
|
run*: Tool
|
||||||
max_lines*: int
|
max_lines*: int
|
||||||
prepend*: bool
|
prepend*: bool
|
||||||
|
to_stdout*: bool
|
||||||
screenshot_tool*: ScreenshotTool
|
screenshot_tool*: ScreenshotTool
|
||||||
|
|
||||||
let config_dir* = getHomeDir() & ".config/wm_tools/"
|
let config_dir* = getHomeDir() & ".config/wm_tools/"
|
||||||
|
|
|
@ -25,8 +25,18 @@ proc copyToClipboard*(str: string): bool {.discardable.} =
|
||||||
let ok = execCmd("echo -n " & quote(str) & " | xclip -selection clipboard")
|
let ok = execCmd("echo -n " & quote(str) & " | xclip -selection clipboard")
|
||||||
return ok == 0
|
return ok == 0
|
||||||
|
|
||||||
|
proc listify(data:Info, opts: varargs[string]): string =
|
||||||
|
var text = data.full_text
|
||||||
|
if opts.len > 0:
|
||||||
|
text &= "\n"
|
||||||
|
for opt in opts:
|
||||||
|
text &= markup text
|
||||||
|
text &= "\n"
|
||||||
|
return text
|
||||||
|
|
||||||
proc genMenuCmd(data: Info, opts: varargs[string]): string =
|
proc genMenuCmd(data: Info, opts: varargs[string]): string =
|
||||||
var cmd = ""
|
var cmd = ""
|
||||||
|
# length of the list of opts, plus the full text
|
||||||
var x_lines = len(opts) + 1
|
var x_lines = len(opts) + 1
|
||||||
# if the text is empty, we don't want to create a menu item of it
|
# if the text is empty, we don't want to create a menu item of it
|
||||||
if data.full_text != "":
|
if data.full_text != "":
|
||||||
|
@ -52,11 +62,14 @@ proc genMenuCmd(data: Info, opts: varargs[string]): string =
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
proc runExec(data: Info, opts: varargs[string]): string =
|
proc runExec(data: Info, opts: varargs[string]): string =
|
||||||
|
if not myConfig.to_stdout:
|
||||||
let cmd = genMenuCmd(data, opts)
|
let cmd = genMenuCmd(data, opts)
|
||||||
var output = execCmdEx(cmd)
|
var output = execCmdEx(cmd)
|
||||||
echo "Output:\n" & $output
|
echo "Output:\n" & $output
|
||||||
output.output.stripLineEnd()
|
output.output.stripLineEnd()
|
||||||
return output.output
|
return output.output
|
||||||
|
else:
|
||||||
|
stdout.writeLine listify(data,opts)
|
||||||
|
|
||||||
proc outputData*(data: Info, args: varargs[string,`$`]): string {.discardable.} =
|
proc outputData*(data: Info, args: varargs[string,`$`]): string {.discardable.} =
|
||||||
var output = runExec(data,args)
|
var output = runExec(data,args)
|
||||||
|
|
|
@ -15,8 +15,11 @@ proc parseArgs*() =
|
||||||
help("WMTools : a set of tools to output option to your program of choice i.e. Rofi")
|
help("WMTools : a set of tools to output option to your program of choice i.e. Rofi")
|
||||||
arg("input",help="the tool to run, i.e. furrytime, pingclock, volurrme, etc.")
|
arg("input",help="the tool to run, i.e. furrytime, pingclock, volurrme, etc.")
|
||||||
arg("others", nargs = -1)
|
arg("others", nargs = -1)
|
||||||
|
flag("-o","--output",help="outputs to stdout instead of something else")
|
||||||
try:
|
try:
|
||||||
var opts = p.parse(params)
|
var opts = p.parse(params)
|
||||||
|
# TODO sort this but out, handle args for all modules, etc.
|
||||||
|
myConfig.to_stdout = opts.output
|
||||||
case opts.input
|
case opts.input
|
||||||
of "furrytime", "fuzzytime", "time":
|
of "furrytime", "fuzzytime", "time":
|
||||||
myConfig.run = FurryTime
|
myConfig.run = FurryTime
|
||||||
|
|
Loading…
Reference in a new issue