import base import std/[os,times,osproc,re] const default_bg = blue const default_fg = white const default_format = "yyyy-MM-dd" const cal_pos_x = "20" const cal_pos_y = "20" proc getObject(date: string): Info = var data = newInfo("Date") data.full_text = date data.border = default_bg data.selected_bg = default_bg data.selected_fg = default_fg return data proc newCalendar(): string = var c = """yad --calendar \ --undecorated --fixed --close-on-unfocus --no-buttons \ --width="222" --height="193" \ --posx="%pos_x" --posy="%pos_y" \ --title="yad-calendar" --borders 0 > /dev/null """ return c proc openCalendar*(input: i3barInput) = var c = newCalendar() c = replace(c,re"%pos_x", $(input.x - 111)) c = replace(c,re"%pos_y", $input.y) discard execCmd(c) proc dmenuCalendar() = var c = newCalendar() c = replace(c,re"%pos_x", cal_pos_x) c = replace(c,re"%pos_y", cal_pos_y) discard execCmd(c) proc getDate*() = let date_today = times.now().format(default_format) let data = getObject(date_today) let output = outputData(data) if output == date_today: dmenuCalendar() proc main() = getDate() if isMainModule: main()