From 4bf9a8e266375d51a802369bd94c26a83ea19f06 Mon Sep 17 00:00:00 2001 From: Paul Wilde Date: Fri, 8 Jul 2022 12:19:53 +0100 Subject: [PATCH] switched back to dmenu mode as I personally prefer it --- base.nim | 26 ++++++++++++-------------- date.nim | 2 +- fuzzytime.nim | 2 +- notes.nim | 2 +- tides.nim | 4 ++-- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/base.nim b/base.nim index 796f26b..b0512a4 100644 --- a/base.nim +++ b/base.nim @@ -34,7 +34,6 @@ type x*: int y*: int -const font = "Hermit-8" const background* = "#000000" const backgroundalt* = "#bb222222" const backgroundalt2* = "#bb333333" @@ -57,17 +56,17 @@ const primary* = yellow const secondary* = red const alert* = "#bd2c40" const MAX_LINES = 20 +const font = "Hermit-12" var loop* = false var stoploop* = true -var dmenu* = false -var rofi* = true +var tool* = "dmenu" var passmenu* = false var command_wrapper* = false var run_command* = "" proc newInfo*(str: string = "Info"): Info = var title = str - if rofi: + if tool == "rofi": title = title & " : " return Info( title: title, @@ -81,7 +80,7 @@ proc newInfo*(str: string = "Info"): Info = color: foreground, ) -proc newMenuConfig(cmd: string = "rofi -dmenu"): Menu = +proc newMenuConfig(cmd: string = "dmenu"): Menu = var menu = Menu() menu.command = cmd menu.prompt = "-p" @@ -89,14 +88,13 @@ proc newMenuConfig(cmd: string = "rofi -dmenu"): Menu = menu.lines_shown = "-l" return menu -proc newRofiConfig(): Menu = - var menu = newMenuConfig() +proc newRofiConfig(cmd: string = "rofi -dmenu"): Menu = + var menu = newMenuConfig(cmd) menu.extra_cmd = "-markup-rows -kb-row-select \"Tab\" -kb-row-tab \"\"" return menu proc newDmenuConfig(cmd: string = "dmenu"): Menu = - var menu = newMenuConfig("dmenu") - menu.command = cmd + var menu = newMenuConfig(cmd) menu.bottom = "-b" menu.grabkb = "-f" menu.monitor = "-m" @@ -112,9 +110,9 @@ proc newMenu(): Menu = return newDmenuConfig("passmenu") elif command_wrapper: return newDmenuConfig(run_command) - elif rofi: + elif tool == "rofi": return newRofiConfig() - elif dmenu: + elif tool == "dmenu": return newDmenuConfig() return newMenuConfig() @@ -205,7 +203,7 @@ proc copyToClipboard*(str: string) = proc outputData*(data: Info, args: varargs[string]): string {.discardable.} = var output = "" - if rofi: + if tool == "rofi": output = runMenu(data,args, rofi = true) elif loop: # mainly for i3bar/i3blocks compatible output @@ -237,10 +235,10 @@ for idx, arg in args: stoploop = false of "dmenu": stoploop = true - dmenu = true + tool = "dmenu" of "rofi": stoploop = true - rofi = true + tool = "rofi" of ["pass","passmenu"]: passmenu = true break diff --git a/date.nim b/date.nim index cf4299b..a7f3fff 100644 --- a/date.nim +++ b/date.nim @@ -1,5 +1,5 @@ import base -import std/[os,times,osproc,re] +import std/[times,osproc,re] const default_bg = blue const default_fg = white diff --git a/fuzzytime.nim b/fuzzytime.nim index ca5cdf0..4d9efad 100755 --- a/fuzzytime.nim +++ b/fuzzytime.nim @@ -1,5 +1,5 @@ import base -import std/[os,times] +import std/[times] const default_bg = lightblue const default_fg = black diff --git a/notes.nim b/notes.nim index c55a9bd..76b2aec 100644 --- a/notes.nim +++ b/notes.nim @@ -158,7 +158,7 @@ proc startNotes() = proc main() = echo "Note dir : ", note_dir - if not dmenu and not rofi: + if tool != "dmenu" and tool != "rofi": echo "Can only be run in dmenu or rofi mode. Exiting..." return startNotes() diff --git a/tides.nim b/tides.nim index 5636b16..0e6718a 100644 --- a/tides.nim +++ b/tides.nim @@ -1,6 +1,6 @@ #curl https://www.tidetimes.org.uk/exmouth-dock-tide-times-20190101 | grep -E -o ">((High|Low)|([0-9]+:[0-9]+)|([0-9]+\.[0-9]+m))" import base -import std/[re,httpclient,os,times,osproc,sequtils] +import std/[re,httpclient,times,osproc,sequtils] # TODO: # Pass location in as variable @@ -76,7 +76,7 @@ proc getDesign(tides: seq[Tide]): Info = data.args = my_tides return data -proc getTides*(get_tomorrow: bool = false) {.gcsafe.}= +proc getTides*(get_tomorrow: bool = false) = var mytides = TideList() mytides.Tides = getTideData(get_tomorrow) mytides.Tides = sortTides(mytides.Tides, get_tomorrow)