Compare commits
8
Commits
96903a4d22
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2fd3e4aa9
|
||
|
|
4a96319bb2
|
||
|
|
faad434dad
|
||
|
|
9896d9bb21
|
||
|
|
248a9b7d1f
|
||
|
|
216e1bff0f
|
||
|
|
472bf7246b
|
||
|
|
0d1cb6cf2a
|
No files matched your search
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -2,6 +2,7 @@
|
||||
# Current weather for xmobar, e.g. "<icon> 7°C": NOAA's decoded METAR (the source of xmobar's Weather plugin)
|
||||
# Icon from the weather, else the sky conditions; clear/partly/mostly cloudy get moon icons when the sun is down.
|
||||
# Temperature colors match the plugin's -L 0 -H 30: low up to 0, high above 30.
|
||||
# With "notify": show the description (e.g. "Light drizzle, mist") and temperature in a notification instead.
|
||||
|
||||
STATION=LZIB LAT=48.2 LON=17.2
|
||||
|
||||
@@ -17,14 +18,16 @@ 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
|
||||
echo "${ICON[thermometer]} N/A"
|
||||
if [[ $1 == notify ]]; then notify-send "Weather" "No report from $STATION"; else echo "<fn=1>${ICON[thermometer]}</fn> N/A"; fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Phenomena "in the vicinity" aren't at the station; the rest are e.g. "light drizzle; mist"
|
||||
wx=$(sed -n 's/^Weather: //p' <<< "$report" | tr ';' '\n' | grep -v vicinity | tr '\n' ' ')
|
||||
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
|
||||
@@ -66,4 +69,13 @@ if awk -v t="$temp" 'BEGIN { exit !(t > 30) }'; then color="#ffb86c"
|
||||
elif awk -v t="$temp" 'BEGIN { exit !(t > 0) }'; then color="#50fa7b"
|
||||
else color="#8be9fd"
|
||||
fi
|
||||
echo "${ICON[$icon]} <fc=$color>$temp</fc>°C"
|
||||
|
||||
if [[ $1 == notify ]]; then
|
||||
if [[ -n $wx ]]; then desc=$(paste -sd, <<< "$wx" | sed 's/,/, /g')
|
||||
elif [[ $icon == day_sunny ]]; then desc=sunny
|
||||
else desc=${sky:-unknown}
|
||||
fi
|
||||
notify-send "${ICON[$icon]} Weather" "${desc^}, $temp°C"
|
||||
exit 0
|
||||
fi
|
||||
echo "<fn=1>${ICON[$icon]}</fn> <fc=$color>$temp</fc>°C"
|
||||
@@ -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
|
||||
@@ -48,5 +49,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/ens_brief.sh week`>%weather% <fc=#565f89>·</fc> %ens_brief%</action> | %pactl_volume% | %date% "
|
||||
, 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% "
|
||||
}
|
||||
@@ -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
|
||||
@@ -49,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/ens_brief.sh week`>%weather% <fc=#565f89>·</fc> %ens_brief%</action> | %pactl_volume% | %date% %_XMONAD_TRAYPAD% "
|
||||
, 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% "
|
||||
}
|
||||
@@ -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
|
||||
@@ -380,7 +383,7 @@ myManageHook =
|
||||
title =? "Genshin Impact" --> doShift wsGames,
|
||||
classIn ["gimp", "audacity"] --> doShift wsMedia,
|
||||
classIn ["pavucontrol", "org.pulseaudio.pavucontrol", "zenity", "org.gnome.zenity", "lxappearance", "qt5ct", "qt6ct"] --> doFloat,
|
||||
className =? "Signal" --> doShift wsChat,
|
||||
classIn ["signal", "discord"] --> doShift wsChat,
|
||||
className =? "Spotify" --> doShift wsMedia,
|
||||
className =? "Transmission-gtk" --> doShift wsWeb,
|
||||
className =? "Viewnior" --> doFloat,
|
||||
@@ -388,7 +391,6 @@ myManageHook =
|
||||
className =? "Xmessage" --> doFloat,
|
||||
className =? "Xreader" --> doShift wsDocs,
|
||||
className =? "calibre" --> doShift wsDocs,
|
||||
className =? "discord" --> doShift wsChat,
|
||||
className =? "feh" --> doFloat,
|
||||
title =? "glxgears" --> doFloat,
|
||||
className =? "library_manager" --> doShift wsDocs,
|
||||
@@ -416,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 =
|
||||
|
||||
Executable
+38
@@ -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
|
||||
@@ -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
|
||||
@@ -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"
|
||||
@@ -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
|
||||
Reference in new issue
Block a user