more dmenu updates
This commit is contained in:
parent
aabcfd98c7
commit
31f2b20d03
3 changed files with 48 additions and 27 deletions
|
@ -1,10 +1,11 @@
|
||||||
import std/os
|
import std/[os,osproc]
|
||||||
import std/json
|
import std/json
|
||||||
import std/rdstdin
|
import std/rdstdin
|
||||||
import marshal
|
import marshal
|
||||||
|
|
||||||
type
|
type
|
||||||
i3BarData* = object
|
i3BarData* = object
|
||||||
|
title*: string
|
||||||
full_text*: string
|
full_text*: string
|
||||||
short_text*: string
|
short_text*: string
|
||||||
color*: string
|
color*: string
|
||||||
|
@ -38,9 +39,13 @@ const darkgrey* = "#444"
|
||||||
const primary* = yellow
|
const primary* = yellow
|
||||||
const secondary* = red
|
const secondary* = red
|
||||||
const alert* = "#bd2c40"
|
const alert* = "#bd2c40"
|
||||||
|
var loop* = true
|
||||||
|
var stoploop* = false
|
||||||
|
var dmenu* = false
|
||||||
|
|
||||||
proc newi3BarData*(): i3BarData =
|
proc newi3BarData*(): i3BarData =
|
||||||
return i3BarData(
|
return i3BarData(
|
||||||
|
title: "Info : ",
|
||||||
full_text: "",
|
full_text: "",
|
||||||
short_text: "",
|
short_text: "",
|
||||||
color: foreground,
|
color: foreground,
|
||||||
|
@ -72,3 +77,23 @@ proc getArguments*(): seq[string] =
|
||||||
proc outputJSON*(data: i3barData) =
|
proc outputJSON*(data: i3barData) =
|
||||||
echo $$data
|
echo $$data
|
||||||
|
|
||||||
|
proc runDMenu*(data: i3BarData) =
|
||||||
|
var cmd = "echo " & $data.full_text & " | dmenu "
|
||||||
|
#cmd = cmd & " -l 2 "
|
||||||
|
cmd = cmd & " -p \"" & $data.title & "\""
|
||||||
|
cmd = cmd & " -nb \"" & $data.background & "\""
|
||||||
|
cmd = cmd & " -nf \"" & $data.color & "\""
|
||||||
|
cmd = cmd & " -sb \"" & $data.border & "\""
|
||||||
|
cmd = cmd & " -sf \"" & $data.color & "\""
|
||||||
|
discard execCmd(cmd)
|
||||||
|
discard execCmd("i3-msg mode \"default\"")
|
||||||
|
|
||||||
|
let args = getArguments()
|
||||||
|
for arg in args:
|
||||||
|
if arg == "noloop":
|
||||||
|
stoploop = true
|
||||||
|
if arg == "dmenu":
|
||||||
|
stoploop = true
|
||||||
|
dmenu = true
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,7 @@ proc get_minute(min: int): string =
|
||||||
|
|
||||||
proc getObject(time: string): i3barData =
|
proc getObject(time: string): i3barData =
|
||||||
var data = newi3barData()
|
var data = newi3barData()
|
||||||
|
data.title = "Fuzzy Time :"
|
||||||
data.full_text = time
|
data.full_text = time
|
||||||
#data.color = foreground
|
#data.color = foreground
|
||||||
data.border = lightblue
|
data.border = lightblue
|
||||||
|
@ -84,6 +85,9 @@ proc main() =
|
||||||
let time = get_fuzzytime()
|
let time = get_fuzzytime()
|
||||||
if time != last_time:
|
if time != last_time:
|
||||||
let data = getObject(time)
|
let data = getObject(time)
|
||||||
|
if dmenu:
|
||||||
|
runDMenu(data)
|
||||||
|
break
|
||||||
outputJSON(data)
|
outputJSON(data)
|
||||||
last_time = time
|
last_time = time
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ proc getObject(ping: float): i3barData =
|
||||||
col = red
|
col = red
|
||||||
|
|
||||||
let data = i3barData(
|
let data = i3barData(
|
||||||
|
title: "Ping Clock:",
|
||||||
full_text: text,
|
full_text: text,
|
||||||
color: col,
|
color: col,
|
||||||
border: blue,
|
border: blue,
|
||||||
|
@ -50,40 +51,31 @@ proc getObject(ping: float): i3barData =
|
||||||
return data
|
return data
|
||||||
|
|
||||||
proc runDMenu(data: i3BarData) =
|
proc runDMenu(data: i3BarData) =
|
||||||
var cmd = "echo Ping Clock : " & $data.full_text & " | dmenu "
|
var cmd = "echo " & $data.full_text & " | dmenu "
|
||||||
|
#cmd = cmd & " -l 2 "
|
||||||
|
cmd = cmd & " -p \"Ping Clock : \""
|
||||||
cmd = cmd & " -nb \"" & $data.background & "\""
|
cmd = cmd & " -nb \"" & $data.background & "\""
|
||||||
cmd = cmd & " -nf \"" & $data.color & "\""
|
cmd = cmd & " -nf \"" & $data.color & "\""
|
||||||
cmd = cmd & " -sb \"" & $data.background & "\""
|
cmd = cmd & " -sb \"" & $data.border & "\""
|
||||||
cmd = cmd & " -sf \"" & $data.color & "\""
|
cmd = cmd & " -sf \"" & $data.color & "\""
|
||||||
discard execCmd(cmd)
|
discard execCmd(cmd)
|
||||||
discard execCmd("i3-msg mode \"default\"")
|
discard execCmd("i3-msg mode \"default\"")
|
||||||
|
|
||||||
|
|
||||||
proc main() =
|
proc main() =
|
||||||
let args = getArguments()
|
var last_ping: float = 0
|
||||||
var loop = true
|
while loop:
|
||||||
var stoploop = false
|
let ping = get_ping()
|
||||||
var dmenu = false
|
if ping != last_ping:
|
||||||
for arg in args:
|
let data = getObject(ping)
|
||||||
if arg == "noloop":
|
if dmenu:
|
||||||
stoploop = true
|
runDMenu(data)
|
||||||
if arg == "dmenu":
|
else:
|
||||||
stoploop = true
|
outputJSON(data)
|
||||||
dmenu = true
|
last_ping = ping
|
||||||
|
loop = not stoploop
|
||||||
var last_ping: float = 0
|
if loop:
|
||||||
while loop:
|
sleep(time_secs * 1000)
|
||||||
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()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue