Compare commits

..
7 Commits
Author SHA1 Message Date
Daniele Fucini 49141ef177 xmobar: show NVIDIA GPU load and temperature
Add gpu.sh, which reads both values from nvidia-smi and colors them like the CPU ones (load 25/75, temp 75/90), and show it between CPU and memory.
2026-11-16 21:42:30 +01:00
Daniele Fucini 478e4d391e Retry i3lock when a keyboard grab blocks it
i3lock exits if another client holds a grab, leaving the screen blanked but
unlocked. Close gcr-prompter (ssh passphrase dialog) first, retry every 2s up
to 30 times and log failures to the journal (tag screen-lock).
2026-11-16 20:57:18 +01:00
Daniele Fucini e2fd3e4aa9 xmonad: restore floating windows after leaving fullscreen
Remember each window's float rect when it goes fullscreen and put it back on exit,
instead of always sinking it (Viewnior after F5). Windows with no record are still sunk.
2026-11-14 19:43:37 +01:00
Daniele Fucini 4a96319bb2 Merge the database dump scripts into db-dump
garmin-dump, weather-dump and library-dump differed only in project, database and rotation; one
db-dump PROJECT DATABASE week|day replaces them. The units keep their names and only change ExecStart.
2026-11-14 15:49:48 +01:00
Daniele Fucini faad434dad aurb: keep ThinLTO cache entries until the size cap
lld expires entries unused for a week by default, which empties the cache between most package rebuilds; prune_after=0s leaves only the 10 GB cap.
2026-11-13 21:27:56 +01:00
Daniele Fucini 9896d9bb21 xmobar: draw the weather icon larger
Add a 13 pt additional font and use it for the weather icon only, so the
rest of the bar and its height are unchanged.
2026-11-13 18:39:53 +01:00
Daniele Fucini 248a9b7d1f xmobar: treat CAVOK/NSC weather reports as clear
NOAA's decoded METAR has no sky conditions line for CAVOK or NSC, so the
weather showed a generic cloud icon and "Unknown"; read them from the raw
observation as clear.
2026-11-13 18:23:14 +01:00
14 changed files with 137 additions and 88 deletions

No files matched your search

+1 -1
View File
@@ -2,4 +2,4 @@
# Here rather than in LDFLAGS: old libtool (<2.4.7) drops -fuse-ld=lld, and these then reach GNU ld.
-fuse-ld=lld
-Wl,--thinlto-cache-dir=/home/fuxino/.cache/thinlto
-Wl,--thinlto-cache-policy=cache_size_bytes=10g
-Wl,--thinlto-cache-policy=cache_size_bytes=10g:prune_after=0s
+1 -1
View File
@@ -5,7 +5,7 @@ StartLimitBurst=4
[Service]
Type=oneshot
ExecStart=%h/.local/bin/garmin-dump
ExecStart=%h/.local/bin/db-dump negsplit Garmin week
# MariaDB not up yet (e.g. caught up right after boot)? retry a few times
Restart=on-failure
RestartSec=5min
+1 -1
View File
@@ -5,7 +5,7 @@ StartLimitBurst=4
[Service]
Type=oneshot
ExecStart=%h/.local/bin/library-dump
ExecStart=%h/.local/bin/db-dump library_manager Library day
# MariaDB not up yet (e.g. caught up right after boot)? retry a few times
Restart=on-failure
RestartSec=5min
+1 -1
View File
@@ -5,7 +5,7 @@ StartLimitBurst=4
[Service]
Type=oneshot
ExecStart=%h/.local/bin/weather-dump
ExecStart=%h/.local/bin/db-dump ens-forecast Weather week
# MariaDB not up yet (e.g. caught up right after boot)? retry a few times
Restart=on-failure
RestartSec=5min
+17
View File
@@ -0,0 +1,17 @@
#!/bin/bash
# NVIDIA GPU load and temperature for xmobar, e.g. "<icon> 9% 68°C", colored like the CPU ones.
# Load 25/75 as MultiCpu; temperature 75/90 (GTX 1050 Ti Mobile: target 94°C, ~65°C driving the HDMI output).
color() { # value low high
if (( $1 > $3 )); then c='#ff5555'; elif (( $1 > $2 )); then c='#ffb86c'; else c='#50fa7b'; fi
printf '<fc=%s>%s</fc>' "$c" "$4"
}
icon=$'\U000f08ae'
IFS=', ' read -r load temp < <(nvidia-smi --query-gpu=utilization.gpu,temperature.gpu --format=csv,noheader,nounits 2>/dev/null)
if [[ ! $load =~ ^[0-9]+$ || ! $temp =~ ^[0-9]+$ ]]; then
echo "$icon N/A"
exit
fi
echo "$icon $(color "$load" 25 75 "$load%") $(color "$temp" 75 90 "$temp°C")"
+4 -2
View File
@@ -18,7 +18,7 @@ declare -A ICON=(
report=$(curl -sf --max-time 20 https://tgftp.nws.noaa.gov/data/observations/metar/decoded/"$STATION".TXT)
temp=$(sed -n 's/^Temperature: .*(\([-0-9.]*\) C).*/\1/p' <<< "$report")
if [[ -z $temp ]]; then
if [[ $1 == notify ]]; then notify-send "Weather" "No report from $STATION"; else echo "${ICON[thermometer]} N/A"; fi
if [[ $1 == notify ]]; then notify-send "Weather" "No report from $STATION"; else echo "<fn=1>${ICON[thermometer]}</fn> N/A"; fi
exit 0
fi
@@ -26,6 +26,8 @@ fi
wx=$(sed -n 's/^Weather: //p' <<< "$report" | tr ';' '\n' | sed 's/^ *//' | grep -v vicinity)
wx=${wx,,}
sky=$(sed -n 's/^Sky conditions: //p' <<< "$report")
# CAVOK/NSC (no cloud below 5000 ft) have no sky line in the decoded report
[[ -z $sky ]] && grep -qE '^ob: .* (CAVOK|NSC) ' <<< "$report" && sky=clear
sky=${sky,,}
# Sun above the horizon (elevation > -0.833°, as for sunrise/sunset) right now, from the low-precision solar position
@@ -76,4 +78,4 @@ if [[ $1 == notify ]]; then
notify-send "${ICON[$icon]} Weather" "${desc^}, $temp°C"
exit 0
fi
echo "${ICON[$icon]} <fc=$color>$temp</fc>°C"
echo "<fn=1>${ICON[$icon]}</fn> <fc=$color>$temp</fc>°C"
+3 -1
View File
@@ -1,6 +1,7 @@
Config { overrideRedirect = True
, lowerOnStart = True
, font = "Jetbrains Mono Nerd Font Bold 10"
, additionalFonts = ["Jetbrains Mono Nerd Font Bold 13"]
, bgColor = "#24283b"
, fgColor = "#737aa2"
, position = TopH 24
@@ -25,6 +26,7 @@ Config { overrideRedirect = True
, "--normal" , "#ffb86c"
, "--high" , "#ff5555"
] 50
, Run Com "/home/fuxino/.config/xmobar/gpu.sh" [] "gpu" 50
, Run Memory
[ "--template" , "\xefc5 <usedratio>%"
, "--Low" , "50"
@@ -48,5 +50,5 @@ Config { overrideRedirect = True
]
, sepChar = "%"
, alignSep = "}{"
, template = "  | %UnsafeXMonadLog% } %multicpu% %coretemp% | %memory% | <action=`/home/fuxino/.config/xmobar/kbd_cycle.sh` button=1><action=`/home/fuxino/.config/xmobar/kbd_cycle.sh prev` button=3> %kbd%</action></action> { <action=`/home/fuxino/.config/xmobar/calcurse.sh list` button=1><action=`xdotool key super+shift+a` button=3>%calcurse%</action></action><action=`/home/fuxino/.config/xmobar/backup.sh list`>%backup%</action><action=`/home/fuxino/.config/xmobar/updates.sh list`>%updates%</action><action=`/home/fuxino/.config/xmobar/weather.sh notify`>%weather%</action> <fc=#565f89>·</fc> <action=`/home/fuxino/.config/xmobar/ens_brief.sh week`>%ens_brief%</action> | <action=`pactl set-sink-mute @DEFAULT_SINK@ toggle` button=1>%pactl_volume%</action> | %date% "
, template = "  | %UnsafeXMonadLog% } %multicpu% %coretemp% | %gpu% | %memory% | <action=`/home/fuxino/.config/xmobar/kbd_cycle.sh` button=1><action=`/home/fuxino/.config/xmobar/kbd_cycle.sh prev` button=3> %kbd%</action></action> { <action=`/home/fuxino/.config/xmobar/calcurse.sh list` button=1><action=`xdotool key super+shift+a` button=3>%calcurse%</action></action><action=`/home/fuxino/.config/xmobar/backup.sh list`>%backup%</action><action=`/home/fuxino/.config/xmobar/updates.sh list`>%updates%</action><action=`/home/fuxino/.config/xmobar/weather.sh notify`>%weather%</action> <fc=#565f89>·</fc> <action=`/home/fuxino/.config/xmobar/ens_brief.sh week`>%ens_brief%</action> | <action=`pactl set-sink-mute @DEFAULT_SINK@ toggle` button=1>%pactl_volume%</action> | %date% "
}
+3 -1
View File
@@ -1,6 +1,7 @@
Config { overrideRedirect = True
, lowerOnStart = True
, font = "Jetbrains Mono Nerd Font Bold 10"
, additionalFonts = ["Jetbrains Mono Nerd Font Bold 13"]
, bgColor = "#24283b"
, fgColor = "#737aa2"
, position = TopH 24
@@ -25,6 +26,7 @@ Config { overrideRedirect = True
, "--normal" , "#ffb86c"
, "--high" , "#ff5555"
] 50
, Run Com "/home/fuxino/.config/xmobar/gpu.sh" [] "gpu" 50
, Run Memory
[ "--template" , "\xefc5 <usedratio>%"
, "--Low" , "50"
@@ -49,5 +51,5 @@ Config { overrideRedirect = True
]
, sepChar = "%"
, alignSep = "}{"
, template = "  | %UnsafeXMonadLog% } %multicpu% %coretemp% | %memory% | <action=`/home/fuxino/.config/xmobar/kbd_cycle.sh` button=1><action=`/home/fuxino/.config/xmobar/kbd_cycle.sh prev` button=3> %kbd%</action></action> { <action=`/home/fuxino/.config/xmobar/calcurse.sh list` button=1><action=`xdotool key super+shift+a` button=3>%calcurse%</action></action><action=`/home/fuxino/.config/xmobar/backup.sh list`>%backup%</action><action=`/home/fuxino/.config/xmobar/updates.sh list`>%updates%</action><action=`/home/fuxino/.config/xmobar/weather.sh notify`>%weather%</action> <fc=#565f89>·</fc> <action=`/home/fuxino/.config/xmobar/ens_brief.sh week`>%ens_brief%</action> | <action=`pactl set-sink-mute @DEFAULT_SINK@ toggle` button=1>%pactl_volume%</action> | %date% %_XMONAD_TRAYPAD% "
, template = "  | %UnsafeXMonadLog% } %multicpu% %coretemp% | %gpu% | %memory% | <action=`/home/fuxino/.config/xmobar/kbd_cycle.sh` button=1><action=`/home/fuxino/.config/xmobar/kbd_cycle.sh prev` button=3> %kbd%</action></action> { <action=`/home/fuxino/.config/xmobar/calcurse.sh list` button=1><action=`xdotool key super+shift+a` button=3>%calcurse%</action></action><action=`/home/fuxino/.config/xmobar/backup.sh list`>%backup%</action><action=`/home/fuxino/.config/xmobar/updates.sh list`>%updates%</action><action=`/home/fuxino/.config/xmobar/weather.sh notify`>%weather%</action> <fc=#565f89>·</fc> <action=`/home/fuxino/.config/xmobar/ens_brief.sh week`>%ens_brief%</action> | <action=`pactl set-sink-mute @DEFAULT_SINK@ toggle` button=1>%pactl_volume%</action> | %date% %_XMONAD_TRAYPAD% "
}
+29 -1
View File
@@ -2,7 +2,8 @@
import Data.Monoid
import Data.Char (toLower)
import Control.Monad (forM_, liftM2, when)
import Control.Monad (forM_, join, liftM2, when)
import qualified Data.Map.Strict as M
import Data.Maybe (isJust)
import XMonad
import XMonad.Actions.OnScreen (greedyViewOnScreen)
@@ -25,6 +26,7 @@ import XMonad.Layout.ThreeColumns
import qualified XMonad.StackSet as W
import XMonad.Util.ClickableWorkspaces
import XMonad.Util.EZConfig
import qualified XMonad.Util.ExtensibleState as XS
import qualified XMonad.Util.Hacks as Hacks
import XMonad.Util.Loggers
import XMonad.Util.NamedActions
@@ -38,6 +40,7 @@ main :: IO ()
main =
xmonad
. ewmhFullscreen
. setEwmhFullscreenHooks myFullscreenHook myUnfullscreenHook
. setEwmhSwitchDesktopHook safeView
. ewmh
. docks
@@ -415,6 +418,31 @@ myManageHook =
-- Case-insensitive, as GTK4 and firejailed apps capitalise their class differently
classIn names = (`elem` names) . map toLower <$> className
-- Fullscreen toggles: remember each window's float rect (Nothing if tiled) so leaving
-- fullscreen restores it instead of always sinking the window.
newtype PreFullscreen = PreFullscreen (M.Map Window (Maybe W.RationalRect))
instance ExtensionClass PreFullscreen where
initialValue = PreFullscreen M.empty
myFullscreenHook :: ManageHook
myFullscreenHook = do
w <- ask
liftX $ do
old <- gets (M.lookup w . W.floating . windowset)
XS.modify (\(PreFullscreen m) -> PreFullscreen (M.insert w old m))
doFullFloat
-- Windows with no record (e.g. opened fullscreen) are sunk, as before.
myUnfullscreenHook :: ManageHook
myUnfullscreenHook = do
w <- ask
old <- liftX $ do
PreFullscreen m <- XS.get
XS.put (PreFullscreen (M.delete w m))
pure (join (M.lookup w m))
maybe doSink doRectFloat old
-- Handle event hook
myHandleEventHook :: Event -> X All
myHandleEventHook =
+38
View File
@@ -0,0 +1,38 @@
#!/bin/bash
# Usage: db-dump PROJECT DATABASE week|day
# Dump a MariaDB database to ~/.local/share/PROJECT/dumps with login ~/.config/PROJECT/dump.cnf.
# week: per-ISO-week files, keeping the two newest; day: per-weekday files (seven self-rotating copies).
set -euo pipefail
if (($# != 3)) || [[ $3 != week && $3 != day ]]; then
echo "usage: ${0##*/} PROJECT DATABASE week|day" >&2
exit 2
fi
project=$1 db=$2 mode=$3
cnf=${XDG_CONFIG_HOME:-$HOME/.config}/$project/dump.cnf
dir=${XDG_DATA_HOME:-$HOME/.local/share}/$project/dumps
if [[ $mode == week ]]; then
out=$dir/$db-$(date +%G-W%V).sql.gz
else
out=$dir/$db-$(LC_ALL=C date +%a).sql.gz
fi
keep=2
umask 077
mkdir -p "$dir"
# Write to a temporary file so a failed dump never replaces a good one
tmp=$(mktemp "$dir/.dump.XXXXXX")
trap 'rm -f "$tmp"' EXIT
mariadb-dump --defaults-extra-file="$cnf" --single-transaction --databases "$db" | gzip > "$tmp"
mv "$tmp" "$out"
# Weekly names sort by week, so all but the last $keep are the old ones
if [[ $mode == week ]]; then
dumps=("$dir/$db"-[0-9][0-9][0-9][0-9]-W[0-9][0-9].sql.gz)
if ((${#dumps[@]} > keep)); then
rm -f -- "${dumps[@]:0:${#dumps[@]}-keep}"
fi
fi
-24
View File
@@ -1,24 +0,0 @@
#!/bin/bash
# Dump the Garmin database to a per-ISO-week file, keeping the two newest weeks.
set -euo pipefail
cnf=${XDG_CONFIG_HOME:-$HOME/.config}/negsplit/dump.cnf
dir=${XDG_DATA_HOME:-$HOME/.local/share}/negsplit/dumps
out=$dir/Garmin-$(date +%G-W%V).sql.gz
keep=2
umask 077
mkdir -p "$dir"
# Write to a temporary file so a failed dump never replaces a good one
tmp=$(mktemp "$dir/.dump.XXXXXX")
trap 'rm -f "$tmp"' EXIT
mariadb-dump --defaults-extra-file="$cnf" --single-transaction --databases Garmin | gzip > "$tmp"
mv "$tmp" "$out"
# Names sort by week, so all but the last $keep are the old ones
dumps=("$dir"/Garmin-*.sql.gz)
if (( ${#dumps[@]} > keep )); then
rm -f -- "${dumps[@]:0:${#dumps[@]}-keep}"
fi
-17
View File
@@ -1,17 +0,0 @@
#!/bin/bash
# Dump the Library database to a per-weekday file (seven self-rotating copies).
set -euo pipefail
cnf=${XDG_CONFIG_HOME:-$HOME/.config}/library_manager/dump.cnf
dir=${XDG_DATA_HOME:-$HOME/.local/share}/library_manager/dumps
out=$dir/Library-$(LC_ALL=C date +%a).sql.gz
umask 077
mkdir -p "$dir"
# Write to a temporary file so a failed dump never replaces a good one
tmp=$(mktemp "$dir/.dump.XXXXXX")
trap 'rm -f "$tmp"' EXIT
mariadb-dump --defaults-extra-file="$cnf" --single-transaction --databases Library | gzip > "$tmp"
mv "$tmp" "$out"
+39 -14
View File
@@ -2,25 +2,50 @@
# i3lock-color with a background image and the keyboard layout shown.
image=/usr/share/backgrounds/arch_1920x1080.png
err=${XDG_RUNTIME_DIR:-/tmp}/screen-lock.err
log() { printf '%s\n' "$*" | systemd-cat -t screen-lock -p warning; }
# gcr-prompter (ssh key passphrase dialog) grabs the keyboard, so i3lock can't lock: cancel it.
pkill -x gcr-prompter && log "stopped gcr-prompter before locking"
# Hold notifications while locked; dunst shows them on unlock. A signal to this
# script is passed on to i3lock, as the old exec did.
was_paused=$(dunstctl is-paused 2>/dev/null)
dunstctl set-paused true 2>/dev/null
trap 'kill "$pid" 2>/dev/null' INT TERM HUP
stopped=
trap 'stopped=1; kill "$pid" 2>/dev/null' INT TERM HUP
# -n: stay in the foreground, as xss-lock needs to see when the screen is unlocked.
# --indicator keeps the ring (and the layout text) visible before typing.
# The layout's default spot (dx:dy+30) falls inside the ring: put it below.
i3lock -n -i "$image" -F -c 000000ff \
-e -f --indicator --keylayout 0 \
--layout-pos='ix:iy+r+40' --layout-color=ffffffff \
--layout-size=24 \
--time-color=ffffffff --date-color=ffffffff --date-str='%A, %d %B' \
--ring-color=1793d1ff --line-uses-ring "$@" &
pid=$!
# A trapped signal interrupts the first wait; the second waits for i3lock to exit.
wait "$pid"
wait "$pid" 2>/dev/null
# i3lock exits 1 if another client holds a grab (dmenu, rofi, a prompt): retry for a minute.
tries=0
while :; do
# -n: stay in the foreground, as xss-lock needs to see when the screen is unlocked.
# --indicator keeps the ring (and the layout text) visible before typing.
# The layout's default spot (dx:dy+30) falls inside the ring: put it below.
i3lock -n -i "$image" -F -c 000000ff \
-e -f --indicator --keylayout 0 \
--layout-pos='ix:iy+r+40' --layout-color=ffffffff \
--layout-size=24 \
--time-color=ffffffff --date-color=ffffffff --date-str='%A, %d %B' \
--ring-color=1793d1ff --line-uses-ring "$@" 2>"$err" &
pid=$!
wait "$pid"
status=$?
# A trapped signal interrupts the first wait; this one waits for i3lock to exit.
if [ -n "$stopped" ]; then
wait "$pid" 2>/dev/null
break
fi
[ "$status" -eq 0 ] && break
tries=$((tries + 1))
log "i3lock failed (exit $status, try $tries): $(cat "$err")"
if [ "$tries" -ge 30 ]; then
log "giving up: screen not locked"
break
fi
sleep 2
[ -n "$stopped" ] && break
done
rm -f "$err"
[ "$was_paused" = true ] || dunstctl set-paused false 2>/dev/null
-24
View File
@@ -1,24 +0,0 @@
#!/bin/bash
# Dump the Weather database (ens-forecast) to a per-ISO-week file, keeping the two newest weeks.
set -euo pipefail
cnf=${XDG_CONFIG_HOME:-$HOME/.config}/ens-forecast/dump.cnf
dir=${XDG_DATA_HOME:-$HOME/.local/share}/ens-forecast/dumps
out=$dir/Weather-$(date +%G-W%V).sql.gz
keep=2
umask 077
mkdir -p "$dir"
# Write to a temporary file so a failed dump never replaces a good one
tmp=$(mktemp "$dir/.dump.XXXXXX")
trap 'rm -f "$tmp"' EXIT
mariadb-dump --defaults-extra-file="$cnf" --single-transaction --databases Weather | gzip > "$tmp"
mv "$tmp" "$out"
# Names sort by week, so all but the last $keep are the old ones
dumps=("$dir"/Weather-*.sql.gz)
if (( ${#dumps[@]} > keep )); then
rm -f -- "${dumps[@]:0:${#dumps[@]}-keep}"
fi