Module
A simple calendar made with rofi and python3.
Cycle through month and create linked event to days.
- naivecalendar.get_arguments()
Parse command line arguments
- Returns
args (argparse.Namespace) – command line arguments
unknown (str) – rofi output
- naivecalendar.strip_list(lst)
strip all element in a list
- naivecalendar.to_list(cfg_list)
convert string with comma separated elements into python list
- naivecalendar.set_list(default, section, key, row)
set, set default or desactivate given user config
- naivecalendar.to_int(section, key)
Convert a configparser entry into an int
- naivecalendar.to_path(path_str, parent=PosixPath('/root'))
make path relative to home or absolute
- naivecalendar.set_locale_n_week_day_names(arg_locale, user_locale, day_format, first_day_week, day_abbr_lenght)
Set SYMS_WEEK_DAYS constante given command line argument
- naivecalendar.main(args, rofi_output)
Print calendar to stdout and react to rofi output
- naivecalendar.set_date(cdate, is_first_loop, is_force_read_cache, arg_date)
set date given context
(read cache, get today date or set date argument)
- Parameters
is_first_loop (bool) – true on first calendar call
is_force_read_cache (bool) – force date from cache
arg_date (str) – date in ‘%m%Y’ format
- Returns
CacheDate object that contain the date to display
- Return type
- naivecalendar.process_event_date(cdate, out, args)
React to rofi output for “date” events
- naivecalendar.process_event_popup(out, cdate)
React to rofi event hat open a popup window
- Parameters
out (str) – rofi output
cdate (CacheDate) – current month
- naivecalendar.update_rofi(date, is_first_loop)
generate and send calendar data to stdout/rofi
It use the rofi custom script mode to communicate with rofi and pango markup for theming
- Parameters
date (datetime.date) – A day of the month to display
is_first_loop (bool) – True on first loop, if true, update today highlights
- naivecalendar.get_calendar_from_date(date)
Return a montly calendar given date
Calendar is a string formated to be shown by rofi (i.e. column bu column):
L M M J V S D 1 2 3 4 5 6 7 8 date -> 9 10 11 12 13 14 15 -> 'L\n \n2\n9\n16\n23\n30\n<\nM\n \n3\n10\n17\n24\n...' 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
- Parameters
date (datetime.date) – Any day of the month to display
- Returns
A str that contain chained columns of a calendar in a rofi format
- Return type
str
- naivecalendar.list_transpose(lst, col_nb=7)
Transpose (math) a row by row list into column by column list given column number
- Parameters
lst (list) – row by row elements
col_nb (int) – number of column to display
- Returns
A list that represent column by column elements
- Return type
list
Examples
>>> my_list = [1,2,3,4,5,6] >>> list_transpose(my_list, col_nb=3) [1,4,2,5,3,6]
- naivecalendar.list2rofi(datas)
Convert python list into a list formatted for rofi
- Parameters
datas (list) – elements stored in a list
- Returns
elements separated by line-breaks
- Return type
str
Examples
>>> my_list = [1,2,3,4,5,6] >>> list2rofi(my_list] "1\n2\n3\n4\n5\n6"
- naivecalendar.rofi2list(datas)
Convert list formatted for rofi into python list object
- Parameters
datas (str) – a string with element separeted by line-breaks
- Returns
elements of datas in a list
- Return type
list
Examples
>>> rofi_list = "1\n2\n3\n4\n5\n6" >>> rofi2list [1,2,3,4,5,6]
- naivecalendar.parse_month_events_files(date)
Return a list of file’s first line of a specific month
- Parameters
date (datetime.date) – Any day of the month to display
- Returns
str – A rofi formatted list of month’s events first line
str – Rows to highlight (date header)
- naivecalendar.parse_event_file(event_path)
Parse event file for compact display
Event format:
Section
[9H30] rdv with truc <---- will be displayed Some text Some text again [14H30] rdv with muche <----- will be displayed Some text again again
header
# Note Title <---- only first line is displayed Some text Some text again...
- Parameters
event_path (str) – A text file path
- Returns
Parsed lines
- Return type
str
- naivecalendar.get_row_rofi_inds(row)
Get all rofi index of a row
- Parameters
row (int) – row number (start at 0)
- Returns
a ‘,’ separate list of rofi indexes
- Return type
str
- naivecalendar.cal2rofi_ind(day, month, year)
Convert calendar date into coordinates for rofi
- Parameters
day (int) – A day number (1-31)
month (int) – A month number (1-12)
year (int) – A year number
- Returns
A rofi index
- Return type
int
- naivecalendar.get_month_events(date)
Return events files paths that are attached to date’s month
- Parameters
date (datetime.date) – Any day of the month displayed
- Returns
list of files that belong to date.month
- Return type
list
- naivecalendar.get_month_events_ind(date)
Return rofi-formatted index of days with attached event
- Parameters
date (datetime.date) – Any day of the month displayed
- Returns
Column index list formatted for rofi
- Return type
str
- naivecalendar.open_n_reload_rofi(func)
decorator to open and reload the rofi script at the same date
- naivecalendar.show_events(date)
open rofi popup with events list of selected month
- Parameters
date (datetime.date) – current month
open popup menu
(list <theme>.cfg SHORTCUTS section entries)
- naivecalendar.open_event(day_sym, date, editor)
open event with editor for the selected date
- naivecalendar.edit_event_file(event_path, editor='xdg-open')
open event file with text editor
- naivecalendar.ask_event_to_display()
Popup that show all events type
- naivecalendar.ask_theme()
Search themes in paths and open a popup
- naivecalendar.execute_external_cmd(cmd)
Execute an external system command try to find command in different directories:
in $HOME/.config/naivecalendar/scripts/, then in
in ./scripts/, then
in system path
- naivecalendar.set_pp_date(day, date, f)
write date to cache with command line specified format
- naivecalendar.send2clipboard(day, date, f)
return select date to stdout given cmd line parameter ‘–format’
- naivecalendar.first_time_init()
Create config files and paths given script head variables
- class naivecalendar.CacheDate
Class to store date Make easier reading and writing to date cache file Make easier operation on date
- now()
Set and return today date
- set_month(month)
Set and return date of the given Month
- Parameters
month (str) – month to set in ‘%m-%Y’ format
- Returns
a day of the month
- Return type
datetime.date
- read_cache()
load cache ini file
- write_cache()
write date to ini cache file
- class naivecalendar.Year(outer)
Make computation on date years
- class naivecalendar.Month(outer)
Make computation on date months
- naivecalendar.joke(sym)
Just display stupid jokes in french
- naivecalendar.set_theme_cache(selected)
Write theme name to cache file
- naivecalendar.set_event_cache(selected)
Write theme name to cache file
- naivecalendar.rofi_popup(txt_head, txt_body, nb_lines=15, nb_col=1, width='40%', highlights=1000)
Launch a rofi window
- Parameters
txt_body (str) – Text to display in rofi window
txt_head (str) – Text to display in rofi prompt
- Returns
Rofi selected cell content
- Return type
str
- naivecalendar.display_help(head_txt='help:')
Show a rofi popup with help message