started top add dmenu implementation
This commit is contained in:
parent
331844dfd8
commit
aabcfd98c7
9 changed files with 31 additions and 7 deletions
1
i3bar_base.nim
Executable file → Normal file
1
i3bar_base.nim
Executable file → Normal file
|
@ -60,6 +60,7 @@ proc parseInput*(): i3BarInput =
|
|||
return i3input
|
||||
except:
|
||||
return i3BarInput()
|
||||
|
||||
proc clearInput*(count: int = 1) =
|
||||
for x in countup(1, count):
|
||||
discard readLineFromStdin("")
|
||||
|
|
|
@ -75,7 +75,7 @@ proc get_output(charge: int, state: bool): i3barData =
|
|||
|
||||
|
||||
proc get_battery_info() =
|
||||
var last_charge = 0
|
||||
var last_charge = -1
|
||||
var last_state = false
|
||||
while true:
|
||||
let charge = get_charge()
|
||||
|
|
0
i3bar_brightness.nim
Executable file → Normal file
0
i3bar_brightness.nim
Executable file → Normal file
0
i3bar_date.nim
Executable file → Normal file
0
i3bar_date.nim
Executable file → Normal file
0
i3bar_fuzzytime.nim
Executable file → Normal file
0
i3bar_fuzzytime.nim
Executable file → Normal file
6
i3bar_nic.nim
Executable file → Normal file
6
i3bar_nic.nim
Executable file → Normal file
|
@ -6,8 +6,6 @@ import strutils
|
|||
|
||||
const nics: seq[string] = @["wlan0", "enp3s0","wlp2s0","enp0s20f0u3"]
|
||||
|
||||
# /sys/class/net/*/operstate up or down if connected
|
||||
|
||||
proc get_ip(nic: string): string =
|
||||
let cmd = "ifconfig " & nic & " | grep inet | awk -F\" \" '{print $2}' | head -1 | awk '{print $1}'"
|
||||
let ip = execCmdEx(cmd)
|
||||
|
@ -25,7 +23,7 @@ proc get_net(nic: string): (string, string) =
|
|||
return ("disconnected", state)
|
||||
return (ip, state)
|
||||
|
||||
proc getObject(conn: string): i3barData =
|
||||
proc getObject(conn: string, nic: string): i3barData =
|
||||
var data = newi3barData()
|
||||
data.full_text = conn
|
||||
data.border = purple
|
||||
|
@ -37,7 +35,7 @@ proc get_net_info(nic: string) =
|
|||
while true:
|
||||
let (ip, state) = get_net(nic)
|
||||
if ip != last_ip or state != last_state:
|
||||
let data = getObject(state & " " & ip)
|
||||
let data = getObject(state & " " & ip, nic)
|
||||
outputJSON(data)
|
||||
last_ip = ip
|
||||
last_state = state
|
||||
|
|
27
i3bar_pingclock.nim
Executable file → Normal file
27
i3bar_pingclock.nim
Executable file → Normal file
|
@ -49,16 +49,41 @@ proc getObject(ping: float): i3barData =
|
|||
)
|
||||
return data
|
||||
|
||||
proc runDMenu(data: i3BarData) =
|
||||
var cmd = "echo Ping Clock : " & $data.full_text & " | dmenu "
|
||||
cmd = cmd & " -nb \"" & $data.background & "\""
|
||||
cmd = cmd & " -nf \"" & $data.color & "\""
|
||||
cmd = cmd & " -sb \"" & $data.background & "\""
|
||||
cmd = cmd & " -sf \"" & $data.color & "\""
|
||||
discard execCmd(cmd)
|
||||
discard execCmd("i3-msg mode \"default\"")
|
||||
|
||||
|
||||
proc main() =
|
||||
let args = getArguments()
|
||||
var loop = true
|
||||
var stoploop = false
|
||||
var dmenu = false
|
||||
for arg in args:
|
||||
if arg == "noloop":
|
||||
stoploop = true
|
||||
if arg == "dmenu":
|
||||
stoploop = true
|
||||
dmenu = true
|
||||
|
||||
var last_ping: float = 0
|
||||
while true:
|
||||
while loop:
|
||||
let ping = get_ping()
|
||||
if ping != last_ping:
|
||||
let data = getObject(ping)
|
||||
outputJSON(data)
|
||||
last_ping = ping
|
||||
if dmenu:
|
||||
runDMenu(data)
|
||||
|
||||
loop = not stoploop
|
||||
if loop:
|
||||
sleep(time_secs * 1000)
|
||||
|
||||
|
||||
main()
|
||||
|
|
0
i3bar_temperature.nim
Executable file → Normal file
0
i3bar_temperature.nim
Executable file → Normal file
0
i3bar_volume.nim
Executable file → Normal file
0
i3bar_volume.nim
Executable file → Normal file
Loading…
Reference in a new issue