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
|
||||
max_lines*: int
|
||||
prepend*: bool
|
||||
to_stdout*: bool
|
||||
screenshot_tool*: ScreenshotTool
|
||||
|
||||
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")
|
||||
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 =
|
||||
var cmd = ""
|
||||
# length of the list of opts, plus the full text
|
||||
var x_lines = len(opts) + 1
|
||||
# if the text is empty, we don't want to create a menu item of it
|
||||
if data.full_text != "":
|
||||
|
@ -52,11 +62,14 @@ proc genMenuCmd(data: Info, opts: varargs[string]): string =
|
|||
return cmd
|
||||
|
||||
proc runExec(data: Info, opts: varargs[string]): string =
|
||||
let cmd = genMenuCmd(data, opts)
|
||||
var output = execCmdEx(cmd)
|
||||
echo "Output:\n" & $output
|
||||
output.output.stripLineEnd()
|
||||
return output.output
|
||||
if not myConfig.to_stdout:
|
||||
let cmd = genMenuCmd(data, opts)
|
||||
var output = execCmdEx(cmd)
|
||||
echo "Output:\n" & $output
|
||||
output.output.stripLineEnd()
|
||||
return output.output
|
||||
else:
|
||||
stdout.writeLine listify(data,opts)
|
||||
|
||||
proc outputData*(data: Info, args: varargs[string,`$`]): string {.discardable.} =
|
||||
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")
|
||||
arg("input",help="the tool to run, i.e. furrytime, pingclock, volurrme, etc.")
|
||||
arg("others", nargs = -1)
|
||||
flag("-o","--output",help="outputs to stdout instead of something else")
|
||||
try:
|
||||
var opts = p.parse(params)
|
||||
# TODO sort this but out, handle args for all modules, etc.
|
||||
myConfig.to_stdout = opts.output
|
||||
case opts.input
|
||||
of "furrytime", "fuzzytime", "time":
|
||||
myConfig.run = FurryTime
|
||||
|
|
Loading…
Reference in a new issue