switched default to rofi
This commit is contained in:
parent
d7128e0540
commit
836cfab8d8
8 changed files with 72 additions and 50 deletions
105
base.nim
105
base.nim
|
@ -15,7 +15,7 @@ type
|
||||||
html_text*: string
|
html_text*: string
|
||||||
short_text*: string
|
short_text*: string
|
||||||
args*: seq[string]
|
args*: seq[string]
|
||||||
Dmenu = object
|
Menu = object
|
||||||
command: string
|
command: string
|
||||||
bottom: string
|
bottom: string
|
||||||
grab_kb: string
|
grab_kb: string
|
||||||
|
@ -28,12 +28,13 @@ type
|
||||||
norm_fg: string
|
norm_fg: string
|
||||||
sel_bg: string
|
sel_bg: string
|
||||||
sel_fg: string
|
sel_fg: string
|
||||||
|
extra_cmd: string
|
||||||
i3BarInput* = object
|
i3BarInput* = object
|
||||||
button*: int
|
button*: int
|
||||||
x*: int
|
x*: int
|
||||||
y*: int
|
y*: int
|
||||||
|
|
||||||
const font = "Hermit-12"
|
const font = "Hermit-8"
|
||||||
const background* = "#000000"
|
const background* = "#000000"
|
||||||
const backgroundalt* = "#bb222222"
|
const backgroundalt* = "#bb222222"
|
||||||
const backgroundalt2* = "#bb333333"
|
const backgroundalt2* = "#bb333333"
|
||||||
|
@ -58,8 +59,8 @@ const alert* = "#bd2c40"
|
||||||
const MAX_LINES = 20
|
const MAX_LINES = 20
|
||||||
var loop* = false
|
var loop* = false
|
||||||
var stoploop* = true
|
var stoploop* = true
|
||||||
var dmenu* = true
|
var dmenu* = false
|
||||||
var rofi* = false
|
var rofi* = true
|
||||||
var passmenu* = false
|
var passmenu* = false
|
||||||
var command_wrapper* = false
|
var command_wrapper* = false
|
||||||
var run_command* = ""
|
var run_command* = ""
|
||||||
|
@ -80,35 +81,41 @@ proc newInfo*(str: string = "Info"): Info =
|
||||||
color: foreground,
|
color: foreground,
|
||||||
)
|
)
|
||||||
|
|
||||||
proc newDmenuConfig(cmd: string = "dmenu"): Dmenu =
|
proc newMenuConfig(cmd: string = "rofi -dmenu"): Menu =
|
||||||
var dmenu = Dmenu()
|
var menu = Menu()
|
||||||
dmenu.command = cmd
|
menu.command = cmd
|
||||||
dmenu.bottom = "-b"
|
menu.prompt = "-p"
|
||||||
dmenu.grabkb = "-f"
|
menu.i_case = "-i"
|
||||||
dmenu.i_case = "-i"
|
menu.lines_shown = "-l"
|
||||||
dmenu.lines_shown = "-l"
|
return menu
|
||||||
dmenu.monitor = "-m"
|
|
||||||
dmenu.prompt = "-p"
|
|
||||||
dmenu.font = "-fn"
|
|
||||||
dmenu.norm_bg = "-nb"
|
|
||||||
dmenu.norm_fg = "-nf"
|
|
||||||
dmenu.sel_bg = "-sb"
|
|
||||||
dmenu.sel_fg = "-sf"
|
|
||||||
return dmenu
|
|
||||||
|
|
||||||
proc newRofiConfig(): Dmenu =
|
proc newRofiConfig(): Menu =
|
||||||
var rofi = newDmenuConfig()
|
var menu = newMenuConfig()
|
||||||
rofi.command = "rofi -dmenu"
|
menu.extra_cmd = "-markup-rows -kb-row-select \"Tab\" -kb-row-tab \"\""
|
||||||
return rofi
|
return menu
|
||||||
|
|
||||||
proc newDmenu(): Dmenu =
|
proc newDmenuConfig(cmd: string = "dmenu"): Menu =
|
||||||
|
var menu = newMenuConfig("dmenu")
|
||||||
|
menu.bottom = "-b"
|
||||||
|
menu.grabkb = "-f"
|
||||||
|
menu.monitor = "-m"
|
||||||
|
menu.font = "-fn"
|
||||||
|
menu.norm_bg = "-nb"
|
||||||
|
menu.norm_fg = "-nf"
|
||||||
|
menu.sel_bg = "-sb"
|
||||||
|
menu.sel_fg = "-sf"
|
||||||
|
return menu
|
||||||
|
|
||||||
|
proc newMenu(): Menu =
|
||||||
if rofi:
|
if rofi:
|
||||||
return newRofiConfig()
|
return newRofiConfig()
|
||||||
elif passmenu:
|
if dmenu:
|
||||||
return newDmenuConfig("passmenu")
|
|
||||||
elif command_wrapper:
|
|
||||||
return newDmenuConfig(run_command)
|
|
||||||
return newDmenuConfig()
|
return newDmenuConfig()
|
||||||
|
elif passmenu:
|
||||||
|
return newMenuConfig("passmenu")
|
||||||
|
elif command_wrapper:
|
||||||
|
return newMenuConfig(run_command)
|
||||||
|
return newMenuConfig()
|
||||||
|
|
||||||
proc debugLog*(str: string) =
|
proc debugLog*(str: string) =
|
||||||
let f = open("/tmp/debug.txt",fmAppend)
|
let f = open("/tmp/debug.txt",fmAppend)
|
||||||
|
@ -147,34 +154,44 @@ proc quote*(str: string): string =
|
||||||
# Put leading and ending quote marks in
|
# Put leading and ending quote marks in
|
||||||
return " \"" & text & "\" "
|
return " \"" & text & "\" "
|
||||||
# ^ Add a spaces ^ so the previous flag isn't touching
|
# ^ Add a spaces ^ so the previous flag isn't touching
|
||||||
|
#
|
||||||
|
proc markup(str: string): string =
|
||||||
|
var text = str
|
||||||
|
|
||||||
proc genDmenuCmd*(data: Info, opts: varargs[string], rofi: bool = false): string =
|
return text
|
||||||
|
|
||||||
|
proc genMenuCmd*(data: Info, opts: varargs[string], rofi: bool = false): string =
|
||||||
# Build dmenu/rofi command
|
# Build dmenu/rofi command
|
||||||
var cmd = ""
|
var cmd = ""
|
||||||
# if the text is empty, we don't want to create a menu item of it
|
# if the text is empty, we don't want to create a menu item of it
|
||||||
if data.full_text != "":
|
if data.full_text != "":
|
||||||
cmd &= data.full_text & "\n"
|
let text = markup(data.full_text)
|
||||||
|
cmd &= text & "\n"
|
||||||
for opt in opts:
|
for opt in opts:
|
||||||
cmd = cmd & opt & "\n"
|
let text = markup(opt)
|
||||||
|
cmd = cmd & text & "\n"
|
||||||
cmd.removeSuffix("\n")
|
cmd.removeSuffix("\n")
|
||||||
|
|
||||||
cmd = "echo -e" & quote(cmd) & " | "
|
cmd = "echo -e" & quote(cmd) & " | "
|
||||||
|
|
||||||
var dmenu = newDmenu()
|
var menu = newMenu()
|
||||||
cmd = cmd & dmenu.command & " "
|
cmd = cmd & menu.command & " "
|
||||||
cmd = cmd & dmenu.lines_shown & " " & $MAX_LINES & " "
|
cmd = cmd & menu.extra_cmd & " "
|
||||||
cmd = cmd & dmenu.prompt & quote(data.title)
|
cmd = cmd & menu.i_case & " "
|
||||||
cmd = cmd & dmenu.norm_bg & quote(data.unselected_bg)
|
cmd = cmd & menu.lines_shown & " " & $MAX_LINES & " "
|
||||||
cmd = cmd & dmenu.norm_fg & quote(data.unselected_fg)
|
cmd = cmd & menu.prompt & quote(data.title)
|
||||||
cmd = cmd & dmenu.sel_bg & quote(data.selected_bg)
|
cmd = cmd & menu.norm_bg & quote(data.unselected_bg)
|
||||||
cmd = cmd & dmenu.sel_fg & quote(data.selected_fg)
|
cmd = cmd & menu.norm_fg & quote(data.unselected_fg)
|
||||||
cmd = cmd & dmenu.font & quote(font)
|
cmd = cmd & menu.sel_bg & quote(data.selected_bg)
|
||||||
|
cmd = cmd & menu.sel_fg & quote(data.selected_fg)
|
||||||
|
cmd = cmd & menu.font & quote(font)
|
||||||
|
echo cmd
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
proc runDMenu*(data: Info, opts: varargs[string], rofi: bool = false): string =
|
proc runMenu*(data: Info, opts: varargs[string], rofi: bool = false): string =
|
||||||
let cmd = genDmenuCmd(data, opts, rofi)
|
let cmd = genMenuCmd(data, opts, rofi)
|
||||||
#echo cmd
|
#echo cmd
|
||||||
#
|
#
|
||||||
# Run command and get output
|
# Run command and get output
|
||||||
|
@ -188,7 +205,7 @@ proc copyToClipboard*(str: string) =
|
||||||
proc outputData*(data: Info, args: varargs[string]): string {.discardable.} =
|
proc outputData*(data: Info, args: varargs[string]): string {.discardable.} =
|
||||||
var output = ""
|
var output = ""
|
||||||
if rofi:
|
if rofi:
|
||||||
output = runDmenu(data,args, rofi = true)
|
output = runMenu(data,args, rofi = true)
|
||||||
elif loop:
|
elif loop:
|
||||||
# mainly for i3bar/i3blocks compatible output
|
# mainly for i3bar/i3blocks compatible output
|
||||||
var j_data = data
|
var j_data = data
|
||||||
|
@ -197,7 +214,7 @@ proc outputData*(data: Info, args: varargs[string]): string {.discardable.} =
|
||||||
echo $$j_data
|
echo $$j_data
|
||||||
else:
|
else:
|
||||||
# if all else fails, use dmenu (default)
|
# if all else fails, use dmenu (default)
|
||||||
output = runDmenu(data,args)
|
output = runMenu(data,args)
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import std/[strutils,osproc]
|
||||||
# Basically just a wrapper to style passmenu nicely
|
# Basically just a wrapper to style passmenu nicely
|
||||||
proc main() =
|
proc main() =
|
||||||
var info = newInfo(capitalizeAscii(run_command))
|
var info = newInfo(capitalizeAscii(run_command))
|
||||||
let cmd = genDmenuCmd(info)
|
let cmd = genMenuCmd(info)
|
||||||
discard execCmd(cmd)
|
discard execCmd(cmd)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
9
compile_all.sh
Normal file → Executable file
9
compile_all.sh
Normal file → Executable file
|
@ -2,6 +2,11 @@
|
||||||
|
|
||||||
dont_compile="./base.nim"
|
dont_compile="./base.nim"
|
||||||
req_ssl=("./translate.nim" "./tides.nim")
|
req_ssl=("./translate.nim" "./tides.nim")
|
||||||
|
dependencies=("configparser")
|
||||||
|
for d in "${dependencies[@]}"; do
|
||||||
|
nimble install $d -n
|
||||||
|
done
|
||||||
|
|
||||||
for f in ./*.nim; do
|
for f in ./*.nim; do
|
||||||
if [[ $f == $dont_compile ]]; then
|
if [[ $f == $dont_compile ]]; then
|
||||||
echo "Not compiling $f"
|
echo "Not compiling $f"
|
||||||
|
@ -12,7 +17,7 @@ for f in ./*.nim; do
|
||||||
do
|
do
|
||||||
if [[ $f == $i ]]; then
|
if [[ $f == $i ]]; then
|
||||||
echo "Compiling $f with SSL"
|
echo "Compiling $f with SSL"
|
||||||
nim c -d:ssl $f
|
nim c -d:ssl -d:release $f
|
||||||
compiled=1
|
compiled=1
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
@ -21,6 +26,6 @@ for f in ./*.nim; do
|
||||||
continue
|
continue
|
||||||
else
|
else
|
||||||
echo "Compiling $f"
|
echo "Compiling $f"
|
||||||
nim c $f
|
nim c -d:release $f
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
0
fuzzytime.nim
Normal file → Executable file
0
fuzzytime.nim
Normal file → Executable file
6
nic.nim
6
nic.nim
|
@ -51,9 +51,9 @@ proc getNetInfo*(my_nics: seq[string]) =
|
||||||
|
|
||||||
proc getNics*(): seq[string] =
|
proc getNics*(): seq[string] =
|
||||||
var my_nics: seq[string] = @[]
|
var my_nics: seq[string] = @[]
|
||||||
for nic in nics:
|
for nic in os.walkDir("/sys/class/net/"):
|
||||||
if dirExists("/sys/class/net/" & nic):
|
let n = replace(nic.path, "/sys/class/net/", "")
|
||||||
my_nics.add(nic)
|
my_nics.add(n)
|
||||||
|
|
||||||
if len(my_nics) > 0:
|
if len(my_nics) > 0:
|
||||||
return my_nics
|
return my_nics
|
||||||
|
|
|
@ -4,7 +4,7 @@ import std/osproc
|
||||||
# Basically just a wrapper to style passmenu nicely
|
# Basically just a wrapper to style passmenu nicely
|
||||||
proc main() =
|
proc main() =
|
||||||
var info = newInfo("Passmenu")
|
var info = newInfo("Passmenu")
|
||||||
let cmd = genDmenuCmd(info)
|
let cmd = genMenuCmd(info)
|
||||||
discard execCmd(cmd)
|
discard execCmd(cmd)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
0
screenshot.nim
Executable file → Normal file
0
screenshot.nim
Executable file → Normal file
0
volume.nim
Normal file → Executable file
0
volume.nim
Normal file → Executable file
Loading…
Add table
Reference in a new issue