From f5372439be077d9dd6f27f3490370c93a51810a3 Mon Sep 17 00:00:00 2001 From: Maxim Likhachev Date: Wed, 11 Aug 2021 15:07:54 +0300 Subject: [PATCH] tcalendar: simple calendar for polybar --- README.md | 1 + scripts/tcalendar | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100755 scripts/tcalendar diff --git a/README.md b/README.md index 7dfcce1..d940909 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ will create the symbolic link for each script in the \ directory. - [dates](scripts/dates) + conky or similar software remind of upcoming events (birthdays, etc.). - [mem](scripts/mem) stores the shorts notes in the file. - [pomodoro](scripts/pomodoro) tracks the working time. +- [tcalendar](scripts/tcalendar) shows a simple calendar widget. - [todo-bingo](scripts/todo-bingo) provides a simple GUI to visualize TODO lists. ## Network diff --git a/scripts/tcalendar b/scripts/tcalendar new file mode 100755 index 0000000..a22b620 --- /dev/null +++ b/scripts/tcalendar @@ -0,0 +1,74 @@ +#!/usr/bin/env tclsh + +# Copyright (C) 2021, Maxim Lihachev, +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the Free +# Software Foundation, version 3. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program. If not, see . + +# +# Simple pop-up calendar widget. +# +# NB: Window geometry is hardcoded. +# + +package require Tk +package require widget +package require widget::calendar + +proc showCalendar {} { + wm title . "TCalendar" + set t [widget::calendar .t -font "Helvetica 13" -dateformat "%Y-%m-%d" -language ru] + + set w 321 + set h 185 + + set x [ expr {([winfo vrootwidth .] - $w)}] + set y 21 + + wm geometry . ${w}x${h}+${x}+${y} + + pack $t -fill x -expand 1 + + bind . exit + bind . exit + bind . exit + bind . exit +} + +# Close calendar if exists. +proc closeCalendar {} { + set cmd [file tail $::argv0] + + # user 23192 30619 0 14:45 pts/8 00:00:00 tclsh tcalendar + lassign [exec ps -ef | grep -E "\[t\]clsh.*$cmd"] uid pid ppid c stime tty time cmd + + puts [pid] + + puts $pid + puts "$pid != {} || $pid != [pid]" + + if {$pid != {} && $pid != [pid]} { + exec kill $pid + return 0 + } else { + return 1 + } +} + +set newCalendar [closeCalendar] + +if {$newCalendar} { + showCalendar +} else { + exit +} +