Browse Source

tcalendar: simple calendar for polybar

master
Maxim Likhachev 4 years ago
parent
commit
f5372439be
  1. 1
      README.md
  2. 74
      scripts/tcalendar

1
README.md

@ -65,6 +65,7 @@ will create the symbolic link for each script in the \<path> directory. @@ -65,6 +65,7 @@ will create the symbolic link for each script in the \<path> 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

74
scripts/tcalendar

@ -0,0 +1,74 @@ @@ -0,0 +1,74 @@
#!/usr/bin/env tclsh
# Copyright (C) 2021, Maxim Lihachev, <envrm@yandex.ru>
#
# 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 <https://www.gnu.org/licenses/>.
#
# 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 . <KeyPress-Control_L><KeyPress-q> exit
bind . <KeyPress-Control_R><KeyPress-q> exit
bind . <KeyPress-q> exit
bind . <Escape> 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
}
Loading…
Cancel
Save