Mese: Gennaio 2022

A Calendar Notification module…

#! /bin/bash

send_notification() {
	TODAY=$(date '+%-d')
	HEAD=$(cal "$1" | head -n1)
	BODY=$(cal "$1" | tail -n7 | sed -z "s|$TODAY|<u><b>$TODAY</b></u>|1")
	FOOT="\n<i>       ~ calendar</i> B. Raucci"
	dunstify -h string:x-canonical-private-synchronous:calendar \
		"$HEAD" "$BODY$FOOT" -u NORMAL
}

handle_action() {
	echo "$DIFF" > "$TMP"
	if [ "$DIFF" -ge 0 ]; then
		send_notification "+$DIFF months"
	else
		send_notification "$((-DIFF)) months ago"
	fi
}

TMP=${XDG_RUNTIME_DIR:-/tmp}/"$UID"_calendar_notification_month
touch "$TMP"

DIFF=$(<"$TMP")

case $1 in
	"curr") DIFF=0;;
	"next") DIFF=$((DIFF+1));;
	"prev") DIFF=$((DIFF-1));;
esac

handle_action

The calendar script is responsible for handling mouse events triggered by your bar, following are valid arguments:

./calendar curr # current month
./calendar next # increment month
./calendar prev # decrement month

Copy calendar to your polybar config directory. Then, in your polybar config, you can use click-left, scroll-up and scroll-down actions to invoke the script. For example:

[module/calendar]
type = custom/script
label = " "
exec = echo Calendar
click-left = ~/.config/polybar/calendar curr
scroll-up = ~/.config/polybar/calendar next
scroll-down = ~/.config/polybar/calendar prev

C=64…

Era il 10 gennaio del 1982 e il Commodore 64 veniva presentato, per la prima volta, al Consumer Electronics Show di Las Vegas…

How I draw figures for my mathematical lecture notes using Inkscape

Just like TikZ, Inkscape has the op­tion to ren­der the text of a fig­ure using LaTeX. For this, it ex­ports fig­ures as both a pdf and a LaTeX file. The pdf doc­u­ment con­tains the fig­ure with text stripped, and the LaTeX file con­tains the code need­ed to place the text at the cor­rect po­si­tion. For ex­am­ple, sup­pose you’re work­ing on the fol­low­ing fig­ure in Inkscape:

To in­clude this fig­ure in a LaTeX doc­u­ment, you’d go to File › Save As, se­lect ‘pdf’ as the ex­ten­sion and then press Save which makes the fol­low­ing di­a­log pop up:

Choos­ing ‘Omit text in pdf and cre­ate LaTeX file’, will save the fig­ure as pdf+LaTeX. To in­clude these Inkscape fig­ures in your LaTeX doc­u­ment, you can add the fol­low­ing code to your pre­am­ble:

\documentclass[11pt,a4paper]{scrbook}
\usepackage{import}
\usepackage{graphicx}
\usepackage{siunitx}
\usepackage{import}
\usepackage{placeins}
\usepackage{graphicx}
\usepackage[labelfont=bf]{caption}
\usepackage{subcaption}
\usepackage{enumitem}
\usepackage{calc}
\begin{document}
 
\chapter{Introduction}

As­sum­ing the fig­ure is lo­cat­ed at figure/disegno.svg, it can sim­ply be in­clud­ed with fol­low­ing code:

\begin{figure}[hbt!]
 \centering
 \begin{normalsize} 
  \def\svgscale{0.5}
  \import{figure/}{disegno.pdf_tex}
 \end{normalsize}
 \caption{Test}
 \label{fig:test}
\end{figure}

Com­pil­ing your doc­u­ment, you’d get the fol­low­ing.

As you can see, the text is ren­dered by LaTeX which makes the fig­ure blend in beau­ti­ful­ly.