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

View file

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