switched back to dmenu mode as I personally prefer it

This commit is contained in:
Paul Wilde 2022-07-08 12:19:53 +01:00
parent 5cd6f85b5d
commit 4bf9a8e266
5 changed files with 17 additions and 19 deletions

View file

@ -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

View file

@ -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

View file

@ -1,5 +1,5 @@
import base
import std/[os,times]
import std/[times]
const default_bg = lightblue
const default_fg = black

View file

@ -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()

View file

@ -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)