Skip to content

Daguhh/naivecalendar

Repository files navigation

NaïveCalendar

A popup calendar with rofi and python3

readme_fr git_badge doc sphinx deb package

naïf, naïve n. adj.

1. LITTERAIRE Qui est naturel, sans artifice, spontané. Art naïf, art populaire, folklorique. — Un peintre naïf.

2. COURANT Qui est plein de confiance et de simplicité par ignorance, par inexpérience. ➙ candide, ingénu, simple. — Qui exprime des choses simples que tout le monde sait. Remarque naïve. ➙ simpliste.

LeRobert

classic dark extended classic light extended

see all themes

  • Interactive : Cycle through calendar months by months, years by years.
  • Locale support : Automatic or force desired one
  • Events : Create notes linked to days, create multiple notes types, switch between them, (link to other app?), display your caldav events
  • Customize : change themes, content, symbols, shortcuts with text files, switch on the fly
  • Integrate : use it in your scripts and make them more interactive: open on a particular date, request a date, copy-to-clipboard.

Author note

This script/programm/app/whatever you call it, is a spare time and learning purpose project, nevertheless I hope you will find it useful. I intended this rofi diversion to be used with my polybar/i3 installation.

Although it's seems working fine to me, there might be still some (ok, there are) bugs, so feel free to open an issue for any comment or consideration.


Requirements

Recommends

  • xclip (copy to clipboard option)
  • sensible-utils (choose editor in update subcommand)
  • python3-caldav (show caldav events in calendar (very light support))

Suggests

  • fontawesome (for icons)

Manually

The naivecalendar use two files:

  • naivecalendar.py : that print a list-formatted calendar entries to sdtout
  • naivecalendar.sh : that run rofi in script mode with the previous file

Plus, a couple of theme files:

  • <theme>.rasi : rofi configuration file (shape and colors)
  • common/<element>.rasi : rasi theme file dependancies (combine shape, colors position...)
  • /themes/<theme>.cfg : an ini file that define calendar content

Simply copy those files (src folder content) in the same place (.ie : keep the tree as it is), remove as many theme as you want, but please keep at least classic_dark_extended default theme.

Here is the simplest doable installation tree

.
├── naivecalendar.py
├── naivecalendar.sh
└── themes
    ├── classic_dark_extended.cfg
    ├── classic_dark_extended.rasi
    └── common
        ├── position.rasi
        ├── shape_base.rasi
        ├── shape_extended.rasi
        ├── theme_base.rasi
        └── theme_dark.rasi

Then, Launch with:

./naivecalendar.sh

Package (debian)

apt install ./naivecalendar_x.y.z_all.deb

Launch with:

naivecalendar

Makefile

Edit Makefile.config to customize your installation, then run:

make install

Get more info :

make help

Launch with:

naivecalendar

Basic

Simply execute the script, then, Use mouse or keyboard to interact with the calendar:

  • Hit arrows to cycle through months or years
  • Hit a day to create a linked event. (day change color as it has a linked event)
  • Hit menu button to switch theme, switch event type, show month events

Shortcuts

Shortcuts have to be entered in the rofi command prompt. Those are default shortcuts, it can vary along themes and can be modified in <theme>.cfg files. Sym is the symbol displayed, you can type either Sym or Keys to execute an action

Sym Keys Action
         
◀◀ << pp -- go to previous year
< p - go to previous month
> n + go to next month
▶▶ >> nn ++ go to next year
event ee   display events of the month (first line)
switch ss   switch event type (open another folder)
help hh   display this help
theme tt   display theme selector
menu mm   display menu

Events

Events are simply files (usally text files) created by the calendar when you interact with a day (click/return key) On interaction, your default editor will open the event file. (see Customize/Events section for formatting advices) On editor closing, calendar will reopen and the day with a linked note will appear colored.

A script in avaible in calendar menu to show event from online calendar - using caldav -, that's a very light support, you can only show events on calendar (day, time, description, location), but you won't be able to sync or push new event to it. (see scripts/caldav2file.py file for details)

Options

Some command line options are avaible and can be useful if you want to integrate the naivecalendar in a script or temporarily override parameters. Subcommands update-themes could be useful to update all theme config at once instead of doing it manually (use completion).

usage: naivecalendar [-h] [-V] [-v] [-p] [-x] [-f FORMAT] [-e EDITOR] [-l LOCALE] [-c] [-t THEME] [-d DATE]

A simple popup calendar

subcommands:
update-themes Update a calendar parameter for all user themes at once
add-event Add or delete event
configure Clone or open configuration files
optional arguments:
-h, --help show this help message and exit
-V, --version show program's version number and exit
-v, --verbose direct rofi command errors to stdout
-p, --print print date to stdout instead of opening a event
-x, --clipboard
 copy date to clipboard
-f FORMAT, --format FORMAT
 option '-p' or '-x' output format (datetime.strftime format, defaut='%Y-%m-%d')
-e EDITOR, --editor EDITOR
 editor command to open events
-l LOCALE, --locale LOCALE
 force system locale, for example '-l es_ES.utf8'
-c, --read-cache
 force calendar to read old date from cache
-t THEME, --theme THEME
 set calendar theme, default=classic_dark (theme file name without extention)
-d DATE, --date DATE
 display calendar at the given month, format='%m-%Y'

To customize the calendar (without altering installation files), you can start with a copy of them in the user config folder:

Manually :

# Themes
cp -r /usr/share/naivecalendar/themes/* ~/.config/naivecalendar/themes/

# Events
cp -r /usr/share/naivecalendar/global/events.cfg  ~/.config/naivecalendar/global/events.cfg

# Scripts
cp -r /usr/share/naivecalendar/global/custom_actions.cfg  ~/.config/naivecalendar/global/custom_actions.cfg
cp -r /usr/share/naivecalendar/scripts/*  ~/.config/naivecalendar/scripts/

With subcommand:

naivecalendar configure --clone <config file>

Themes

A theme consist of two files :

  • `theme.cfg`_ : an ini file, configure calendar content
  • `theme.rasi`_ : a rofi theme file, configure apperance (color, size, layout...)

Warning

Number of rows in rofi (.rasi) should match content configuration (.cfg)! See more details in .cfg files.

Some themes are avaibles, set them by typing theme in rofi prompt or temporarily load them with --theme argument. To create your own theme, create a rasi file and a cfg file in ~/.config/naivecalendar/themes.

You can start from a copy of "officials" themes, with configure subcommand or manually:

cp -r /usr/share/naivecalendar/themes/* ~/.config/naivecalendar/themes/

Note

If it exist two themes with the same name in differents folders, the one in $HOME/.config/... will be prevalent over the others

Then modify themes one by one with your favourite editor or use naivecalendar subcommand to update multiples themes at once (cfg files only)

naivecalendar update-themes -h

Author

Proposed themes are more examples than official. I intented this calendar to easily match all user configurations and to be easily configurable. There is no specific tool to update .rasi files, but they (almost all) share some ressources in themes/common/, commonly:

  • a color theme : theme_<color_name>.rasi
  • a position on the screen : position.rasi
  • a shape (contain number of row) : shape_<kind>.rasi

So you can easily mix them to customize calendar aspect or modify independently colors and shapes.

Events

Events files names should contain strftime directives (%d, %m ...) to appear in the calendar.

note_%Y-%m-%d.txt

Not giving it a year directive will make it occur every year (usefull for birthday isn't it?)

birthday_on_%d-%m.txt

The calendar handle multiple events types (that are simply differents folders), you can define new event type by adding an entry in [EVENTS] section in .config/naivecalendar/global/event.cfg. Paths are relative to user's home.

[EVENTS]

Notes = .naivecalendar_events/MyNotes/note_%Y-%m-%d.txt
Birthday = .naivecalendar_events/Birthdays/birthday_on_%d-%m.txt

Notes support a very light format to be parsed when displaying "events of the month" :

  • show section : if you create sections (format : [section]) all lines containing a section will be displayed

    [9H30 -> 10H] short description <---- will be displayed
    Long
    multilines
    description...
    [14H30] rdv with bidulle <----- will be displayed
    Some text again again
  • show header : if the event/note don't contain section, only first line will be displayed

    # Note Title  <---- only first line is displayed
    Some text
    Some text again...

if you interact with the event file name, it will open the note again, other rows will bring you back to calendar

notes_2021-01-05 : <---- reopen editor
[9H30 -> 10H] short description  <--- do nothing : back to calendar
[14H30] rdv with bidulle

Custom actions

User can also create is own custom action i.e. create a button that launch user's script. To add a custom action please, put your script in ~/.config/naivecalendar/script/, then, edit ~/.config/naivecalendar/global/custom_actions.cfg to configure the button/shortcut:

[Shortcut Name] <--- used as id for other conf file
SYM = Icon, [shortcut_1, shortcut_2], long description   <--- Icon : displayed on calendar
CMD = path/to/script <--- script or system command            long description : displayed in menu

Here is a brief description of files needed/generated by the naivecalendar

Function File
Minimal : required
rofi command /usr/share/naivecalendar/naivecalendar.sh
script called by rofi /usr/share/naivecalendar/naivecalendar.py
rofi theme files /usr/share/naivecalendar/themes/*.rasi
calendar content configuration /usr/share/naivecalendar/themes/*.cfg
Installation & optional
system command /usr/bin/naivecalendar
theme config editor command /usr/share/naivecalendar/tools/naivecalendar-update-themes
theme event editor command /usr/share/naivecalendar/tools/naivecalendar-add-event
manage config files command /usr/share/naivecalendar/tools/naivecalendar-configure
custom actions /usr/share/naivecalendar/global/custom_actions.cfg
scripts /usr/share/naivecalendar/scripts/*"
events conf /usr/share/naivecalendar/global/events.cfg
User themes : optional (overide installation conf file)
user theme files ~/.config/naivecalendar/themes/*.rasi
user content configuration ~/.config/naivecalendar/themes/*.cfg
user custom actions ~/.config/naivecalendar/global/custom_actions.cfg
user events conf ~/.config/naivecalendar/global/events.cfg
user scripts ~/.config/naivecalendar/scripts/*"
Event : editable
day notes path (default) ~/.naivecalendar_events/<event type>/<date format>.txt
Generated : cache
remember date throught loops ~/.cache/naivecalendar/date_cache.ini
pass date to bash when -p option ~/.cache/naivecalendar/pretty_print_cache.txt
remember theme after quitting ~/.cache/naivecalendar/theme_cache.txt
remember event type ~/.cache/naivecalendar/event_cache.txt
last rofi command log file ~/.cache/naivecalendar/rofi_log.txt

Note

You can use the makefile with make command to build package and documentation.

Build debian package

sudo apt install devscripts
cd naivecalendar-x.y.z/
debuild -us -uc

Note

You can personnalize your themes before building, all themes folder content will be included in the package

Build the doc

cd docs/
python3 -m pip install -r requirements.txt
make html