dynamic line number for rofi

This commit is contained in:
Paul Wilde 2023-02-17 11:44:13 +00:00
parent 41e9cf2a5e
commit 21a424f3e6
2 changed files with 6 additions and 4 deletions

View file

@ -60,7 +60,7 @@ const alert* = "#bd2c40"
const font = "Hermit-12"
const WL_DMENU = "dmenu"
const WL_ROFI = "wofi --dmenu"
var MAX_LINES* = 0
const MAX_LINES = 20
var loop* = false
var stoploop* = true
var tool* = "dmenu"
@ -198,14 +198,17 @@ proc genMenuCmd*(data: Info, opts: varargs[string], rofi: bool = false): string
cmd = cmd & text & "\n"
cmd.removeSuffix("\n")
var x_lines = len(opts)
if x_lines > MAX_LINES:
x_lines = MAX_LINES
cmd = "echo -e" & quote(cmd) & " | "
var menu = newMenu()
cmd = cmd & menu.command & " "
cmd = cmd & menu.extra_cmd & " "
cmd = cmd & menu.i_case & " "
if MAX_LINES > 0:
cmd = cmd & menu.lines_shown & " " & $MAX_LINES & " "
cmd = cmd & menu.lines_shown & " " & $MAX_LINES & " "
cmd = cmd & menu.prompt & quote(data.title)
cmd = cmd & menu.norm_bg & quote(data.unselected_bg)
cmd = cmd & menu.norm_fg & quote(data.unselected_fg)

View file

@ -82,5 +82,4 @@ proc main() =
main()
if isMainModule:
MAX_LINES = 0
main()