Compare commits
40
Commits
5b6e381c89
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be065bef95
|
||
|
|
9e2b6d52bb
|
||
|
|
85796d4c39
|
||
|
|
6e587622f0
|
||
|
|
5fa637ef79
|
||
|
|
a5f7d9507f
|
||
|
|
394e1d4d58
|
||
|
|
108f71e711
|
||
|
|
7e8328bf60
|
||
|
|
49141ef177
|
||
|
|
478e4d391e
|
||
|
|
e2fd3e4aa9
|
||
|
|
4a96319bb2
|
||
|
|
faad434dad
|
||
|
|
9896d9bb21
|
||
|
|
248a9b7d1f
|
||
|
|
216e1bff0f
|
||
|
|
472bf7246b
|
||
|
|
0d1cb6cf2a
|
||
|
|
96903a4d22
|
||
|
|
ce1cd479df
|
||
|
|
c103510786
|
||
|
|
3053b35f26
|
||
|
|
a260a42352
|
||
|
|
566ac562bd
|
||
|
|
3bb25669ea
|
||
|
|
84eec8c855
|
||
|
|
f6015f8d98
|
||
|
|
7aa423b6d6
|
||
|
|
b5c268ae7d
|
||
|
|
0ec1272df6
|
||
|
|
6f4aa3806f
|
||
|
|
9da7cc8105
|
||
|
|
93b5bcbf30
|
||
|
|
4c5ca29f6e
|
||
|
|
8bfd577b20
|
||
|
|
3a2d2b7c37
|
||
|
|
51b2bbeff8
|
||
|
|
b76ae5c3f6
|
||
|
|
90a81ea960
|
No files matched your search
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
Xcursor.theme: Dracula
|
Xcursor.theme: Dracula-cursors
|
||||||
|
|
||||||
*.Dialog.bodyFont: Jetbrains Mono Nerd Font
|
*.Dialog.bodyFont: Jetbrains Mono Nerd Font
|
||||||
*.Dialog.headingFont: Jetbrains Mono Nerd Font
|
*.Dialog.headingFont: Jetbrains Mono Nerd Font
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
# Aliases
|
# Aliases
|
||||||
alias cat='bat'
|
alias cat='bat'
|
||||||
alias clean-aurutils-cache='find ~/.cache/aurutils/sync -type d -name .git -execdir git clean -xi \;'
|
|
||||||
alias config='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
|
alias config='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
|
||||||
alias cookie='fortune /usr/share/fortune/asoiaf /usr/share/fortune/startrek | cowthink | lolcat -p 2.0 -F 0.3 -a -d 1'
|
alias cookie='fortune /usr/share/fortune/asoiaf /usr/share/fortune/startrek | cowthink | lolcat -p 2.0 -F 0.3 -a -d 1'
|
||||||
alias fastfetch='hyfetch --distro=arch'
|
alias fastfetch='hyfetch --distro=arch'
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Thermal-focused overlay; starts hidden, Shift_R+F12 toggles it.
|
||||||
|
no_display
|
||||||
|
toggle_hud=Shift_R+F12
|
||||||
|
position=top-left
|
||||||
|
font_size=20
|
||||||
|
background_alpha=0.4
|
||||||
|
|
||||||
|
# Divisors of 60 Hz only; Shift_L+F1 cycles 60 -> 30 -> unlimited.
|
||||||
|
fps_limit=60,30,0
|
||||||
|
toggle_fps_limit=Shift_L+F1
|
||||||
|
fps_limit_method=late
|
||||||
|
|
||||||
|
# GPU0 is the Intel iGPU (no temp, power or VRAM); only show the NVIDIA one.
|
||||||
|
gpu_list=1
|
||||||
|
gpu_stats
|
||||||
|
gpu_temp
|
||||||
|
gpu_core_clock
|
||||||
|
throttling_status
|
||||||
|
|
||||||
|
cpu_stats
|
||||||
|
cpu_temp
|
||||||
|
cpu_mhz
|
||||||
|
|
||||||
|
vram
|
||||||
|
ram
|
||||||
|
|
||||||
|
fps
|
||||||
|
frametime
|
||||||
|
frame_timing
|
||||||
@@ -2,4 +2,4 @@
|
|||||||
# Here rather than in LDFLAGS: old libtool (<2.4.7) drops -fuse-ld=lld, and these then reach GNU ld.
|
# Here rather than in LDFLAGS: old libtool (<2.4.7) drops -fuse-ld=lld, and these then reach GNU ld.
|
||||||
-fuse-ld=lld
|
-fuse-ld=lld
|
||||||
-Wl,--thinlto-cache-dir=/home/fuxino/.cache/thinlto
|
-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
|
||||||
@@ -20,7 +20,7 @@ format.notifytime=%T
|
|||||||
format.appointmenttime=%H:%M
|
format.appointmenttime=%H:%M
|
||||||
format.outputdate=%F
|
format.outputdate=%F
|
||||||
format.dayheading=%B %e, %Y
|
format.dayheading=%B %e, %Y
|
||||||
general.autogc=no
|
general.autogc=yes
|
||||||
general.autosave=yes
|
general.autosave=yes
|
||||||
general.confirmdelete=yes
|
general.confirmdelete=yes
|
||||||
general.confirmquit=yes
|
general.confirmquit=yes
|
||||||
@@ -28,6 +28,6 @@ general.firstdayofweek=monday
|
|||||||
general.multipledays=yes
|
general.multipledays=yes
|
||||||
general.periodicsave=0
|
general.periodicsave=0
|
||||||
general.systemevents=yes
|
general.systemevents=yes
|
||||||
notification.command=calcurse --next | xargs -0 notify-send "Appointment"
|
notification.command=calcurse --next | xargs -0 notify-send -a calcurse -i x-office-calendar "Appointment"
|
||||||
notification.notifyall=all
|
notification.notifyall=all
|
||||||
notification.warning=3600
|
notification.warning=3600
|
||||||
Executable
+6
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Sync the UI's saved changes once it exits (syncing while it runs would change files under it).
|
||||||
|
[ "$(ps -o args= -p "$PPID")" = calcurse ] && [ "$(ps -o tty= -p "$PPID" | tr -d ' ')" != '?' ] || exit 0
|
||||||
|
# shellcheck disable=SC2016 # $1 expands in the inner shell
|
||||||
|
setsid -f sh -c 'while kill -0 "$1" 2>/dev/null; do sleep 1; done; systemctl --user start calcurse-sync.service' \
|
||||||
|
sh "$PPID" >/dev/null 2>&1
|
||||||
Executable
+5
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Sync with Google before the UI loads. Non-interactive calls (-Q, -d, -i, calcurse-caldav's own) run this hook
|
||||||
|
# too, so act only for the UI: a bare "calcurse" with a terminal (the daemon is bare too, but has none).
|
||||||
|
[ "$(ps -o args= -p "$PPID")" = calcurse ] && [ "$(ps -o tty= -p "$PPID" | tr -d ' ')" != '?' ] || exit 0
|
||||||
|
calcurse-sync --now 2>&1 | systemd-cat -t calcurse-sync
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
# Always-on Remote Control
|
||||||
|
|
||||||
|
Reference copy of a machine setup: Claude Code Remote Control running as its own system user `claude-rc`, so my
|
||||||
|
projects' read-only MCP servers (now: negsplit, ens-forecast) can be used from the Claude app on the phone. One user and one
|
||||||
|
session (`data`) for all projects. The user holds only read-only database logins; Bash runs sandboxed without
|
||||||
|
network and can't read them (only the MCP servers, which run outside the sandbox, do). Nothing secret in this
|
||||||
|
folder: the ntfy topic lives only in `/etc/claude-rc-notify.env`.
|
||||||
|
|
||||||
|
Needs `claude-code`, `bubblewrap`, `socat` and each project's MCP server installed. Per project:
|
||||||
|
|
||||||
|
- negsplit: the installed `negsplit` (with `python-mcp`) and the `garmin_ro` grants from its
|
||||||
|
`sql/garmin_ro_grants.sql`. A per-user query limit is a useful safety net (the session can lift it):
|
||||||
|
|
||||||
|
```
|
||||||
|
mariadb -u root -p -e "ALTER USER 'garmin_ro'@'localhost' WITH MAX_STATEMENT_TIME 30;"
|
||||||
|
```
|
||||||
|
- ens-forecast: the installed `ens-forecast-mcp` (with `python-mcp` and `python-mysqlclient`) and the `weather_ro`
|
||||||
|
grant from its `sql/weather_grants.sql`; the same safety net:
|
||||||
|
|
||||||
|
```
|
||||||
|
mariadb -u root -p -e "ALTER USER 'weather_ro'@'localhost' WITH MAX_STATEMENT_TIME 30;"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
Run from this folder. User and folders:
|
||||||
|
|
||||||
|
```
|
||||||
|
doas useradd --system --create-home --home-dir /var/lib/claude-rc --shell /usr/bin/nologin claude-rc
|
||||||
|
doas chmod 700 /var/lib/claude-rc
|
||||||
|
doas install -d -o claude-rc -g claude-rc -m 700 /var/lib/claude-rc/.config /var/lib/claude-rc/.claude /var/lib/claude-rc/data /var/lib/claude-rc/data/.claude
|
||||||
|
doas install -o claude-rc -g claude-rc -m 644 mcp.json /var/lib/claude-rc/data/.mcp.json
|
||||||
|
doas install -o claude-rc -g claude-rc -m 644 project-settings.json /var/lib/claude-rc/data/.claude/settings.json
|
||||||
|
doas install -o claude-rc -g claude-rc -m 644 user-settings.json /var/lib/claude-rc/.claude/settings.json
|
||||||
|
```
|
||||||
|
|
||||||
|
`strictAllowlist` must stay in the user settings: in project settings it has no effect.
|
||||||
|
|
||||||
|
Each project's config holds only a `[readonly]` section. negsplit (`garmin_ro`):
|
||||||
|
|
||||||
|
```
|
||||||
|
doas install -d -o claude-rc -g claude-rc -m 700 /var/lib/claude-rc/.config/negsplit
|
||||||
|
doas install -o claude-rc -g claude-rc -m 600 config.toml /var/lib/claude-rc/.config/negsplit/config.toml
|
||||||
|
```
|
||||||
|
|
||||||
|
ens-forecast (`weather_ro`): only the `[readonly]` section of my own config, so the password never shows:
|
||||||
|
|
||||||
|
```
|
||||||
|
doas install -d -o claude-rc -g claude-rc -m 700 /var/lib/claude-rc/.config/ens-forecast
|
||||||
|
awk '/^\[/ { keep = ($0 == "[readonly]") } keep' ~/.config/ens-forecast/config.toml | doas install -o claude-rc -g claude-rc -m 600 /dev/stdin /var/lib/claude-rc/.config/ens-forecast/config.toml
|
||||||
|
```
|
||||||
|
|
||||||
|
Log in, trust the folder and enable Remote Control once, interactively:
|
||||||
|
|
||||||
|
```
|
||||||
|
doas -u claude-rc sh -c 'cd /var/lib/claude-rc/data && exec claude auth login'
|
||||||
|
doas -u claude-rc sh -c 'cd /var/lib/claude-rc/data && exec claude'
|
||||||
|
doas -u claude-rc sh -c 'cd /var/lib/claude-rc/data && exec claude remote-control --name data --spawn session'
|
||||||
|
```
|
||||||
|
|
||||||
|
ntfy topic for the failure alert (subscribe to it on ntfy.sh), then the units:
|
||||||
|
|
||||||
|
```
|
||||||
|
doas sh -c 'umask 077; printf "NTFY_TOPIC=claude-rc-%s\n" "$(openssl rand -hex 16)" > /etc/claude-rc-notify.env'
|
||||||
|
doas install -m 644 claude-rc.service claude-rc-notify.service claude-rc-recover.service claude-rc-recover.timer -t /etc/systemd/system/
|
||||||
|
doas systemctl daemon-reload
|
||||||
|
doas systemctl enable --now claude-rc.service claude-rc-recover.timer
|
||||||
|
```
|
||||||
|
|
||||||
|
The service restarts with a growing delay (30 s to 10 min); after about 50 minutes of failures it gives up and
|
||||||
|
sends the alert. The timer restarts it every 3 hours if it gave up, so a long network outage doesn't stop it for
|
||||||
|
good. After upgrading a project's MCP server, or changing `mcp.json` or the settings, restart `claude-rc.service`
|
||||||
|
so phone sessions use the new version.
|
||||||
|
|
||||||
|
## Adding a project
|
||||||
|
|
||||||
|
Add its server to `mcp.json` and `mcp__<server>` to the `allow` list in `project-settings.json` (plus a `Read` rule
|
||||||
|
for its chart folder, if any), install its `[readonly]` config as above, reinstall the changed files and restart
|
||||||
|
the service.
|
||||||
|
|
||||||
|
## Dead login
|
||||||
|
|
||||||
|
```
|
||||||
|
doas systemctl stop claude-rc.service
|
||||||
|
doas -u claude-rc sh -c 'cd /var/lib/claude-rc/data && exec claude auth login'
|
||||||
|
doas systemctl reset-failed claude-rc.service
|
||||||
|
doas systemctl start claude-rc.service
|
||||||
|
```
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Notify via ntfy that Claude Remote Control stopped
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
DynamicUser=yes
|
||||||
|
# NTFY_TOPIC=...: root-only (0600), the topic is the only secret
|
||||||
|
EnvironmentFile=/etc/claude-rc-notify.env
|
||||||
|
TimeoutStartSec=10min
|
||||||
|
ExecStart=/usr/bin/curl -fsS -m 30 --retry 5 --retry-delay 60 --retry-all-errors \
|
||||||
|
-H "Title: Claude Remote Control stopped" -H "Tags: warning" \
|
||||||
|
-d "%H: claude-rc.service keeps failing (dead login?). Retried every 3 h; fix at home: claude auth login as claude-rc." \
|
||||||
|
https://ntfy.sh/${NTFY_TOPIC}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Restart Claude Remote Control if it gave up (e.g. after a long network outage)
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecCondition=/usr/bin/systemctl is-failed --quiet claude-rc.service
|
||||||
|
ExecStart=/usr/bin/systemctl reset-failed claude-rc.service
|
||||||
|
ExecStart=/usr/bin/systemctl start --no-block claude-rc.service
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Every 3 h, restart Claude Remote Control if it gave up
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnBootSec=1h
|
||||||
|
OnUnitActiveSec=3h
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Claude Code Remote Control (read-only MCP servers)
|
||||||
|
Wants=network-online.target
|
||||||
|
After=network-online.target mariadb.service
|
||||||
|
# about 50 min of failed starts (back-off below): give up and notify
|
||||||
|
StartLimitIntervalSec=1h
|
||||||
|
StartLimitBurst=8
|
||||||
|
OnFailure=claude-rc-notify.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=claude-rc
|
||||||
|
Group=claude-rc
|
||||||
|
WorkingDirectory=/var/lib/claude-rc/data
|
||||||
|
# strips credentials from subprocess environments; on Linux also sandboxes ! shell commands
|
||||||
|
Environment=CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1
|
||||||
|
ExecStart=/usr/bin/claude remote-control --name data --spawn session
|
||||||
|
Restart=always
|
||||||
|
RestartSec=30s
|
||||||
|
RestartSteps=4
|
||||||
|
RestartMaxDelaySec=10min
|
||||||
|
ProtectSystem=strict
|
||||||
|
ProtectHome=yes
|
||||||
|
ReadWritePaths=/var/lib/claude-rc
|
||||||
|
PrivateTmp=yes
|
||||||
|
NoNewPrivileges=yes
|
||||||
|
ProtectKernelTunables=yes
|
||||||
|
ProtectKernelModules=yes
|
||||||
|
ProtectControlGroups=yes
|
||||||
|
ProtectKernelLogs=yes
|
||||||
|
ProtectClock=yes
|
||||||
|
ProtectHostname=yes
|
||||||
|
CapabilityBoundingSet=
|
||||||
|
RestrictSUIDSGID=yes
|
||||||
|
RestrictRealtime=yes
|
||||||
|
LockPersonality=yes
|
||||||
|
# no RestrictNamespaces/MemoryDenyWriteExecute: the Bash sandbox (bubblewrap) needs user namespaces
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"negsplit": {
|
||||||
|
"command": "negsplit",
|
||||||
|
"args": ["mcp"]
|
||||||
|
},
|
||||||
|
"ens-forecast": {
|
||||||
|
"command": "ens-forecast-mcp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"permissions": {
|
||||||
|
"defaultMode": "default",
|
||||||
|
"disableBypassPermissionsMode": "disable",
|
||||||
|
"disableAutoMode": "disable",
|
||||||
|
"allow": [
|
||||||
|
"mcp__negsplit",
|
||||||
|
"mcp__ens-forecast",
|
||||||
|
"Read(~/.local/share/negsplit/charts/**)"
|
||||||
|
],
|
||||||
|
"deny": [
|
||||||
|
"Read(~/.config/**)",
|
||||||
|
"Read(~/.claude/**)",
|
||||||
|
"Read(~/.claude.json)",
|
||||||
|
"Edit(~/.config/**)",
|
||||||
|
"Edit(~/.claude/**)",
|
||||||
|
"Edit(~/.claude.json)",
|
||||||
|
"Edit(./.claude/**)",
|
||||||
|
"Edit(./.mcp.json)",
|
||||||
|
"WebFetch",
|
||||||
|
"WebSearch"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"sandbox": {
|
||||||
|
"enabled": true,
|
||||||
|
"failIfUnavailable": true,
|
||||||
|
"allowUnsandboxedCommands": false,
|
||||||
|
"autoAllowBashIfSandboxed": true,
|
||||||
|
"filesystem": {
|
||||||
|
"denyRead": ["~/.config", "~/.claude", "~/.claude.json"],
|
||||||
|
"denyWrite": ["./.claude", "./.mcp.json"]
|
||||||
|
},
|
||||||
|
"network": {
|
||||||
|
"allowedDomains": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"theme": "dark",
|
||||||
|
"sandbox": {
|
||||||
|
"network": {
|
||||||
|
"strictAllowlist": true,
|
||||||
|
"allowedDomains": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -300,7 +300,7 @@
|
|||||||
# * context_all: Open context menu for all notifications.
|
# * context_all: Open context menu for all notifications.
|
||||||
# These values can be strung together for each mouse event, and
|
# These values can be strung together for each mouse event, and
|
||||||
# will be executed in sequence.
|
# will be executed in sequence.
|
||||||
mouse_left_click = close_current
|
mouse_left_click = do_action, close_current
|
||||||
mouse_middle_click = do_action, close_current
|
mouse_middle_click = do_action, close_current
|
||||||
mouse_right_click = close_all
|
mouse_right_click = close_all
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,6 @@ if status is-interactive
|
|||||||
|
|
||||||
fastfetch
|
fastfetch
|
||||||
|
|
||||||
cookie
|
|
||||||
|
|
||||||
calcurse -d 7
|
|
||||||
|
|
||||||
starship init fish | source
|
starship init fish | source
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
[general]
|
||||||
|
inhibit_screensaver=1
|
||||||
|
renice=10
|
||||||
|
; performance gave no gain: the CPU is heat-limited at 95 °C either way
|
||||||
|
desiredgov=powersave
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
mainwindow_position = mouse
|
|
||||||
close_on_unfocus = 1
|
|
||||||
mark_today = 1
|
|
||||||
show_week_numbers = 1
|
|
||||||
@@ -13,4 +13,4 @@ gtk-enable-event-sounds=1
|
|||||||
gtk-enable-input-feedback-sounds=1
|
gtk-enable-input-feedback-sounds=1
|
||||||
gtk-xft-antialias=1
|
gtk-xft-antialias=1
|
||||||
gtk-xft-hinting=1
|
gtk-xft-hinting=1
|
||||||
gtk-xft-hintstyle=hintfull
|
gtk-xft-hintstyle=hintmedium
|
||||||
@@ -36,6 +36,7 @@ set cleaner ~/.config/lf/lf_kitty_clean
|
|||||||
# text files and a file opener for the rest.
|
# text files and a file opener for the rest.
|
||||||
cmd open &{{
|
cmd open &{{
|
||||||
case $(file --mime-type -Lb $f) in
|
case $(file --mime-type -Lb $f) in
|
||||||
|
text/html) for f in $fx; do $OPENER $f > /dev/null 2> /dev/null & done;;
|
||||||
text/*) lf -remote "send $id \$$EDITOR \$fx";;
|
text/*) lf -remote "send $id \$$EDITOR \$fx";;
|
||||||
application/json) lf -remote "send $id \$$EDITOR \$fx";;
|
application/json) lf -remote "send $id \$$EDITOR \$fx";;
|
||||||
video/*) movie $fx > /dev/null 2> /dev/null;;
|
video/*) movie $fx > /dev/null 2> /dev/null;;
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
macro pager \cb <pipe-entry>'urlscan'<enter> 'Follow links with urlview'
|
macro index,pager \cb "<pipe-message>urlscan<enter>" "Follow links with urlscan"
|
||||||
macro index,pager a "<pipe-message>abook --add-email-quiet<return>" "Add this sender to Abook"
|
macro index,pager a "<pipe-message>abook --add-email-quiet<return>" "Add this sender to Abook"
|
||||||
macro attach V "<pipe-entry>iconv -c --to-code=UTF8 > ~/.cache/mutt/mail.html<enter><shell-escape>vivaldi-stable ~/.cache/mutt/mail.html<enter>"
|
macro attach V "<pipe-entry>iconv -c --to-code=UTF8 > ~/.cache/mutt/html/mail.html<enter><shell-escape>zen-browser ~/.cache/mutt/html/mail.html >/dev/null 2>&1<enter>" "Open attachment in Zen"
|
||||||
@@ -29,6 +29,7 @@ bind editor <Tab> complete-query
|
|||||||
# Other settings
|
# Other settings
|
||||||
set header_cache = "~/.cache/mutt"
|
set header_cache = "~/.cache/mutt"
|
||||||
set message_cachedir = "~/.cache/mutt"
|
set message_cachedir = "~/.cache/mutt"
|
||||||
|
set message_cache_clean = yes
|
||||||
|
|
||||||
set timeout = 30
|
set timeout = 30
|
||||||
set editor = "vim"
|
set editor = "vim"
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
backend = "xrender"
|
backend = "xrender"
|
||||||
dithered-present = false;
|
dithered-present = false;
|
||||||
use-damage = true;
|
use-damage = true;
|
||||||
|
# Fullscreen games bypass picom: less CPU work and latency.
|
||||||
|
unredir-if-possible = true;
|
||||||
|
|
||||||
shadow = true;
|
shadow = true;
|
||||||
shadow-radius = 7;
|
shadow-radius = 7;
|
||||||
@@ -41,4 +43,9 @@ rules: ({
|
|||||||
"class_g = 'Cairo-clock' || "
|
"class_g = 'Cairo-clock' || "
|
||||||
"_GTK_FRAME_EXTENTS@";
|
"_GTK_FRAME_EXTENTS@";
|
||||||
shadow = false;
|
shadow = false;
|
||||||
|
}, {
|
||||||
|
# Unredirecting fullscreen i3lock/mpv left the HDMI output (reverse PRIME sink) black.
|
||||||
|
match = "class_g = 'i3lock' || "
|
||||||
|
"class_g = 'mpv'";
|
||||||
|
unredir = false;
|
||||||
})
|
})
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Ask to renew the calcurse Google Calendar login
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
# simple: the prompt waits for a click without a start timeout
|
||||||
|
Type=simple
|
||||||
|
ExecStart=%h/.local/bin/calcurse-relogin --prompt
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Sync calcurse with Google Calendar
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=%h/.local/bin/calcurse-sync
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Sync calcurse with Google Calendar hourly
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnActiveSec=1min
|
||||||
|
OnCalendar=hourly
|
||||||
|
Persistent=true
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Notify today's calcurse events
|
||||||
|
After=calcurse-sync.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=%h/.local/bin/calcurse-today
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Notify today's calcurse events every morning
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=*-*-* 09:00
|
||||||
|
Persistent=true
|
||||||
@@ -5,7 +5,7 @@ StartLimitBurst=4
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
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
|
# MariaDB not up yet (e.g. caught up right after boot)? retry a few times
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
RestartSec=5min
|
RestartSec=5min
|
||||||
@@ -5,7 +5,7 @@ StartLimitBurst=4
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
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
|
# MariaDB not up yet (e.g. caught up right after boot)? retry a few times
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
RestartSec=5min
|
RestartSec=5min
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Dump the Weather database to ~/.local/share/ens-forecast/dumps
|
||||||
|
StartLimitIntervalSec=2h
|
||||||
|
StartLimitBurst=4
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
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
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Dump the Weather database weekly
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=weekly
|
||||||
|
Persistent=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
||||||
Executable
+42
@@ -0,0 +1,42 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Next calcurse item for xmobar: pink " 10:15 | " for an appointment later today, a cyan icon for a whole-day
|
||||||
|
# event today, a pink icon alone when the next appointment is tomorrow; empty otherwise.
|
||||||
|
# With "list": show today's and tomorrow's items in a notification (for a click on the bar)
|
||||||
|
set -uo pipefail
|
||||||
|
|
||||||
|
icon=$'\xf3\xb0\x83\xad' # nf-md-calendar, as UTF-8 bytes so the locale doesn't matter
|
||||||
|
today=$(date +%F)
|
||||||
|
|
||||||
|
query() {
|
||||||
|
calcurse -Q --filter-type cal --days 2 --output-datefmt %F "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ ${1:-} == list ]]; then
|
||||||
|
tomorrow=$(date -d tomorrow +%F)
|
||||||
|
body=$(query --format-apt '%S–%E %m\n' --format-recur-apt '%S–%E %m\n' \
|
||||||
|
--format-event 'all day %m\n' --format-recur-event 'all day %m\n' |
|
||||||
|
sed -e 's/&/\&/g; s/</\</g; s/>/\>/g' -e "s/^$today:$/Today:/; s/^$tomorrow:$/Tomorrow:/")
|
||||||
|
notify-send -a calcurse -i x-office-calendar "Calendar" "${body:-Nothing today or tomorrow}"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
now=$(date +%s)
|
||||||
|
day="" next="" event=false
|
||||||
|
while read -r kind start; do
|
||||||
|
case $kind in
|
||||||
|
*:) day=${kind%:} ;;
|
||||||
|
A) [[ -z $next ]] && ((start > now)) && next=$start ;;
|
||||||
|
E) [[ $day == "$today" ]] && event=true ;;
|
||||||
|
esac
|
||||||
|
done < <(query --format-apt 'A %s\n' --format-recur-apt 'A %s\n' --format-event 'E\n' --format-recur-event 'E\n')
|
||||||
|
|
||||||
|
if [[ -n $next && $(date -d "@$next" +%F) == "$today" ]]; then
|
||||||
|
text="<fc=#ff79c6>$icon $(date -d "@$next" +%H:%M)</fc>"
|
||||||
|
elif $event; then
|
||||||
|
text="<fc=#8be9fd>$icon</fc>"
|
||||||
|
elif [[ -n $next ]]; then
|
||||||
|
text="<fc=#ff79c6>$icon</fc>"
|
||||||
|
else
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo "$text | "
|
||||||
@@ -13,7 +13,7 @@ declare -A LABEL=([ncep_gefs025]=GEFS [icon_seamless_eps]=ICON [google_weatherne
|
|||||||
pick() {
|
pick() {
|
||||||
local m l head first="" first_model="" err=""
|
local m l head first="" first_model="" err=""
|
||||||
for m in "${MODELS[@]}"; do
|
for m in "${MODELS[@]}"; do
|
||||||
if ! l=$(ens-forecast --brief "$1" --model "$m" 2>&1); then
|
if ! l=$(ens-forecast brief "$1" --model "$m" 2>&1); then
|
||||||
[[ -z $err ]] && err=$l
|
[[ -z $err ]] && err=$l
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@@ -47,9 +47,11 @@ if [ "$1" = "week" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
pick 1 2>/dev/null || exit 0
|
pick 1 2>/dev/null || exit 0
|
||||||
read -r day temps rain <<< "${line#*: }"
|
read -r day temps rain extra <<< "${line#*: }"
|
||||||
|
# Probabilities as nf-weather icons: frost snowflake_cold, snow, heat hot
|
||||||
|
extra=${extra//frost /$'\xee\x8d\xaf' } extra=${extra//snow /$'\xee\x8c\x9a' } extra=${extra//heat /$'\xee\x8d\xab' }
|
||||||
label=""
|
label=""
|
||||||
[[ $model != "${MODELS[0]}" ]] && label="${LABEL[$model]:-$model} "
|
[[ $model != "${MODELS[0]}" ]] && label="${LABEL[$model]:-$model} "
|
||||||
stale=""
|
stale=""
|
||||||
[[ ${line%%: *} == *STALE* ]] && stale=" <fc=#f7768e>!</fc>"
|
[[ ${line%%: *} == *STALE* ]] && stale=" <fc=#f7768e>!</fc>"
|
||||||
echo "$label$day ${temps%C} "$''" $rain$stale"
|
echo "$label$day ${temps%C} "$''" $rain${extra:+ $extra}$stale"
|
||||||
Executable
+17
@@ -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")"
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Pending updates for xmobar from update-notify's pending list, e.g. " 15/3 | " (repo/AUR), empty when none
|
# Pending updates for xmobar from update-notify's pending list, e.g. " 15/3 | " (repo/AUR), empty when none
|
||||||
# Entries already installed are dropped, so the count falls right after an upgrade. Orange from the threshold
|
# Entries already installed are dropped, so the count falls right after an upgrade. Orange from the threshold
|
||||||
# on, red "K" when a custom kernel needs a rebuild.
|
# on, red "K" when a custom kernel needs a rebuild, red "R" when a reboot is needed, blue "P" for .pacnew files.
|
||||||
# With "list": show the pending packages in a notification (for a click on the bar)
|
# With "list": show the pending packages in a notification (for a click on the bar)
|
||||||
|
|
||||||
file="${XDG_STATE_HOME:-$HOME/.local/state}/update-notify/pending"
|
file="${XDG_STATE_HOME:-$HOME/.local/state}/update-notify/pending"
|
||||||
@@ -11,7 +11,7 @@ mapfile -t entries < "$file"
|
|||||||
names=()
|
names=()
|
||||||
for e in "${entries[@]}"; do
|
for e in "${entries[@]}"; do
|
||||||
read -r src pkg _ <<< "$e"
|
read -r src pkg _ <<< "$e"
|
||||||
[[ $src != threshold ]] && names+=("$pkg")
|
case $src in repo|aur|kernel) names+=("$pkg") ;; esac
|
||||||
done
|
done
|
||||||
|
|
||||||
declare -A installed
|
declare -A installed
|
||||||
@@ -21,10 +21,15 @@ if (( ${#names[@]} )); then
|
|||||||
done < <(pacman -Q "${names[@]}" 2>/dev/null)
|
done < <(pacman -Q "${names[@]}" 2>/dev/null)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
threshold=0 repo=() aur=() kernel=()
|
threshold=0 repo=() aur=() kernel=() pacnew=() reboot=""
|
||||||
|
running=$(uname -r)
|
||||||
for e in "${entries[@]}"; do
|
for e in "${entries[@]}"; do
|
||||||
read -r src pkg new <<< "$e"
|
read -r src pkg new <<< "$e"
|
||||||
[[ $src == threshold ]] && { threshold=$pkg; continue; }
|
case $src in
|
||||||
|
threshold) threshold=$pkg; continue ;;
|
||||||
|
pacnew) [[ -e ${e#pacnew } ]] && pacnew+=("${e#pacnew }"); continue ;; # gone once merged
|
||||||
|
reboot) [[ $pkg == "$running" ]] && reboot=$pkg; continue ;; # gone after the reboot
|
||||||
|
esac
|
||||||
have=${installed[$pkg]:-}
|
have=${installed[$pkg]:-}
|
||||||
[[ -z $have ]] && continue # removed since the last run
|
[[ -z $have ]] && continue # removed since the last run
|
||||||
case $src in
|
case $src in
|
||||||
@@ -39,14 +44,19 @@ if [[ ${1:-} == list ]]; then
|
|||||||
(( ${#repo[@]} )) && { printf -v l '%s\n' "${repo[@]}"; body+="Repo:"$'\n'"$l"; }
|
(( ${#repo[@]} )) && { printf -v l '%s\n' "${repo[@]}"; body+="Repo:"$'\n'"$l"; }
|
||||||
(( ${#aur[@]} )) && { printf -v l '%s\n' "${aur[@]}"; body+="AUR:"$'\n'"$l"; }
|
(( ${#aur[@]} )) && { printf -v l '%s\n' "${aur[@]}"; body+="AUR:"$'\n'"$l"; }
|
||||||
(( ${#kernel[@]} )) && { printf -v l 'Rebuild %s\n' "${kernel[@]}"; body+="$l"; }
|
(( ${#kernel[@]} )) && { printf -v l 'Rebuild %s\n' "${kernel[@]}"; body+="$l"; }
|
||||||
|
(( ${#pacnew[@]} )) && { printf -v l '%s\n' "${pacnew[@]}"; body+="Merge with pacdiff:"$'\n'"$l"; }
|
||||||
|
[[ -n $reboot ]] && body+="Reboot (running $reboot)"$'\n'
|
||||||
body=${body%$'\n'}
|
body=${body%$'\n'}
|
||||||
notify-send "Pending updates" "${body:-None}"
|
notify-send "Pending updates" "${body:-None}"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
total=$(( ${#repo[@]} + ${#aur[@]} ))
|
total=$(( ${#repo[@]} + ${#aur[@]} ))
|
||||||
(( total + ${#kernel[@]} )) || exit 0
|
(( total + ${#kernel[@]} + ${#pacnew[@]} )) || [[ -n $reboot ]] || exit 0
|
||||||
text=$'\xef\x92\x87'" ${#repo[@]}/${#aur[@]}" # nf-oct-package, as UTF-8 bytes so the locale doesn't matter
|
text=$'\xef\x92\x87' # nf-oct-package, as UTF-8 bytes so the locale doesn't matter
|
||||||
(( total >= threshold )) && text="<fc=#ffb86c>$text</fc>"
|
(( total )) && text+=" ${#repo[@]}/${#aur[@]}" # markers alone: no "0/0"
|
||||||
|
(( total && total >= threshold )) && text="<fc=#ffb86c>$text</fc>"
|
||||||
(( ${#kernel[@]} )) && text+=" <fc=#f7768e>K</fc>"
|
(( ${#kernel[@]} )) && text+=" <fc=#f7768e>K</fc>"
|
||||||
|
[[ -n $reboot ]] && text+=" <fc=#f7768e>R</fc>"
|
||||||
|
(( ${#pacnew[@]} )) && text+=" <fc=#7aa2f7>P</fc>"
|
||||||
echo "$text | "
|
echo "$text | "
|
||||||
Executable
+81
@@ -0,0 +1,81 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# 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
|
||||||
|
|
||||||
|
declare -A ICON=(
|
||||||
|
[thermometer]=$'\xef\x8b\x89' [day_sunny]=$'\xee\x8c\x8d' [night_clear]=$'\xee\x8c\xab'
|
||||||
|
[day_cloudy]=$'\xee\x8c\x82' [night_partly_cloudy]=$'\xee\x8d\xb9' [day_sunny_overcast]=$'\xee\x8c\x8c'
|
||||||
|
[night_cloudy]=$'\xee\x8d\xbe' [cloudy]=$'\xee\x8c\x92' [cloud]=$'\xee\x8c\xbd'
|
||||||
|
[thunderstorm]=$'\xee\x8c\x9d' [rain_mix]=$'\xee\x8c\x96' [snow]=$'\xee\x8c\x9a' [showers]=$'\xee\x8c\x99'
|
||||||
|
[rain]=$'\xee\x8c\x98' [sprinkle]=$'\xee\x8c\x9b' [fog]=$'\xee\x8c\x93' [smoke]=$'\xee\x8d\x9c'
|
||||||
|
[dust]=$'\xee\x8d\x9d'
|
||||||
|
)
|
||||||
|
|
||||||
|
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 "<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' | 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
|
||||||
|
sun_up() {
|
||||||
|
awk -v t="$(date +%s)" -v lat="$LAT" -v lon="$LON" 'BEGIN {
|
||||||
|
r = atan2(0, -1) / 180; d = t / 86400 - 10957.5
|
||||||
|
g = (357.529 + 0.98560028 * d) * r
|
||||||
|
l = (280.459 + 0.98564736 * d + 1.915 * sin(g) + 0.020 * sin(2 * g)) * r
|
||||||
|
e = (23.439 - 0.00000036 * d) * r
|
||||||
|
ra = atan2(cos(e) * sin(l), cos(l)); s = sin(e) * sin(l); dec = atan2(s, sqrt(1 - s * s))
|
||||||
|
h = (280.46061837 + 360.98564736629 * d + lon) * r - ra
|
||||||
|
exit !(sin(lat * r) * sin(dec) + cos(lat * r) * cos(dec) * cos(h) > sin(-0.833 * r))
|
||||||
|
}'
|
||||||
|
}
|
||||||
|
|
||||||
|
case $wx in
|
||||||
|
*thunder*) icon=thunderstorm ;;
|
||||||
|
*freezing*|*sleet*|*ice\ pellets*|*hail*) icon=rain_mix ;;
|
||||||
|
*snow*rain*|*rain*snow*|*snow*drizzle*|*drizzle*snow*) icon=rain_mix ;;
|
||||||
|
*snow*) icon=snow ;;
|
||||||
|
*showers*) icon=showers ;;
|
||||||
|
*rain*) icon=rain ;;
|
||||||
|
*drizzle*) icon=sprinkle ;;
|
||||||
|
*fog*|*mist*) icon=fog ;;
|
||||||
|
*haze*|*smoke*) icon=smoke ;;
|
||||||
|
*dust*|*sand*) icon=dust ;;
|
||||||
|
*)
|
||||||
|
case $sky in
|
||||||
|
clear*) if sun_up; then icon=day_sunny; else icon=night_clear; fi ;;
|
||||||
|
"mostly clear"*|"partly cloudy"*) if sun_up; then icon=day_cloudy; else icon=night_partly_cloudy; fi ;;
|
||||||
|
"mostly cloudy"*) if sun_up; then icon=day_sunny_overcast; else icon=night_cloudy; fi ;;
|
||||||
|
overcast*|obscured*) icon=cloudy ;;
|
||||||
|
*) icon=cloud ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
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
|
Config { overrideRedirect = True
|
||||||
, lowerOnStart = True
|
, lowerOnStart = True
|
||||||
, font = "Jetbrains Mono Nerd Font Bold 10"
|
, font = "Jetbrains Mono Nerd Font Bold 10"
|
||||||
|
, additionalFonts = ["Jetbrains Mono Nerd Font Bold 13"]
|
||||||
, bgColor = "#24283b"
|
, bgColor = "#24283b"
|
||||||
, fgColor = "#737aa2"
|
, fgColor = "#737aa2"
|
||||||
, position = TopH 24
|
, position = TopH 24
|
||||||
@@ -8,14 +9,7 @@ Config { overrideRedirect = True
|
|||||||
, borderColor = "#24283b"
|
, borderColor = "#24283b"
|
||||||
, allDesktops = True
|
, allDesktops = True
|
||||||
, pickBroadest = True
|
, pickBroadest = True
|
||||||
, commands = [ Run Weather "LZIB"
|
, commands = [ Run Com "/home/fuxino/.config/xmobar/weather.sh" [] "weather" 9000
|
||||||
[ "--template", "\xf2c9 <tempC>°C"
|
|
||||||
, "-L", "5"
|
|
||||||
, "-H", "25"
|
|
||||||
, "--low" , "#8be9fd"
|
|
||||||
, "--normal" , "#50fa7b"
|
|
||||||
, "--high" , "#ff5555"
|
|
||||||
] 9000
|
|
||||||
, Run MultiCpu
|
, Run MultiCpu
|
||||||
[ "--template" , "\xf4bc <total>%"
|
[ "--template" , "\xf4bc <total>%"
|
||||||
, "--Low" , "25"
|
, "--Low" , "25"
|
||||||
@@ -26,16 +20,17 @@ Config { overrideRedirect = True
|
|||||||
] 10
|
] 10
|
||||||
, Run CoreTemp
|
, Run CoreTemp
|
||||||
[ "--template" , "<core0>°C"
|
[ "--template" , "<core0>°C"
|
||||||
, "--Low" , "60"
|
, "--Low" , "70"
|
||||||
, "--High" , "85"
|
, "--High" , "90"
|
||||||
, "--low" , "#50fa7b"
|
, "--low" , "#50fa7b"
|
||||||
, "--normal" , "#ffb86c"
|
, "--normal" , "#ffb86c"
|
||||||
, "--high" , "#ff5555"
|
, "--high" , "#ff5555"
|
||||||
] 50
|
] 50
|
||||||
|
, Run Com "/home/fuxino/.config/xmobar/gpu.sh" [] "gpu" 50
|
||||||
, Run Memory
|
, Run Memory
|
||||||
[ "--template" , "\xefc5 <usedratio>%"
|
[ "--template" , "\xefc5 <usedratio>%"
|
||||||
, "--Low" , "33"
|
, "--Low" , "50"
|
||||||
, "--High" , "66"
|
, "--High" , "80"
|
||||||
, "--low" , "#50fa7b"
|
, "--low" , "#50fa7b"
|
||||||
, "--normal" , "#ffb86c"
|
, "--normal" , "#ffb86c"
|
||||||
, "--high" , "#ff5555"
|
, "--high" , "#ff5555"
|
||||||
@@ -45,17 +40,15 @@ Config { overrideRedirect = True
|
|||||||
, ("us" , "<fc=#ffb86c>US</fc>")
|
, ("us" , "<fc=#ffb86c>US</fc>")
|
||||||
, ("sk(qwerty)" , "<fc=#ff5555>SK</fc>")
|
, ("sk(qwerty)" , "<fc=#ff5555>SK</fc>")
|
||||||
]
|
]
|
||||||
, Run Date "\xf133 %a %Y-%m-%d <fc=#ff79c6>%H:%M</fc>" "date" 10
|
, Run Date "\xf133 %a %d/%m <fc=#ff79c6>%H:%M</fc>" "date" 10
|
||||||
, Run Uptime
|
|
||||||
[ "--template" , "\xf017 <days>d <hours>h"
|
|
||||||
] 600
|
|
||||||
, Run Com "/home/fuxino/.config/xmobar/pactl_volume.sh" [] "pactl_volume" 10
|
, Run Com "/home/fuxino/.config/xmobar/pactl_volume.sh" [] "pactl_volume" 10
|
||||||
, Run Com "/home/fuxino/.config/xmobar/ens_brief.sh" [] "ens_brief" 18000
|
, Run Com "/home/fuxino/.config/xmobar/ens_brief.sh" [] "ens_brief" 18000
|
||||||
, Run Com "/home/fuxino/.config/xmobar/updates.sh" [] "updates" 600
|
, Run Com "/home/fuxino/.config/xmobar/updates.sh" [] "updates" 600
|
||||||
, Run Com "/home/fuxino/.config/xmobar/backup.sh" [] "backup" 3600
|
, Run Com "/home/fuxino/.config/xmobar/backup.sh" [] "backup" 3600
|
||||||
|
, Run Com "/home/fuxino/.config/xmobar/calcurse.sh" [] "calcurse" 600
|
||||||
, Run UnsafeXMonadLog
|
, Run UnsafeXMonadLog
|
||||||
]
|
]
|
||||||
, sepChar = "%"
|
, sepChar = "%"
|
||||||
, alignSep = "}{"
|
, alignSep = "}{"
|
||||||
, template = " | %UnsafeXMonadLog% } %uptime% | %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/backup.sh list`>%backup%</action><action=`/home/fuxino/.config/xmobar/updates.sh list`>%updates%</action><action=`/home/fuxino/.config/xmobar/ens_brief.sh week`>%LZIB% <fc=#565f89>·</fc> %ens_brief%</action> | %pactl_volume% | <action=`gsimplecal`>%date%</action> "
|
, 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% "
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
Config { overrideRedirect = True
|
Config { overrideRedirect = True
|
||||||
, lowerOnStart = True
|
, lowerOnStart = True
|
||||||
, font = "Jetbrains Mono Nerd Font Bold 10"
|
, font = "Jetbrains Mono Nerd Font Bold 10"
|
||||||
|
, additionalFonts = ["Jetbrains Mono Nerd Font Bold 13"]
|
||||||
, bgColor = "#24283b"
|
, bgColor = "#24283b"
|
||||||
, fgColor = "#737aa2"
|
, fgColor = "#737aa2"
|
||||||
, position = TopH 24
|
, position = TopH 24
|
||||||
@@ -8,14 +9,7 @@ Config { overrideRedirect = True
|
|||||||
, borderColor = "#24283b"
|
, borderColor = "#24283b"
|
||||||
, allDesktops = True
|
, allDesktops = True
|
||||||
, pickBroadest = True
|
, pickBroadest = True
|
||||||
, commands = [ Run Weather "LZIB"
|
, commands = [ Run Com "/home/fuxino/.config/xmobar/weather.sh" [] "weather" 9000
|
||||||
[ "--template", "\xf2c9 <tempC>°C"
|
|
||||||
, "-L", "5"
|
|
||||||
, "-H", "25"
|
|
||||||
, "--low" , "#8be9fd"
|
|
||||||
, "--normal" , "#50fa7b"
|
|
||||||
, "--high" , "#ff5555"
|
|
||||||
] 9000
|
|
||||||
, Run MultiCpu
|
, Run MultiCpu
|
||||||
[ "--template" , "\xf4bc <total>%"
|
[ "--template" , "\xf4bc <total>%"
|
||||||
, "--Low" , "25"
|
, "--Low" , "25"
|
||||||
@@ -26,16 +20,17 @@ Config { overrideRedirect = True
|
|||||||
] 10
|
] 10
|
||||||
, Run CoreTemp
|
, Run CoreTemp
|
||||||
[ "--template" , "<core0>°C"
|
[ "--template" , "<core0>°C"
|
||||||
, "--Low" , "60"
|
, "--Low" , "70"
|
||||||
, "--High" , "85"
|
, "--High" , "90"
|
||||||
, "--low" , "#50fa7b"
|
, "--low" , "#50fa7b"
|
||||||
, "--normal" , "#ffb86c"
|
, "--normal" , "#ffb86c"
|
||||||
, "--high" , "#ff5555"
|
, "--high" , "#ff5555"
|
||||||
] 50
|
] 50
|
||||||
|
, Run Com "/home/fuxino/.config/xmobar/gpu.sh" [] "gpu" 50
|
||||||
, Run Memory
|
, Run Memory
|
||||||
[ "--template" , "\xefc5 <usedratio>%"
|
[ "--template" , "\xefc5 <usedratio>%"
|
||||||
, "--Low" , "33"
|
, "--Low" , "50"
|
||||||
, "--High" , "66"
|
, "--High" , "80"
|
||||||
, "--low" , "#50fa7b"
|
, "--low" , "#50fa7b"
|
||||||
, "--normal" , "#ffb86c"
|
, "--normal" , "#ffb86c"
|
||||||
, "--high" , "#ff5555"
|
, "--high" , "#ff5555"
|
||||||
@@ -45,18 +40,16 @@ Config { overrideRedirect = True
|
|||||||
, ("us" , "<fc=#ffb86c>US</fc>")
|
, ("us" , "<fc=#ffb86c>US</fc>")
|
||||||
, ("sk(qwerty)" , "<fc=#ff5555>SK</fc>")
|
, ("sk(qwerty)" , "<fc=#ff5555>SK</fc>")
|
||||||
]
|
]
|
||||||
, Run Date "\xf133 %a %Y-%m-%d <fc=#ff79c6>%H:%M</fc>" "date" 10
|
, Run Date "\xf133 %a %d/%m <fc=#ff79c6>%H:%M</fc>" "date" 10
|
||||||
, Run Uptime
|
|
||||||
[ "--template" , "\xf017 <days>d <hours>h"
|
|
||||||
] 600
|
|
||||||
, Run XPropertyLog "_XMONAD_TRAYPAD"
|
, Run XPropertyLog "_XMONAD_TRAYPAD"
|
||||||
, Run Com "/home/fuxino/.config/xmobar/pactl_volume.sh" [] "pactl_volume" 10
|
, Run Com "/home/fuxino/.config/xmobar/pactl_volume.sh" [] "pactl_volume" 10
|
||||||
, Run Com "/home/fuxino/.config/xmobar/ens_brief.sh" [] "ens_brief" 18000
|
, Run Com "/home/fuxino/.config/xmobar/ens_brief.sh" [] "ens_brief" 18000
|
||||||
, Run Com "/home/fuxino/.config/xmobar/updates.sh" [] "updates" 600
|
, Run Com "/home/fuxino/.config/xmobar/updates.sh" [] "updates" 600
|
||||||
, Run Com "/home/fuxino/.config/xmobar/backup.sh" [] "backup" 3600
|
, Run Com "/home/fuxino/.config/xmobar/backup.sh" [] "backup" 3600
|
||||||
|
, Run Com "/home/fuxino/.config/xmobar/calcurse.sh" [] "calcurse" 600
|
||||||
, Run UnsafeXMonadLog
|
, Run UnsafeXMonadLog
|
||||||
]
|
]
|
||||||
, sepChar = "%"
|
, sepChar = "%"
|
||||||
, alignSep = "}{"
|
, alignSep = "}{"
|
||||||
, template = " | %UnsafeXMonadLog% } %uptime% | %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/backup.sh list`>%backup%</action><action=`/home/fuxino/.config/xmobar/updates.sh list`>%updates%</action><action=`/home/fuxino/.config/xmobar/ens_brief.sh week`>%LZIB% <fc=#565f89>·</fc> %ens_brief%</action> | %pactl_volume% | <action=`gsimplecal`>%date%</action> %_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% "
|
||||||
}
|
}
|
||||||
+144
-81
@@ -1,11 +1,13 @@
|
|||||||
-- Import
|
-- Import
|
||||||
|
|
||||||
import Data.Monoid
|
import Data.Monoid
|
||||||
|
import Data.Bits (complement, (.&.))
|
||||||
import Data.Char (toLower)
|
import Data.Char (toLower)
|
||||||
import Control.Monad (forM_, liftM2, when)
|
import Control.Monad (filterM, forM_, join, unless, when)
|
||||||
|
import qualified Data.Map.Strict as M
|
||||||
import Data.Maybe (isJust)
|
import Data.Maybe (isJust)
|
||||||
import XMonad
|
import XMonad
|
||||||
import XMonad.Actions.OnScreen (greedyViewOnScreen)
|
import XMonad.Actions.OnScreen (Focus (FocusNew), onScreen)
|
||||||
import XMonad.Actions.PhysicalScreens
|
import XMonad.Actions.PhysicalScreens
|
||||||
import XMonad.Hooks.EwmhDesktops
|
import XMonad.Hooks.EwmhDesktops
|
||||||
import XMonad.Hooks.ManageDocks
|
import XMonad.Hooks.ManageDocks
|
||||||
@@ -13,6 +15,7 @@ import XMonad.Hooks.ManageHelpers
|
|||||||
import XMonad.Hooks.Rescreen
|
import XMonad.Hooks.Rescreen
|
||||||
import XMonad.Hooks.StatusBar
|
import XMonad.Hooks.StatusBar
|
||||||
import XMonad.Hooks.StatusBar.PP
|
import XMonad.Hooks.StatusBar.PP
|
||||||
|
import XMonad.Hooks.UrgencyHook (NoUrgencyHook (..), withUrgencyHook)
|
||||||
import XMonad.Layout.Grid
|
import XMonad.Layout.Grid
|
||||||
import XMonad.Layout.Magnifier
|
import XMonad.Layout.Magnifier
|
||||||
import XMonad.Layout.NoBorders
|
import XMonad.Layout.NoBorders
|
||||||
@@ -25,6 +28,7 @@ import XMonad.Layout.ThreeColumns
|
|||||||
import qualified XMonad.StackSet as W
|
import qualified XMonad.StackSet as W
|
||||||
import XMonad.Util.ClickableWorkspaces
|
import XMonad.Util.ClickableWorkspaces
|
||||||
import XMonad.Util.EZConfig
|
import XMonad.Util.EZConfig
|
||||||
|
import qualified XMonad.Util.ExtensibleState as XS
|
||||||
import qualified XMonad.Util.Hacks as Hacks
|
import qualified XMonad.Util.Hacks as Hacks
|
||||||
import XMonad.Util.Loggers
|
import XMonad.Util.Loggers
|
||||||
import XMonad.Util.NamedActions
|
import XMonad.Util.NamedActions
|
||||||
@@ -38,9 +42,11 @@ main :: IO ()
|
|||||||
main =
|
main =
|
||||||
xmonad
|
xmonad
|
||||||
. ewmhFullscreen
|
. ewmhFullscreen
|
||||||
|
. setEwmhFullscreenHooks myFullscreenHook myUnfullscreenHook
|
||||||
. setEwmhSwitchDesktopHook safeView
|
. setEwmhSwitchDesktopHook safeView
|
||||||
. ewmh
|
. ewmh
|
||||||
. docks
|
. docks
|
||||||
|
. withUrgencyHook NoUrgencyHook
|
||||||
. rescreenHook def {afterRescreenHook = restartStatusBars, rescreenWorkspacesHook = Last (Just safeRescreen)}
|
. rescreenHook def {afterRescreenHook = restartStatusBars, rescreenWorkspacesHook = Last (Just safeRescreen)}
|
||||||
. addRandrChangeHook (spawn myScreenHotplug)
|
. addRandrChangeHook (spawn myScreenHotplug)
|
||||||
$ myConfig
|
$ myConfig
|
||||||
@@ -61,17 +67,12 @@ myNormBorderColor = "#1f2335"
|
|||||||
myFocusBorderColor :: String
|
myFocusBorderColor :: String
|
||||||
myFocusBorderColor = "#41a6b5"
|
myFocusBorderColor = "#41a6b5"
|
||||||
|
|
||||||
myKeyboardLayoutIT :: String
|
myEarbuds :: String
|
||||||
myKeyboardLayoutIT = " -layout it"
|
myEarbuds = "F4:9D:8A:B9:8C:EE"
|
||||||
|
|
||||||
myKeyboardLayoutUS :: String
|
|
||||||
myKeyboardLayoutUS = " -layout us"
|
|
||||||
|
|
||||||
myKeyboardLayoutSK :: String
|
|
||||||
myKeyboardLayoutSK = " -layout sk -variant qwerty"
|
|
||||||
|
|
||||||
|
-- Expanded by sh, as spawn runs it
|
||||||
myScreenshotDir :: String
|
myScreenshotDir :: String
|
||||||
myScreenshotDir = "/home/fuxino/Pictures/Screenshots/"
|
myScreenshotDir = "~/Pictures/Screenshots/"
|
||||||
|
|
||||||
myScreenshotName :: String
|
myScreenshotName :: String
|
||||||
myScreenshotName = "Screenshot-%Y-%m-%d-%H%M%S.png"
|
myScreenshotName = "Screenshot-%Y-%m-%d-%H%M%S.png"
|
||||||
@@ -80,30 +81,29 @@ myScreenshotName = "Screenshot-%Y-%m-%d-%H%M%S.png"
|
|||||||
myScreenLayout :: String
|
myScreenLayout :: String
|
||||||
myScreenLayout = "/home/fuxino/.local/bin/screen-layout"
|
myScreenLayout = "/home/fuxino/.local/bin/screen-layout"
|
||||||
|
|
||||||
-- Safe to re-run (e.g. spawnOnce after this string changes and xmonad restarts)
|
-- Safe to re-run (e.g. spawnOnce after this string changes and xmonad restarts); keeps the last wallpapers across logins
|
||||||
myScreenSetup :: String
|
myScreenSetup :: String
|
||||||
myScreenSetup =
|
myScreenSetup =
|
||||||
"sleep 1; " ++ myScreenLayout ++ "; pgrep -x picom > /dev/null || picom -b -c"
|
"sleep 1; " ++ myScreenLayout ++ " --keep-wallpaper; pgrep -x picom > /dev/null || picom -b -c"
|
||||||
|
|
||||||
-- Run when a monitor is (dis)connected; restarts trayer so it moves to the right screen
|
-- Run when a monitor is (dis)connected; restarts trayer so it moves to the right screen
|
||||||
myScreenHotplug :: String
|
myScreenHotplug :: String
|
||||||
myScreenHotplug = myScreenLayout
|
myScreenHotplug = myScreenLayout ++ " --keep-wallpaper"
|
||||||
|
|
||||||
myScratchpads :: [NamedScratchpad]
|
myScratchpads :: [NamedScratchpad]
|
||||||
myScratchpads =
|
myScratchpads =
|
||||||
[ NS "Riseup-vpn" "riseup-vpn" (className =? "RiseupVPN") (customFloating $ W.RationalRect 0.15 0.4 0.15 0.4),
|
[ NS "Windscribe" "windscribe" (className =? "Windscribe2") (customFloating $ W.RationalRect 0.15 0.4 0.15 0.4),
|
||||||
NS "Terminal" spawnTerminal (className =? "scratch-terminal") (customFloating $ W.RationalRect 0.2 0.2 0.6 0.6),
|
termPad "Terminal" "kitty-float" "",
|
||||||
NS "Music" spawnMusic (className =? "scratch-music") (customFloating $ W.RationalRect 0.2 0.2 0.6 0.6),
|
termPad "Music" "ncmpcpp" "ncmpcpp",
|
||||||
NS "Mail" spawnMail (className =? "scratch-mail") (customFloating $ W.RationalRect 0.2 0.2 0.6 0.6),
|
termPad "Mail" "mutt" "bash -c 'pushd ~/Downloads > /dev/null; mutt; popd > /dev/null'",
|
||||||
NS "Cal" spawnCal (className =? "scratch-cal") (customFloating $ W.RationalRect 0.2 0.2 0.6 0.6),
|
termPad "Cal" "calcurse" "calcurse",
|
||||||
NS "Btop" spawnBtop (className =? "scratch-btop") (customFloating $ W.RationalRect 0.2 0.2 0.6 0.6)
|
termPad "Btop" "btop" "btop"
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
spawnTerminal = myTerminal ++ " --class scratch-terminal -T kitty-float"
|
-- Centred kitty with class scratch-<name>, window title t, running cmd
|
||||||
spawnMusic = myTerminal ++ " --class scratch-music -T ncmpcpp ncmpcpp"
|
termPad name t cmd =
|
||||||
spawnMail = myTerminal ++ " --class scratch-mail -T mutt bash -c 'pushd ~/Downloads > /dev/null; mutt; popd > /dev/null'"
|
let cls = "scratch-" ++ map toLower name
|
||||||
spawnCal = myTerminal ++ " --class scratch-cal -T calcurse calcurse"
|
in NS name (unwords [myTerminal, "--class", cls, "-T", t, cmd]) (className =? cls) (customFloating $ W.RationalRect 0.2 0.2 0.6 0.6)
|
||||||
spawnBtop = myTerminal ++ " --class scratch-btop -T btop btop"
|
|
||||||
|
|
||||||
-- Config
|
-- Config
|
||||||
myConfig =
|
myConfig =
|
||||||
@@ -149,7 +149,7 @@ myCustomKeys c =
|
|||||||
[ ("M-S-s", addName "Terminal" $ namedScratchpadAction myScratchpads "Terminal"),
|
[ ("M-S-s", addName "Terminal" $ namedScratchpadAction myScratchpads "Terminal"),
|
||||||
("M-S-a", addName "Calendar (calcurse)" $ namedScratchpadAction myScratchpads "Cal"),
|
("M-S-a", addName "Calendar (calcurse)" $ namedScratchpadAction myScratchpads "Cal"),
|
||||||
("M-o", addName "btop" $ namedScratchpadAction myScratchpads "Btop"),
|
("M-o", addName "btop" $ namedScratchpadAction myScratchpads "Btop"),
|
||||||
("M-S-v", addName "RiseupVPN" $ namedScratchpadAction myScratchpads "Riseup-vpn"),
|
("M-S-v", addName "Windscribe VPN" $ namedScratchpadAction myScratchpads "Windscribe"),
|
||||||
("<XF86Mail>", addName "Mail (mutt)" $ namedScratchpadAction myScratchpads "Mail"),
|
("<XF86Mail>", addName "Mail (mutt)" $ namedScratchpadAction myScratchpads "Mail"),
|
||||||
("<XF86Tools>", addName "Music (ncmpcpp)" $ namedScratchpadAction myScratchpads "Music")
|
("<XF86Tools>", addName "Music (ncmpcpp)" $ namedScratchpadAction myScratchpads "Music")
|
||||||
]
|
]
|
||||||
@@ -160,11 +160,11 @@ myCustomKeys c =
|
|||||||
("M-C-n", addName "Close all notifications" $ spawn "dunstctl close-all"),
|
("M-C-n", addName "Close all notifications" $ spawn "dunstctl close-all"),
|
||||||
("M-b", addName "Toggle the status bar gap" $ sendMessage ToggleStruts),
|
("M-b", addName "Toggle the status bar gap" $ sendMessage ToggleStruts),
|
||||||
("M-f", addName "Tabbed layout" $ sendMessage $ JumpToLayout "Tabbed"),
|
("M-f", addName "Tabbed layout" $ sendMessage $ JumpToLayout "Tabbed"),
|
||||||
("M-i", addName "Keyboard: Italian" $ spawn $ "setxkbmap" ++ myKeyboardLayoutIT),
|
("M-i", addName "Keyboard: Italian" $ spawn "setxkbmap -layout it"),
|
||||||
("M-u", addName "Keyboard: US" $ spawn $ "setxkbmap" ++ myKeyboardLayoutUS),
|
("M-u", addName "Keyboard: US" $ spawn "setxkbmap -layout us"),
|
||||||
("M-s", addName "Keyboard: Slovak" $ spawn $ "setxkbmap" ++ myKeyboardLayoutSK),
|
("M-s", addName "Keyboard: Slovak" $ spawn "setxkbmap -layout sk -variant qwerty"),
|
||||||
("M-x", addName "Connect earbuds" $ spawn "bluetoothctl connect F4:9D:8A:B9:8C:EE"),
|
("M-x", addName "Connect earbuds" $ spawn $ "bluetoothctl connect " ++ myEarbuds),
|
||||||
("M-S-x", addName "Disconnect earbuds" $ spawn "bluetoothctl disconnect F4:9D:8A:B9:8C:EE")
|
("M-S-x", addName "Disconnect earbuds" $ spawn $ "bluetoothctl disconnect " ++ myEarbuds)
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
( "screenshots",
|
( "screenshots",
|
||||||
@@ -174,8 +174,8 @@ myCustomKeys c =
|
|||||||
]
|
]
|
||||||
),
|
),
|
||||||
( "media keys",
|
( "media keys",
|
||||||
[ ("<XF86AudioMute>", addName "Mute" $ spawn "pactl set-sink-mute $(pactl get-default-sink) toggle"),
|
[ ("<XF86AudioMute>", addName "Mute" $ spawn "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"),
|
||||||
("<XF86AudioLowerVolume>", addName "Volume down" $ spawn "pactl set-sink-volume $(pactl get-default-sink) -10%"),
|
("<XF86AudioLowerVolume>", addName "Volume down" $ spawn "wpctl set-volume @DEFAULT_AUDIO_SINK@ 10%-"),
|
||||||
("<XF86AudioRaiseVolume>", addName "Volume up" $ spawn "wpctl set-volume -l 1.0 @DEFAULT_AUDIO_SINK@ 10%+"),
|
("<XF86AudioRaiseVolume>", addName "Volume up" $ spawn "wpctl set-volume -l 1.0 @DEFAULT_AUDIO_SINK@ 10%+"),
|
||||||
("<XF86AudioPlay>", addName "Play/pause" $ spawn "playerctl play-pause"),
|
("<XF86AudioPlay>", addName "Play/pause" $ spawn "playerctl play-pause"),
|
||||||
("<XF86AudioPause>", addName "Pause" $ spawn "playerctl pause"),
|
("<XF86AudioPause>", addName "Pause" $ spawn "playerctl pause"),
|
||||||
@@ -210,10 +210,10 @@ showKeys ks = addName "Show keybindings" $ do
|
|||||||
fixMod (x : r) = x : fixMod r
|
fixMod (x : r) = x : fixMod r
|
||||||
fixMod [] = []
|
fixMod [] = []
|
||||||
|
|
||||||
-- greedyView that keeps wsGames on screen 0 (HDMI): Wine games lose the mouse when moved between screens
|
-- greedyView that keeps wsGames on screen 0 (HDMI), and focuses it: Wine games lose the mouse when moved between screens
|
||||||
safeView :: WorkspaceId -> WindowSet -> WindowSet
|
safeView :: WorkspaceId -> WindowSet -> WindowSet
|
||||||
safeView i ws
|
safeView i ws
|
||||||
| i == wsGames = greedyViewOnScreen 0 i ws
|
| i == wsGames = onScreen (W.greedyView i) FocusNew 0 ws
|
||||||
| W.currentTag ws == wsGames && i `elem` map (W.tag . W.workspace) (W.visible ws) = W.view i ws
|
| W.currentTag ws == wsGames && i `elem` map (W.tag . W.workspace) (W.visible ws) = W.view i ws
|
||||||
| otherwise = W.greedyView i ws
|
| otherwise = W.greedyView i ws
|
||||||
|
|
||||||
@@ -237,7 +237,7 @@ safeRescreen = do
|
|||||||
|
|
||||||
-- Workspaces
|
-- Workspaces
|
||||||
myWorkspaces :: [String]
|
myWorkspaces :: [String]
|
||||||
myWorkspaces = [wsTerm, wsWeb, wsGames, wsChat, wsMedia, wsDocs, wsVM] ++ map show [8, 9]
|
myWorkspaces = [wsTerm, wsWeb, wsGames, wsChat, wsMedia, wsDocs, wsVM] ++ map show [8, 9 :: Int]
|
||||||
|
|
||||||
-- Icons spill past their advance in the non-Mono Nerd Font: keep them ~1000-1160 units wide or gaps look uneven
|
-- Icons spill past their advance in the non-Mono Nerd Font: keep them ~1000-1160 units wide or gaps look uneven
|
||||||
wsTerm, wsWeb, wsGames, wsChat, wsMedia, wsDocs, wsVM :: String
|
wsTerm, wsWeb, wsGames, wsChat, wsMedia, wsDocs, wsVM :: String
|
||||||
@@ -250,12 +250,15 @@ wsDocs = "6:\xede2 "
|
|||||||
wsVM = "7:\xf108 "
|
wsVM = "7:\xf108 "
|
||||||
|
|
||||||
-- Layout
|
-- Layout
|
||||||
myLayoutHook = onWorkspace wsWeb myWebLayout $ onWorkspace wsGames myGamesLayout $ onWorkspace wsMedia myVideoLayout myDefaultLayout
|
myLayoutHook =
|
||||||
|
avoidStruts $
|
||||||
|
onWorkspaces [wsGames, wsMedia] (smartBorders Full) $
|
||||||
|
onWorkspace wsWeb (spaced $ myTabbed ||| tiled ||| Mirror tiled ||| others) $
|
||||||
|
spaced (tiled ||| Mirror tiled ||| myTabbed ||| others)
|
||||||
where
|
where
|
||||||
myWebLayout = avoidStruts $ renamed [CutWordsLeft 1] $ spacingWithEdge 3 $ myTabbed ||| tiled ||| Mirror tiled ||| threeCol ||| Grid ||| spiral 0.856
|
-- CutWordsLeft drops the "Spacing" prefix from the layout names
|
||||||
myGamesLayout = avoidStruts $ smartBorders Full
|
spaced l = renamed [CutWordsLeft 1] $ spacingWithEdge 3 l
|
||||||
myVideoLayout = avoidStruts $ smartBorders Full
|
others = threeCol ||| Grid ||| spiral 0.856
|
||||||
myDefaultLayout = avoidStruts $ renamed [CutWordsLeft 1] $ spacingWithEdge 3 $ tiled ||| Mirror tiled ||| myTabbed ||| threeCol ||| Grid ||| spiral 0.856
|
|
||||||
threeCol =
|
threeCol =
|
||||||
renamed [Replace "ThreeCol"] $
|
renamed [Replace "ThreeCol"] $
|
||||||
magnifiercz' 1.3 $
|
magnifiercz' 1.3 $
|
||||||
@@ -305,11 +308,16 @@ myXmobarPP =
|
|||||||
_ -> tag,
|
_ -> tag,
|
||||||
-- NamedScratchpad never removes NSP once created; hide it while it's empty
|
-- NamedScratchpad never removes NSP once created; hide it while it's empty
|
||||||
ppSort = (. filter (\w -> W.tag w /= scratchpadWorkspaceTag || isJust (W.stack w))) <$> ppSort def,
|
ppSort = (. filter (\w -> W.tag w /= scratchpadWorkspaceTag || isJust (W.stack w))) <$> ppSort def,
|
||||||
ppOrder = \[ws, l, _, wins] -> [ws, l, wins],
|
ppOrder = dropTitle,
|
||||||
ppLayout = layoutIcon,
|
ppLayout = layoutIcon,
|
||||||
ppExtras = [budgetTitles]
|
ppExtras = [budgetTitles]
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
|
-- The focused title is replaced by budgetTitles
|
||||||
|
dropTitle :: [String] -> [String]
|
||||||
|
dropTitle (ws : l : _ : rest) = ws : l : rest
|
||||||
|
dropTitle xs = xs
|
||||||
|
|
||||||
layoutIcon :: String -> String
|
layoutIcon :: String -> String
|
||||||
layoutIcon l = case l of
|
layoutIcon l = case l of
|
||||||
"Tall" -> "\xf0bcc"
|
"Tall" -> "\xf0bcc"
|
||||||
@@ -326,11 +334,12 @@ myXmobarPP =
|
|||||||
budgetTitles = do
|
budgetTitles = do
|
||||||
n <- gets $ length . W.integrate' . W.stack . W.workspace . W.current . windowset
|
n <- gets $ length . W.integrate' . W.stack . W.workspace . W.current . windowset
|
||||||
let width = max 8 . min 30 $ 60 `div` max 1 n
|
let width = max 8 . min 30 $ 60 `div` max 1 n
|
||||||
logTitles (formatFocused width) (formatUnfocused width)
|
logTitles' (TitlesFormat (formatFocused width) (formatUnfocused width) (formatUrgent width))
|
||||||
|
|
||||||
formatFocused, formatUnfocused :: Int -> String -> String
|
formatFocused, formatUnfocused, formatUrgent :: Int -> String -> String
|
||||||
formatFocused w = wrap (cultured "[") (cultured "]") . pink . ppWindow w
|
formatFocused w = wrap (cultured "[") (cultured "]") . pink . ppWindow w
|
||||||
formatUnfocused w = wrap (outerspace "[") (outerspace "]") . cultured . ppWindow w
|
formatUnfocused w = wrap (outerspace "[") (outerspace "]") . cultured . ppWindow w
|
||||||
|
formatUrgent w = wrap (keylime "!") (keylime "!") . sunsetorange . ppWindow w
|
||||||
|
|
||||||
ppWindow :: Int -> String -> String
|
ppWindow :: Int -> String -> String
|
||||||
ppWindow w = xmobarRaw . (\t -> if null t then "untitled" else t) . shorten' "…" w
|
ppWindow w = xmobarRaw . (\t -> if null t then "untitled" else t) . shorten' "…" w
|
||||||
@@ -346,6 +355,7 @@ myXmobarPP =
|
|||||||
myStartupHook :: X ()
|
myStartupHook :: X ()
|
||||||
myStartupHook = do
|
myStartupHook = do
|
||||||
restartStatusBars
|
restartStatusBars
|
||||||
|
scanDiscoverOverlay
|
||||||
spawnOnce myScreenSetup
|
spawnOnce myScreenSetup
|
||||||
spawnOnce "systemctl --user start fehbg.timer"
|
spawnOnce "systemctl --user start fehbg.timer"
|
||||||
spawnOnce "xsetroot -cursor_name left_ptr"
|
spawnOnce "xsetroot -cursor_name left_ptr"
|
||||||
@@ -358,6 +368,8 @@ myStartupHook = do
|
|||||||
spawnOnce "nm-applet"
|
spawnOnce "nm-applet"
|
||||||
spawnOnce "arch-audit-gtk"
|
spawnOnce "arch-audit-gtk"
|
||||||
spawnOnce "calcurse --daemon"
|
spawnOnce "calcurse --daemon"
|
||||||
|
spawnOnce "systemctl --user start calcurse-today.timer"
|
||||||
|
spawnOnce "systemctl --user start calcurse-sync.timer"
|
||||||
spawnOnce "systemctl --user start dunst"
|
spawnOnce "systemctl --user start dunst"
|
||||||
spawnOnce "lxpolkit"
|
spawnOnce "lxpolkit"
|
||||||
spawnOnce "numlockx"
|
spawnOnce "numlockx"
|
||||||
@@ -372,48 +384,58 @@ myManageHook =
|
|||||||
[ -- Proton games are steam_app_<id>; Wine windows are named after their .exe
|
[ -- Proton games are steam_app_<id>; Wine windows are named after their .exe
|
||||||
className ^? "steam_app_" --> doShift wsGames,
|
className ^? "steam_app_" --> doShift wsGames,
|
||||||
className $? ".exe" --> doShift wsGames,
|
className $? ".exe" --> doShift wsGames,
|
||||||
className =? "Gpodder" --> doShift wsMedia,
|
classIn ["steam", "an anime game launcher"] --> doShift wsGames,
|
||||||
className =? "An Anime Game Launcher" --> doShift wsGames,
|
|
||||||
className =? "Qalculate-gtk" --> doFloat,
|
|
||||||
title =? "Genshin Impact" --> doShift wsGames,
|
title =? "Genshin Impact" --> doShift wsGames,
|
||||||
classIn ["gimp", "audacity"] --> doShift wsMedia,
|
classIn ["steam_app_109600", "steam_app_289070"] --> doFloat,
|
||||||
classIn ["pavucontrol", "org.pulseaudio.pavucontrol", "zenity", "org.gnome.zenity", "lxappearance", "qt5ct", "qt6ct", "gsimplecal"] --> doFloat,
|
classIn ["zen", "vivaldi-stable", "transmission-gtk"] --> doShift wsWeb,
|
||||||
className =? "Signal" --> doShift wsChat,
|
classIn ["signal", "discord"] --> doShift wsChat,
|
||||||
className =? "Spotify" --> doShift wsMedia,
|
classIn ["gpodder", "spotify", "freetube", "scrcpy", "gimp", "audacity"] --> doShift wsMedia,
|
||||||
className =? "Transmission-gtk" --> doShift wsWeb,
|
classIn ["xreader", "calibre", "library_manager", "libreoffice-calc", "libreoffice-writer"] --> doShift wsDocs,
|
||||||
className =? "Viewnior" --> doFloat,
|
classIn ["virtualbox manager"] --> doShift wsVM,
|
||||||
className =? "Vivaldi-stable" --> doShift wsWeb,
|
className =? "VirtualBox Machine" --> doFullFloat <+> doShift wsVM,
|
||||||
className =? "Xmessage" --> doFloat,
|
className =? "mpv" --> doFullFloat <+> viewShift wsMedia,
|
||||||
className =? "Xreader" --> doShift wsDocs,
|
|
||||||
className =? "calibre" --> doShift wsDocs,
|
|
||||||
className =? "discord" --> doShift wsChat,
|
|
||||||
className =? "feh" --> doFloat,
|
|
||||||
title =? "glxgears" --> doFloat,
|
|
||||||
className =? "library_manager" --> doShift wsDocs,
|
|
||||||
className =? "libreoffice-calc" --> doShift wsDocs,
|
|
||||||
className =? "libreoffice-writer" --> doShift wsDocs,
|
|
||||||
className =? "mpv" --> doFullFloat,
|
|
||||||
className =? "mpv" --> viewShift wsMedia,
|
|
||||||
className =? "freetube" --> doShift wsMedia,
|
|
||||||
className =? myTerminal --> doShift wsTerm,
|
className =? myTerminal --> doShift wsTerm,
|
||||||
className =? "scrcpy" --> doShift wsMedia,
|
classIn
|
||||||
className =? "steam" --> doShift wsGames,
|
[ "qalculate-gtk", "viewnior", "xmessage", "feh", "lxappearance", "qt5ct", "qt6ct",
|
||||||
className =? "steam_app_109600" --> doFloat,
|
"pavucontrol", "org.pulseaudio.pavucontrol", "zenity", "org.gnome.zenity"
|
||||||
className =? "steam_app_289070" --> doFloat,
|
]
|
||||||
className =? "VirtualBox Machine" --> doShift wsVM,
|
--> doFloat,
|
||||||
className =? "VirtualBox Machine" --> doFullFloat,
|
title =? "glxgears" --> doFloat,
|
||||||
className =? "VirtualBox Manager" --> doShift wsVM,
|
|
||||||
className =? "zen" --> doShift wsWeb,
|
|
||||||
isDialog --> doFloat,
|
isDialog --> doFloat,
|
||||||
-- Windows that open already fullscreen; ewmhFullscreen only handles later requests
|
-- Windows that open already fullscreen; ewmhFullscreen only handles later requests
|
||||||
isFullscreen --> doFullFloat
|
isFullscreen --> doFullFloat
|
||||||
]
|
]
|
||||||
<+> namedScratchpadManageHook myScratchpads
|
<+> namedScratchpadManageHook myScratchpads
|
||||||
where
|
where
|
||||||
viewShift = doF . liftM2 (.) safeView W.shift
|
viewShift = doF . liftA2 (.) safeView W.shift
|
||||||
-- Case-insensitive, as GTK4 and firejailed apps capitalise their class differently
|
-- Case-insensitive, as GTK4 and firejailed apps capitalise their class differently
|
||||||
classIn names = (`elem` names) . map toLower <$> className
|
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
|
-- Handle event hook
|
||||||
myHandleEventHook :: Event -> X All
|
myHandleEventHook :: Event -> X All
|
||||||
myHandleEventHook =
|
myHandleEventHook =
|
||||||
@@ -421,6 +443,24 @@ myHandleEventHook =
|
|||||||
<> Hacks.trayerAboveXmobarEventHook
|
<> Hacks.trayerAboveXmobarEventHook
|
||||||
<> Hacks.trayerPaddingXmobarEventHook
|
<> Hacks.trayerPaddingXmobarEventHook
|
||||||
<> Hacks.fixSteamFlicker
|
<> Hacks.fixSteamFlicker
|
||||||
|
<> pinWindscribe
|
||||||
|
<> trackDiscoverOverlay
|
||||||
|
|
||||||
|
-- Windscribe moves itself to a saved position after mapping: apply its resizes (as core does for floats) but drop moves.
|
||||||
|
pinWindscribe :: Event -> X All
|
||||||
|
pinWindscribe e@ConfigureRequestEvent {ev_window = w} = do
|
||||||
|
floats <- gets (W.floating . windowset)
|
||||||
|
pinned <- if M.member w floats then runQuery (className =? "Windscribe2") w else pure False
|
||||||
|
when pinned $ withDisplay $ \dpy -> do
|
||||||
|
bw <- asks (borderWidth . config)
|
||||||
|
io $ configureWindow dpy w (ev_value_mask e .&. complement (fromIntegral (cWX .|. cWY))) $
|
||||||
|
WindowChanges
|
||||||
|
{ wc_x = 0, wc_y = 0, wc_width = ev_width e, wc_height = ev_height e,
|
||||||
|
wc_border_width = fromIntegral bw, wc_sibling = ev_above e, wc_stack_mode = ev_detail e }
|
||||||
|
float w
|
||||||
|
io $ sync dpy False
|
||||||
|
pure (All (not pinned))
|
||||||
|
pinWindscribe _ = pure (All True)
|
||||||
|
|
||||||
-- Log hook
|
-- Log hook
|
||||||
myLogHook :: X ()
|
myLogHook :: X ()
|
||||||
@@ -429,11 +469,34 @@ myLogHook = do
|
|||||||
xmonadPropLog =<< dynamicLogString =<< clickablePP myXmobarPP
|
xmonadPropLog =<< dynamicLogString =<< clickablePP myXmobarPP
|
||||||
|
|
||||||
-- discover-overlay's windows are override-redirect, so xmonad doesn't manage them and
|
-- discover-overlay's windows are override-redirect, so xmonad doesn't manage them and
|
||||||
-- raising a floating window (e.g. a game) covers them; put them back on top after every change
|
-- raising a floating window (e.g. a game) covers them; put them back on top after every change.
|
||||||
raiseDiscoverOverlay :: X ()
|
-- They're remembered when mapped, so the log hook doesn't query every window each time.
|
||||||
raiseDiscoverOverlay = withDisplay $ \d -> do
|
newtype OverlayWindows = OverlayWindows [Window]
|
||||||
|
|
||||||
|
instance ExtensionClass OverlayWindows where
|
||||||
|
initialValue = OverlayWindows []
|
||||||
|
|
||||||
|
isDiscoverOverlay :: Window -> X Bool
|
||||||
|
isDiscoverOverlay = runQuery (className =? "Discover-overlay")
|
||||||
|
|
||||||
|
-- Startup (incl. xmonad --restart): pick up overlays mapped before the event hook could see them
|
||||||
|
scanDiscoverOverlay :: X ()
|
||||||
|
scanDiscoverOverlay = withDisplay $ \d -> do
|
||||||
root <- asks theRoot
|
root <- asks theRoot
|
||||||
(_, _, ws) <- io $ queryTree d root
|
(_, _, ws) <- io $ queryTree d root
|
||||||
forM_ ws $ \w -> do
|
XS.put . OverlayWindows =<< filterM isDiscoverOverlay ws
|
||||||
cls <- io $ getClassHint d w
|
|
||||||
when (resClass cls == "Discover-overlay") $ io $ raiseWindow d w
|
trackDiscoverOverlay :: Event -> X All
|
||||||
|
trackDiscoverOverlay MapNotifyEvent {ev_window = w, ev_override_redirect = True} = do
|
||||||
|
overlay <- isDiscoverOverlay w
|
||||||
|
when overlay $ XS.modify $ \(OverlayWindows ws) -> OverlayWindows (w : filter (/= w) ws)
|
||||||
|
pure (All True)
|
||||||
|
trackDiscoverOverlay DestroyWindowEvent {ev_window = w} = do
|
||||||
|
XS.modify $ \(OverlayWindows ws) -> OverlayWindows (filter (/= w) ws)
|
||||||
|
pure (All True)
|
||||||
|
trackDiscoverOverlay _ = pure (All True)
|
||||||
|
|
||||||
|
raiseDiscoverOverlay :: X ()
|
||||||
|
raiseDiscoverOverlay = do
|
||||||
|
OverlayWindows ws <- XS.get
|
||||||
|
unless (null ws) $ withDisplay $ \d -> io $ mapM_ (raiseWindow d) ws
|
||||||
+1
-1
@@ -17,7 +17,7 @@ install script. This README lives in `.github/` to keep it out of the home direc
|
|||||||
| Audio / media | mpd, ncmpcpp, mpDris2, mpv, beets, pipewire |
|
| Audio / media | mpd, ncmpcpp, mpDris2, mpv, beets, pipewire |
|
||||||
| Packaging | `.config/aurutils-makepkg.conf`, `.config/aurb/`, `.local/bin/aurb` / `aurs` (aurutils wrappers) |
|
| Packaging | `.config/aurutils-makepkg.conf`, `.config/aurb/`, `.local/bin/aurb` / `aurs` (aurutils wrappers) |
|
||||||
| Services | `.config/systemd/user/` (timers and overrides) |
|
| Services | `.config/systemd/user/` (timers and overrides) |
|
||||||
| Scripts | `.local/bin/` (screen layout, phone mount, video helpers, Library and Garmin database dumps) |
|
| Scripts | `.local/bin/` (screen layout, phone mount, video helpers, Library, Garmin and Weather database dumps) |
|
||||||
|
|
||||||
Note: `config.fish` sources `~/.bash_aliases`, so the aliases apply in both shells.
|
Note: `config.fish` sources `~/.bash_aliases`, so the aliases apply in both shells.
|
||||||
|
|
||||||
|
|||||||
Executable
+101
@@ -0,0 +1,101 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Renew calcurse-caldav's Google login: catch the OAuth redirect on 127.0.0.1 and hand the code to calcurse-sync.
|
||||||
|
|
||||||
|
--prompt shows a notification first and logs in when it is clicked.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import configparser
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import urllib.parse
|
||||||
|
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
CONFIG = Path(os.environ.get("XDG_CONFIG_HOME", Path.home() / ".config")) / "calcurse" / "caldav" / "config"
|
||||||
|
WAIT_SECONDS = 300
|
||||||
|
|
||||||
|
|
||||||
|
def notify(summary: str, body: str = "", *extra: str) -> str:
|
||||||
|
"""Send a calcurse notification; with actions in extra, wait and return the chosen action's name."""
|
||||||
|
cmd = ["notify-send", "-a", "calcurse", "-i", "x-office-calendar", *extra, summary, body]
|
||||||
|
return subprocess.run(cmd, capture_output=True, text=True).stdout.strip()
|
||||||
|
|
||||||
|
|
||||||
|
def redirect_port() -> int:
|
||||||
|
parser = configparser.RawConfigParser()
|
||||||
|
parser.read(CONFIG)
|
||||||
|
uri = urllib.parse.urlparse(parser.get("OAuth2", "RedirectURI", fallback=""))
|
||||||
|
if uri.hostname != "127.0.0.1" or uri.port is None:
|
||||||
|
sys.exit(f"RedirectURI in {CONFIG} must be http://127.0.0.1:<port>")
|
||||||
|
return uri.port
|
||||||
|
|
||||||
|
|
||||||
|
def ui_running() -> bool:
|
||||||
|
ttys = subprocess.run(["ps", "-C", "calcurse", "-o", "tty="], capture_output=True, text=True).stdout.split()
|
||||||
|
return any(tty != "?" for tty in ttys)
|
||||||
|
|
||||||
|
|
||||||
|
class RedirectHandler(BaseHTTPRequestHandler):
|
||||||
|
result: dict[str, str] = {}
|
||||||
|
|
||||||
|
def do_GET(self) -> None:
|
||||||
|
query = urllib.parse.parse_qs(urllib.parse.urlparse(self.path).query)
|
||||||
|
for key in ("code", "error"):
|
||||||
|
if key in query:
|
||||||
|
RedirectHandler.result[key] = query[key][0]
|
||||||
|
done = bool(RedirectHandler.result)
|
||||||
|
self.send_response(200 if done else 404)
|
||||||
|
self.send_header("Content-Type", "text/plain; charset=utf-8")
|
||||||
|
self.end_headers()
|
||||||
|
if done:
|
||||||
|
self.wfile.write(b"calcurse: login received, you can close this tab.\n")
|
||||||
|
|
||||||
|
def log_message(self, format: str, *args: object) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def login() -> int:
|
||||||
|
if ui_running():
|
||||||
|
notify("Google Calendar login", "Close calcurse first, then log in again.", "-u", "critical")
|
||||||
|
return 1
|
||||||
|
server = HTTPServer(("127.0.0.1", redirect_port()), RedirectHandler)
|
||||||
|
# With an expired login calcurse-caldav opens the consent page and exits; with a valid one it just syncs.
|
||||||
|
if subprocess.run(["calcurse-caldav"], capture_output=True).returncode == 0:
|
||||||
|
notify("Google Calendar login", "Already logged in.")
|
||||||
|
return 0
|
||||||
|
deadline = time.monotonic() + WAIT_SECONDS
|
||||||
|
while not RedirectHandler.result and (left := deadline - time.monotonic()) > 0:
|
||||||
|
server.timeout = left
|
||||||
|
server.handle_request()
|
||||||
|
server.server_close()
|
||||||
|
code = RedirectHandler.result.get("code")
|
||||||
|
if not code:
|
||||||
|
reason = RedirectHandler.result.get("error", "no answer from the browser")
|
||||||
|
notify("Google Calendar login failed", reason, "-u", "critical")
|
||||||
|
return 1
|
||||||
|
# The user manager's PATH lacks ~/.local/bin: call calcurse-sync from this script's folder.
|
||||||
|
calcurse_sync = Path(__file__).resolve().with_name("calcurse-sync")
|
||||||
|
sync = subprocess.run([calcurse_sync, "--authcode", code], capture_output=True, text=True)
|
||||||
|
if sync.returncode != 0:
|
||||||
|
last_line = (sync.stdout.strip().splitlines() or [""])[-1]
|
||||||
|
notify("Google Calendar login failed", last_line, "-u", "critical")
|
||||||
|
return 1
|
||||||
|
notify("Google Calendar login renewed", "Synced again.")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> int:
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
||||||
|
parser.add_argument("--prompt", action="store_true", help="ask with a notification before logging in")
|
||||||
|
if parser.parse_args().prompt:
|
||||||
|
body = "Click to log in again, then click Allow in the browser."
|
||||||
|
if notify("Google Calendar login expired", body, "-u", "critical", "-A", "default=Log in") != "default":
|
||||||
|
return 0
|
||||||
|
return login()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
Executable
+57
@@ -0,0 +1,57 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Sync calcurse with Google Calendar via calcurse-caldav; start the login prompt when the weekly OAuth login expires.
|
||||||
|
# --now: called from the UI's pre-load hook (skip the UI check, shorter timeout, no daemon restart).
|
||||||
|
# --authcode CODE: finish a login (from calcurse-relogin, which checks for the UI itself).
|
||||||
|
set -uo pipefail
|
||||||
|
|
||||||
|
data=${XDG_DATA_HOME:-$HOME/.local/share}/calcurse
|
||||||
|
state=${XDG_STATE_HOME:-$HOME/.local/state}/calcurse-sync
|
||||||
|
expired_flag=$state/login-expired
|
||||||
|
now=false
|
||||||
|
authcode=()
|
||||||
|
case ${1:-} in
|
||||||
|
--now) now=true ;;
|
||||||
|
--authcode) authcode=(--authcode "$2") ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# The UI keeps the data in memory, so syncing under it would lose changes; its post-save hook syncs after it exits.
|
||||||
|
ui_running() {
|
||||||
|
# shellcheck disable=SC2009 # pgrep can't match "has any terminal"
|
||||||
|
ps -C calcurse -o tty= | grep -qv '?'
|
||||||
|
}
|
||||||
|
|
||||||
|
if ! $now && ((${#authcode[@]} == 0)) && ui_running; then
|
||||||
|
echo "calcurse UI is running, skipping"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p "$state"
|
||||||
|
# BROWSER=true: an expired login must not open browser tabs on its own.
|
||||||
|
out=$(BROWSER=true timeout "$($now && echo 15 || echo 60)" calcurse-caldav "${authcode[@]}" 2>&1)
|
||||||
|
rc=$?
|
||||||
|
printf '%s\n' "$out"
|
||||||
|
|
||||||
|
if ((rc != 0)); then
|
||||||
|
if grep -q 'Access token is missing or refresh token is expired' <<<"$out"; then
|
||||||
|
# Prompt via calcurse-relogin, again daily if the prompt was dismissed.
|
||||||
|
if [[ ! -e $expired_flag || -n $(find "$expired_flag" -mmin +1440) ]]; then
|
||||||
|
systemctl --user start --no-block calcurse-relogin.service
|
||||||
|
touch "$expired_flag"
|
||||||
|
fi
|
||||||
|
elif grep -q 'Another synchronization instance' <<<"$out"; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
exit "$rc"
|
||||||
|
fi
|
||||||
|
rm -f "$expired_flag"
|
||||||
|
|
||||||
|
# A running daemon never re-reads the data files: restart it so imported appointments get alerts.
|
||||||
|
if ! $now && ! grep -q '^0 items imported, 0 items removed locally' <<<"$out"; then
|
||||||
|
pidfile=$data/.daemon.pid
|
||||||
|
if [[ -s $pidfile ]] && pid=$(<"$pidfile") && kill "$pid" 2>/dev/null; then
|
||||||
|
timeout 5 tail --pid="$pid" -f /dev/null
|
||||||
|
# Own scope, so the daemon outlives this oneshot service.
|
||||||
|
systemd-run --user --scope -q calcurse --daemon
|
||||||
|
echo "restarted calcurse daemon"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
Executable
+9
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Notify today's whole-day calcurse events (the daemon only alerts timed appointments).
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
events=$(calcurse -Q --filter-type event,recur-event --days 1 \
|
||||||
|
--format-event '%m\n' --format-recur-event '%m\n' | tail -n +2)
|
||||||
|
|
||||||
|
[[ -n $events ]] || exit 0
|
||||||
|
notify-send -a calcurse -i x-office-calendar "Today" "$events"
|
||||||
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"
|
|
||||||
+35
-10
@@ -2,25 +2,50 @@
|
|||||||
# i3lock-color with a background image and the keyboard layout shown.
|
# i3lock-color with a background image and the keyboard layout shown.
|
||||||
|
|
||||||
image=/usr/share/backgrounds/arch_1920x1080.png
|
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
|
# Hold notifications while locked; dunst shows them on unlock. A signal to this
|
||||||
# script is passed on to i3lock, as the old exec did.
|
# script is passed on to i3lock, as the old exec did.
|
||||||
was_paused=$(dunstctl is-paused 2>/dev/null)
|
was_paused=$(dunstctl is-paused 2>/dev/null)
|
||||||
dunstctl set-paused true 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.
|
# i3lock exits 1 if another client holds a grab (dmenu, rofi, a prompt): retry for a minute.
|
||||||
# --indicator keeps the ring (and the layout text) visible before typing.
|
tries=0
|
||||||
# The layout's default spot (dx:dy+30) falls inside the ring: put it below.
|
while :; do
|
||||||
i3lock -n -i "$image" -F -c 000000ff \
|
# -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 \
|
-e -f --indicator --keylayout 0 \
|
||||||
--layout-pos='ix:iy+r+40' --layout-color=ffffffff \
|
--layout-pos='ix:iy+r+40' --layout-color=ffffffff \
|
||||||
--layout-size=24 \
|
--layout-size=24 \
|
||||||
--time-color=ffffffff --date-color=ffffffff --date-str='%A, %d %B' \
|
--time-color=ffffffff --date-color=ffffffff --date-str='%A, %d %B' \
|
||||||
--ring-color=1793d1ff --line-uses-ring "$@" &
|
--ring-color=1793d1ff --line-uses-ring "$@" 2>"$err" &
|
||||||
pid=$!
|
pid=$!
|
||||||
# A trapped signal interrupts the first wait; the second waits for i3lock to exit.
|
wait "$pid"
|
||||||
wait "$pid"
|
status=$?
|
||||||
wait "$pid" 2>/dev/null
|
# 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
|
[ "$was_paused" = true ] || dunstctl set-paused false 2>/dev/null
|
||||||
Reference in new issue
Block a user