added direct yad execute rather than script
This commit is contained in:
parent
bc5084df13
commit
117ba68d89
4 changed files with 53 additions and 17 deletions
14
debug.txt
Normal file
14
debug.txt
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
(full_text: "🌗 70%", short_text: "", color: "#dfdfdf", border: "#ffb52a")(full_text: "🌗 70%", short_text: "", color: "#dfdfdf", border: "#ffb52a")
|
||||||
|
5
|
||||||
|
(full_text: "🌗 65%", short_text: "", color: "#dfdfdf", border: "#ffb52a")
|
||||||
|
4
|
||||||
|
(full_text: "🌗 70%", short_text: "", color: "#dfdfdf", border: "#ffb52a")
|
||||||
|
5
|
||||||
|
(full_text: "🌗 65%", short_text: "", color: "#dfdfdf", border: "#ffb52a")
|
||||||
|
(full_text: "🌗 65%", short_text: "", color: "#dfdfdf", border: "#ffb52a")
|
||||||
|
(full_text: "🌗 65%", short_text: "", color: "#dfdfdf", border: "#ffb52a")
|
||||||
|
(full_text: "🌗 65%", short_text: "", color: "#dfdfdf", border: "#ffb52a")
|
||||||
|
|
||||||
|
|
||||||
|
5
|
||||||
|
4
|
|
@ -1,3 +1,6 @@
|
||||||
|
import std/os
|
||||||
|
import std/json
|
||||||
|
import std/rdstdin
|
||||||
import marshal
|
import marshal
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
@ -8,6 +11,10 @@ type
|
||||||
color*: string
|
color*: string
|
||||||
border*: string
|
border*: string
|
||||||
|
|
||||||
|
type
|
||||||
|
i3BarInput* = object
|
||||||
|
button*: int
|
||||||
|
|
||||||
const background* = "#000000"
|
const background* = "#000000"
|
||||||
const backgroundalt* = "#bb222222"
|
const backgroundalt* = "#bb222222"
|
||||||
const backgroundalt2* = "#bb333333"
|
const backgroundalt2* = "#bb333333"
|
||||||
|
@ -28,6 +35,21 @@ const primary* = yellow
|
||||||
const secondary* = red
|
const secondary* = red
|
||||||
const alert* = "#bd2c40"
|
const alert* = "#bd2c40"
|
||||||
|
|
||||||
|
proc debugLog*(str: string) =
|
||||||
|
let f = open("/tmp/debug.txt",fmAppend)
|
||||||
|
defer: f.close()
|
||||||
|
f.writeLine(str)
|
||||||
|
|
||||||
|
proc parseInput*(): i3BarInput =
|
||||||
|
let input = readLineFromStdin("")
|
||||||
|
debugLog($input)
|
||||||
|
try:
|
||||||
|
let jsonNode = parseJson(input)
|
||||||
|
let i3input = to(jsonNode, i3BarInput)
|
||||||
|
return i3input
|
||||||
|
except:
|
||||||
|
return i3BarInput()
|
||||||
|
|
||||||
proc getArguments*(): seq[string] =
|
proc getArguments*(): seq[string] =
|
||||||
let args = commandLineParams()
|
let args = commandLineParams()
|
||||||
return args
|
return args
|
||||||
|
|
|
@ -30,8 +30,6 @@ proc getDesign(pcnt: float): string =
|
||||||
let text = icon & " " & $percent & "%"
|
let text = icon & " " & $percent & "%"
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
proc getBrightness() =
|
proc getBrightness() =
|
||||||
let current = parseInt(strip(readFile("/sys/class/backlight/intel_backlight/actual_brightness")))
|
let current = parseInt(strip(readFile("/sys/class/backlight/intel_backlight/actual_brightness")))
|
||||||
let pcnt = (current/limit)*100
|
let pcnt = (current/limit)*100
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import std/os
|
import std/os
|
||||||
import std/times
|
import std/times
|
||||||
import std/osproc
|
import std/osproc
|
||||||
|
import std/re
|
||||||
import i3bar_base
|
import i3bar_base
|
||||||
|
|
||||||
let args = getArguments()
|
let args = getArguments()
|
||||||
|
@ -13,32 +14,33 @@ proc getObject(date: string): i3barData =
|
||||||
)
|
)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
proc openCalendar() =
|
proc openCalendar(datestr: string) =
|
||||||
let cmd = "~/Nextcloud/Backups/Linux/dotFiles/scripts/popup-calendar.sh"
|
var c = """yad --calendar \
|
||||||
discard execCmd(cmd)
|
--undecorated --fixed --close-on-unfocus --no-buttons \
|
||||||
|
--width="222" --height="193" \
|
||||||
|
--posx="1650" --posy="25" \
|
||||||
|
--title="yad-calendar" --borders 0 > /dev/null
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
discard execCmd(c)
|
||||||
|
|
||||||
proc getDate() =
|
proc getDate() =
|
||||||
let now = now()
|
let now = now()
|
||||||
let d = now.format("yyyy-MM-dd")
|
let d = now.format("yyyy-MM-dd")
|
||||||
let data = getObject(d)
|
let data = getObject(d)
|
||||||
outputJSON(data)
|
outputJSON(data)
|
||||||
|
if len(args) > 0 and args[0] == "1":
|
||||||
|
openCalendar(now.format("ddd dd HH:MM"))
|
||||||
|
|
||||||
proc main() =
|
proc main() =
|
||||||
if len(args) == 0:
|
getDate()
|
||||||
#while true:
|
#while true:
|
||||||
getDate()
|
# let input = parseInput()
|
||||||
# sleep(5000)
|
# if input.button == 1:
|
||||||
else:
|
|
||||||
if args[0] == "1":
|
|
||||||
openCalendar()
|
|
||||||
getDate()
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
||||||
#BAR_HEIGHT=28 # polybar height
|
|
||||||
#BORDER_SIZE=1 # border size from your wm settings
|
|
||||||
#YAD_WIDTH=222 # 222 is minimum possible value
|
|
||||||
#YAD_HEIGHT=193 # 193 is minimum possible value
|
|
||||||
#DATE="$(date +"%a %d %H:%M")"
|
#DATE="$(date +"%a %d %H:%M")"
|
||||||
#if [ "$(xdotool getwindowfocus getwindowname)" = "yad-calendar" ]; then
|
#if [ "$(xdotool getwindowfocus getwindowname)" = "yad-calendar" ]; then
|
||||||
# exit 0
|
# exit 0
|
||||||
|
|
Loading…
Reference in a new issue