added direct yad execute rather than script

This commit is contained in:
Paul Wilde 2022-02-06 22:07:32 +00:00
parent bc5084df13
commit 117ba68d89
4 changed files with 53 additions and 17 deletions

14
debug.txt Normal file
View 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

View file

@ -1,3 +1,6 @@
import std/os
import std/json
import std/rdstdin
import marshal
import argparse
@ -8,6 +11,10 @@ type
color*: string
border*: string
type
i3BarInput* = object
button*: int
const background* = "#000000"
const backgroundalt* = "#bb222222"
const backgroundalt2* = "#bb333333"
@ -28,6 +35,21 @@ const primary* = yellow
const secondary* = red
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] =
let args = commandLineParams()
return args

View file

@ -30,8 +30,6 @@ proc getDesign(pcnt: float): string =
let text = icon & " " & $percent & "%"
return text
proc getBrightness() =
let current = parseInt(strip(readFile("/sys/class/backlight/intel_backlight/actual_brightness")))
let pcnt = (current/limit)*100

View file

@ -1,6 +1,7 @@
import std/os
import std/times
import std/osproc
import std/re
import i3bar_base
let args = getArguments()
@ -13,32 +14,33 @@ proc getObject(date: string): i3barData =
)
return data
proc openCalendar() =
let cmd = "~/Nextcloud/Backups/Linux/dotFiles/scripts/popup-calendar.sh"
discard execCmd(cmd)
proc openCalendar(datestr: string) =
var c = """yad --calendar \
--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() =
let now = now()
let d = now.format("yyyy-MM-dd")
let data = getObject(d)
outputJSON(data)
if len(args) > 0 and args[0] == "1":
openCalendar(now.format("ddd dd HH:MM"))
proc main() =
if len(args) == 0:
#while true:
getDate()
# sleep(5000)
else:
if args[0] == "1":
openCalendar()
getDate()
getDate()
#while true:
# let input = parseInput()
# if input.button == 1:
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")"
#if [ "$(xdotool getwindowfocus getwindowname)" = "yad-calendar" ]; then
# exit 0