65 lines
1.7 KiB
Nim
65 lines
1.7 KiB
Nim
|
import std/os
|
||
|
import std/times
|
||
|
import std/osproc
|
||
|
import i3bar_base
|
||
|
|
||
|
let args = getArguments()
|
||
|
|
||
|
proc getObject(date: string): i3barData =
|
||
|
let data = i3barData(
|
||
|
full_text: date,
|
||
|
color: foreground,
|
||
|
border: blue
|
||
|
)
|
||
|
return data
|
||
|
|
||
|
proc openCalendar() =
|
||
|
let cmd = "~/Nextcloud/Backups/Linux/dotFiles/scripts/popup-calendar.sh"
|
||
|
discard execCmd(cmd)
|
||
|
|
||
|
proc getDate() =
|
||
|
let now = now()
|
||
|
let d = now.format("yyyy-MM-dd")
|
||
|
let data = getObject(d)
|
||
|
outputJSON(data)
|
||
|
|
||
|
proc main() =
|
||
|
if len(args) == 0:
|
||
|
#while true:
|
||
|
getDate()
|
||
|
# sleep(5000)
|
||
|
else:
|
||
|
if args[0] == "1":
|
||
|
openCalendar()
|
||
|
getDate()
|
||
|
|
||
|
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
|
||
|
#fi
|
||
|
#eval "$(xdotool getmouselocation --shell)"
|
||
|
#eval "$(xdotool getdisplaygeometry --shell)"
|
||
|
## X
|
||
|
#if [ "$((X + YAD_WIDTH / 2 + BORDER_SIZE))" -gt "$WIDTH" ]; then #Right side
|
||
|
# : $((pos_x = WIDTH - YAD_WIDTH - BORDER_SIZE))
|
||
|
#elif [ "$((X - YAD_WIDTH / 2 - BORDER_SIZE))" -lt 0 ]; then #Left side
|
||
|
# : $((pos_x = BORDER_SIZE))
|
||
|
#else #Center
|
||
|
# : $((pos_x = X - YAD_WIDTH / 2))
|
||
|
#fi
|
||
|
## Y
|
||
|
#if [ "$Y" -gt "$((HEIGHT / 2))" ]; then #Bottom
|
||
|
# : $((pos_y = HEIGHT - YAD_HEIGHT - BAR_HEIGHT - BORDER_SIZE))
|
||
|
#else #Top
|
||
|
# : $((pos_y = BAR_HEIGHT + BORDER_SIZE))
|
||
|
#fi
|
||
|
#yad --calendar --undecorated --fixed --close-on-unfocus --no-buttons \
|
||
|
# --width="$YAD_WIDTH" --height="$YAD_HEIGHT" --posx="$pos_x" --posy="$pos_y" \
|
||
|
# --title="yad-calendar" --borders=0 >/dev/null &
|