[{"content":"authentik can post to Discord out of the box, but the default embed only names the user and the event type. I wanted a short message that says who signed into which app:\nalex is logging into Grafana\nTested on authentik 2026.8.\nWhy the default doesn\u0026rsquo;t work The plain login event happens at the authentik level, before any app is involved, so it has no app name. The authorize_application event fires when a user is authorized for a specific app. That\u0026rsquo;s the one to match on. The transport mode called \u0026ldquo;Slack Webhook (Discord compatible)\u0026rdquo; uses a fixed embed and ignores property mappings entirely. Step 1: Create a Discord webhook In Discord: Channel Settings → Integrations → Webhooks → New Webhook, then copy the URL. It should look like this:\nhttps://discord.com/api/webhooks/\u0026lt;id\u0026gt;/\u0026lt;token\u0026gt; Don\u0026rsquo;t add /slack to the end (more on that in the troubleshooting table). Treat this URL like a password: anyone who has it can post to your channel.\nStep 2: Create the webhook mapping Customization → Property Mappings → Create → Webhook Mapping (Notification)\nfrom authentik.core.models import Application event = notification.event ctx = event.context or {} user = (event.user or {}).get(\u0026#34;username\u0026#34;, \u0026#34;Unknown user\u0026#34;) app = ctx.get(\u0026#34;authorized_application\u0026#34;, {}).get(\u0026#34;name\u0026#34;) if not app: match = Application.objects.filter( provider__authorization_flow__pk=ctx.get(\u0026#34;flow\u0026#34;) ).first() app = match.name if match else \u0026#34;an application\u0026#34; return {\u0026#34;content\u0026#34;: f\u0026#34;**{user}** is logging into **{app}**\u0026#34;} It tries the app name from the event context first. If that\u0026rsquo;s missing, it looks up the app from the flow ID.\nCaveat: the flow-ID fallback can pick the wrong app when several apps share one authorization flow, which is the default for most setups. If you see the wrong app name, give each provider its own authorization flow, or use the debug mapping below to find a better key.\nStep 3: Create the notification transport Events → Notification Transports → Create\nMode: Webhook (generic), not the Slack/Discord-compatible mode Webhook URL: the Discord URL from step 1 Webhook Mapping Body: the mapping from step 2 The test (play) button next to the transport sends a test message without you having to log in.\nStep 4: Create the event matcher policy Customization → Policies → Create → Event Matcher Policy\nName: authorize-application-event Action: Authorize Application Leave app and client IP empty to match every app. Note that this lives under Customization → Policies, not under Events.\nStep 5: Create the notification rule Events → Notification Rules\nSelect the transport from step 3. Set the severity to Notice or lower, or the event gets filtered out. Expand the rule and use Bind existing Policy/Group/User to bind the policy from step 4. Remove any binding to a login event matcher, or you\u0026rsquo;ll get two messages per login. Step 6: Test it Log out and back into an app, or use a private window. A fresh authorize_application event should fire and the message should appear in Discord.\nTroubleshooting Symptom Cause Fix Discord still shows the default embed Transport is in Slack/Discord-compatible mode Switch to Webhook (generic) and select the mapping 400 Client Error: Bad Request URL ends in /slack, so Discord expects a Slack payload (text) but gets content Remove /slack, or return {\u0026quot;text\u0026quot;: ...} Event page in authentik looks unchanged The event page shows the raw stored event; mappings only change what\u0026rsquo;s sent Check Discord, not the event page No message at all An existing session means no new authorize_application event, or the rule uses the wrong transport Log out/in, and check the rule\u0026rsquo;s transport and policy binding Webhook URL showed up in an error message authentik\u0026rsquo;s error text includes the full URL Delete and recreate the webhook in Discord, then update the transport Debug mapping Swap this in temporarily to see exactly what the event context contains. It shows up in Discord as a code block:\nimport json event = notification.event return {\u0026#34;content\u0026#34;: \u0026#34;```\u0026#34; + json.dumps(event.context, default=str)[:1800] + \u0026#34;```\u0026#34;} Extras Discord webhooks also accept embeds if you want something fancier: {\u0026quot;embeds\u0026quot;: [{\u0026quot;title\u0026quot;: \u0026quot;Login\u0026quot;, \u0026quot;description\u0026quot;: f\u0026quot;{user} is logging into {app}\u0026quot;}]} If messages break after an authentik upgrade, run the debug mapping first to check whether the context keys changed. ","permalink":"http://liyafixes.dev/posts/authentik-discord-login-notifications/","summary":"\u003cp\u003eauthentik can post to Discord out of the box, but the default embed only names the user and the event type. I wanted a short message that says who signed into which app:\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cp\u003e\u003cstrong\u003ealex\u003c/strong\u003e is logging into \u003cstrong\u003eGrafana\u003c/strong\u003e\u003c/p\u003e\n\u003c/blockquote\u003e\n\u003cp\u003eTested on authentik 2026.8.\u003c/p\u003e\n\u003ch2 id=\"why-the-default-doesnt-work\"\u003eWhy the default doesn\u0026rsquo;t work\u003c/h2\u003e\n\u003cul\u003e\n\u003cli\u003eThe plain \u003ccode\u003elogin\u003c/code\u003e event happens at the authentik level, \u003cem\u003ebefore\u003c/em\u003e any app is involved, so it has no app name.\u003c/li\u003e\n\u003cli\u003eThe \u003ccode\u003eauthorize_application\u003c/code\u003e event fires when a user is authorized for a specific app. That\u0026rsquo;s the one to match on.\u003c/li\u003e\n\u003cli\u003eThe transport mode called \u0026ldquo;Slack Webhook (Discord compatible)\u0026rdquo; uses a fixed embed and \u003cstrong\u003eignores property mappings entirely\u003c/strong\u003e.\u003c/li\u003e\n\u003c/ul\u003e\n\u003ch2 id=\"step-1-create-a-discord-webhook\"\u003eStep 1: Create a Discord webhook\u003c/h2\u003e\n\u003cp\u003eIn Discord: \u003cstrong\u003eChannel Settings → Integrations → Webhooks → New Webhook\u003c/strong\u003e, then copy the URL. It should look like this:\u003c/p\u003e","title":"How to Send \"User Is Logging Into App\" Alerts from authentik to Discord"},{"content":"If you expose self-hosted apps to the internet through Traefik, you will see scanners and brute-force attempts within hours. CrowdSec reads Traefik\u0026rsquo;s access log, spots attack patterns, and tells a Traefik plugin to return 403 to the offenders. This guide walks through the full setup with Docker Compose.\nHow it fits together Internet → Traefik (https entrypoint) → crowdsec@file middleware → app │ │ │ writes JSON access log │ asks \u0026#34;is this IP banned?\u0026#34; ▼ ▼ ./traefik/logs ──────────► CrowdSec container (reads log, detects, decides) Traefik writes a JSON access log. The CrowdSec engine reads that log, matches attack scenarios, and creates ban decisions. It also pulls the community blocklist. The bouncer is a Traefik plugin, not a separate container. It asks CrowdSec\u0026rsquo;s local API whether an IP is banned and returns 403 if so. CrowdSec ignores private ranges (10.x, 172.16-31.x, 192.168.x) by default, so LAN traffic can\u0026rsquo;t get banned.\nThe examples assume this layout. Adjust the paths to match yours.\nItem Example location Traefik stack /opt/stacks/traefik Traefik static config /opt/stacks/traefik/data/traefik.yml Traefik dynamic config /opt/stacks/traefik/data/config.yml CrowdSec stack /opt/stacks/crowdsec Shared Docker network proxy (external) HTTPS entrypoint name https Part 1: One-time setup Step 1: Turn on Traefik\u0026rsquo;s access log In traefik.yml:\naccessLog: filePath: /var/log/traefik/access.log format: json bufferingSize: 100 Add a logs volume to Traefik\u0026rsquo;s compose.yaml:\nvolumes: - ./logs:/var/log/traefik mkdir -p /opt/stacks/traefik/logs Step 2: Create the CrowdSec acquisition file Create this before you start the container:\n/opt/stacks/crowdsec/acquis.yaml\nfilenames: - /var/log/traefik/access.log labels: type: traefik Bind-mount gotcha: if a bind-mounted file doesn\u0026rsquo;t exist when a container starts, Docker creates an empty directory in its place and the mount fails with \u0026ldquo;not a directory\u0026rdquo;. To fix it: docker compose down, sudo rm -rf the bogus directory (check both the host path and inside ./crowdsec/config/), create the real file, and start again.\nStep 3: Write the CrowdSec compose file /opt/stacks/crowdsec/compose.yaml\nservices: crowdsec: image: crowdsecurity/crowdsec:latest container_name: crowdsec restart: unless-stopped environment: COLLECTIONS: crowdsecurity/traefik crowdsecurity/http-cve crowdsecurity/base-http-scenarios GID: \u0026#34;1000\u0026#34; volumes: - ./crowdsec/config:/etc/crowdsec - ./crowdsec/data:/var/lib/crowdsec/data - ./acquis.yaml:/etc/crowdsec/acquis.yaml - /opt/stacks/traefik/logs:/var/log/traefik:ro networks: - proxy networks: proxy: external: true cd /opt/stacks/crowdsec docker compose up -d docker logs crowdsec --tail 50 docker exec crowdsec cscli metrics # access.log should show lines read and parsed Step 4: Create a bouncer API key docker exec crowdsec cscli bouncers add traefik-bouncer The key is shown once. If you lose it, run cscli bouncers delete traefik-bouncer and add it again. Keep it out of screenshots, chats and git.\nStep 5: Declare the plugin in Traefik In traefik.yml. Plugins download at startup, so Traefik needs outbound access to GitHub:\nexperimental: plugins: crowdsec-bouncer: moduleName: github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin version: v1.8.2 Step 6: Define the middleware In config.yml, add it under the existing http: → middlewares: block:\nhttp: middlewares: crowdsec: plugin: crowdsec-bouncer: enabled: true crowdsecMode: live crowdsecLapiScheme: http crowdsecLapiHost: crowdsec:8080 crowdsecLapiKey: \u0026#34;PASTE_KEY_HERE\u0026#34; # ...your other middlewares Never add a second middlewares: key. YAML rejects duplicate keys and Traefik then drops the entire file provider. The symptom is middleware \u0026quot;default-headers@file\u0026quot; does not exist on every router. Check with grep -n '^ middlewares:' config.yml; you want exactly one match.\nStep 7: Restart Traefik cd /opt/stacks/traefik docker compose up -d --force-recreate traefik docker logs traefik --since 1m # no ERR lines = good Single-file mounts go stale. If config.yml is mounted as a single file, editors and sed -i can replace the file\u0026rsquo;s inode and the container keeps reading the old copy. Recreating the container (as above) avoids this.\nStep 8: Confirm the bouncer is talking to CrowdSec docker exec crowdsec cscli bouncers list # \u0026#34;Last API pull\u0026#34; should show a timestamp Part 2: Allowlist your own IP (even if it changes) If your home connection has a dynamic IP that you already track with DDNS, a small script can mirror that IP into a CrowdSec allowlist so you can never ban yourself.\ndocker exec crowdsec cscli allowlists create home -d \u0026#34;home WAN IP\u0026#34; ~/scripts/update-home-allowlist.sh:\n#!/bin/bash # Keep the CrowdSec \u0026#34;home\u0026#34; allowlist in sync with your DDNS hostname DDNS_HOST=\u0026#34;home.example.com\u0026#34; NEW=$(/usr/bin/dig +short A \u0026#34;$DDNS_HOST\u0026#34; @1.1.1.1 | tail -1) STATE=$HOME/scripts/home-ip.txt OLD=$(cat \u0026#34;$STATE\u0026#34; 2\u0026gt;/dev/null) # bail out if the lookup failed or didn\u0026#39;t return an IPv4 address [[ \u0026#34;$NEW\u0026#34; =~ ^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$ ]] || exit 1 [ \u0026#34;$NEW\u0026#34; = \u0026#34;$OLD\u0026#34; ] \u0026amp;\u0026amp; exit 0 /usr/bin/docker exec crowdsec cscli allowlists add home \u0026#34;$NEW\u0026#34; [ -n \u0026#34;$OLD\u0026#34; ] \u0026amp;\u0026amp; /usr/bin/docker exec crowdsec cscli allowlists remove home \u0026#34;$OLD\u0026#34; echo \u0026#34;$NEW\u0026#34; \u0026gt; \u0026#34;$STATE\u0026#34; echo \u0026#34;$(date) home IP changed: ${OLD:-none} -\u0026gt; $NEW\u0026#34; Run it every five minutes with crontab -e:\n*/5 * * * * $HOME/scripts/update-home-allowlist.sh \u0026gt;\u0026gt; $HOME/scripts/allowlist-update.log 2\u0026gt;\u0026amp;1 Check it with docker exec crowdsec cscli allowlists inspect home.\nPart 3: Adding a new app Each time you expose a new app at app.example.com:\nDNS: point app.example.com at your WAN IP (an A record, or a CNAME to your DDNS name). Network: put the container on the shared proxy network. Labels: put crowdsec@file first in the router\u0026rsquo;s middleware list: - traefik.http.routers.app.middlewares=crowdsec@file,default-headers@file A few rules of thumb:\ncrowdsec@file always goes first, so banned IPs are dropped before anything else runs, including SSO/forward-auth. File-provider middlewares need the @file suffix in labels. To hide admin paths from the internet, exclude them in the external rule, for example Host(`app.example.com`) \u0026amp;\u0026amp; !PathPrefix(`/admin`). Then test from outside your LAN (a phone on cellular works) and confirm the real client IP shows up in the log:\ntail -n 3 /opt/stacks/traefik/logs/access.log | grep -o \u0026#39;\u0026#34;ClientHost\u0026#34;:\u0026#34;[^\u0026#34;]*\u0026#34;\u0026#39; Optional: protect every service at once Attach the middleware to the https entrypoint in traefik.yml (merge into your existing entryPoints: block):\nentryPoints: https: address: \u0026#34;:443\u0026#34; http: middlewares: - crowdsec@file After this, the per-router entry is redundant but harmless.\nTest that blocking actually works # 1. ban your phone\u0026#39;s cellular IP for 10 minutes docker exec crowdsec cscli decisions add --ip \u0026lt;PHONE-IP\u0026gt; --duration 10m # 2. wait 60-90 seconds (live mode caches \u0026#34;not banned\u0026#34; results) # 3. reload the site on cellular in a private tab; a blank page is a bare 403 # 4. confirm in the log grep \u0026lt;PHONE-IP\u0026gt; /opt/stacks/traefik/logs/access.log | tail -3 | grep -o \u0026#39;\u0026#34;DownstreamStatus\u0026#34;:[0-9]*\u0026#39; # 5. clean up docker exec crowdsec cscli decisions delete --ip \u0026lt;PHONE-IP\u0026gt; Never ban your router\u0026rsquo;s LAN address. Traffic that loops back through the gateway can appear as that address, so banning it blocks everything that arrives that way.\nDay-to-day commands docker exec crowdsec cscli metrics # logs read/parsed, scenarios triggered docker exec crowdsec cscli alerts list # what got flagged, and why docker exec crowdsec cscli decisions list # active bans docker exec crowdsec cscli decisions add --ip X --duration 4h docker exec crowdsec cscli decisions delete --ip X docker exec crowdsec cscli bouncers list # bouncer health docker exec crowdsec cscli hub update \u0026amp;\u0026amp; docker exec crowdsec cscli hub upgrade Troubleshooting Symptom Likely cause and fix Mount error \u0026ldquo;not a directory\u0026rdquo; for acquis.yaml Docker created a directory. Remove it, create the real file, start again middleware \u0026quot;default-headers@file\u0026quot; does not exist everywhere Duplicate middlewares: key in config.yml Edits to config.yml are ignored Stale single-file mount; docker compose up -d --force-recreate traefik cscli metrics shows 0 lines read Traefik isn\u0026rsquo;t writing the log, or the volume path is wrong Bouncer has no \u0026ldquo;Last API pull\u0026rdquo; Middleware isn\u0026rsquo;t on a router that has seen traffic, or the containers aren\u0026rsquo;t on the same network Every request comes from a 172.x address The client IP is masked before Traefik; check port forwarding and Docker networking Plugin error at startup Version typo, or no outbound access to GitHub Locked yourself out docker exec crowdsec cscli decisions delete --ip \u0026lt;your-ip\u0026gt; and check the allowlist Done checklist cscli metrics shows access.log lines read and parsed cscli bouncers list shows a recent \u0026ldquo;Last API pull\u0026rdquo; Public IPs appear in ClientHost The block test returns 403 on cellular The home allowlist holds your current IP and the cron job is installed config.yml has exactly one middlewares: key ","permalink":"http://liyafixes.dev/posts/crowdsec-traefik-setup/","summary":"\u003cp\u003eIf you expose self-hosted apps to the internet through Traefik, you will see scanners and brute-force attempts within hours. CrowdSec reads Traefik\u0026rsquo;s access log, spots attack patterns, and tells a Traefik plugin to return \u003ccode\u003e403\u003c/code\u003e to the offenders. This guide walks through the full setup with Docker Compose.\u003c/p\u003e\n\u003ch2 id=\"how-it-fits-together\"\u003eHow it fits together\u003c/h2\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eInternet → Traefik (https entrypoint) → crowdsec@file middleware → app\n              │                               │\n              │ writes JSON access log        │ asks \u0026#34;is this IP banned?\u0026#34;\n              ▼                               ▼\n        ./traefik/logs  ──────────►  CrowdSec container (reads log, detects, decides)\n\u003c/code\u003e\u003c/pre\u003e\u003col\u003e\n\u003cli\u003e\u003cstrong\u003eTraefik\u003c/strong\u003e writes a JSON access log.\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eThe CrowdSec engine\u003c/strong\u003e reads that log, matches attack scenarios, and creates ban decisions. It also pulls the community blocklist.\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eThe bouncer\u003c/strong\u003e is a Traefik plugin, not a separate container. It asks CrowdSec\u0026rsquo;s local API whether an IP is banned and returns \u003ccode\u003e403\u003c/code\u003e if so.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cblockquote\u003e\n\u003cp\u003eCrowdSec ignores private ranges (\u003ccode\u003e10.x\u003c/code\u003e, \u003ccode\u003e172.16-31.x\u003c/code\u003e, \u003ccode\u003e192.168.x\u003c/code\u003e) by default, so LAN traffic can\u0026rsquo;t get banned.\u003c/p\u003e\n\u003c/blockquote\u003e","title":"How to Protect Traefik Services with CrowdSec"},{"content":"authentik upgrades are usually painless, until an LDAP or proxy outpost keeps running the old image and your NAS logins or forward-auth apps start acting strange. This is the routine I use for a Docker Compose install behind Traefik, plus a from-scratch setup at the end.\nGotchas to know first sudo cmd \u0026gt; file fails in root-owned directories, because the redirect runs as your user. Write backups to ~/ (or pipe to sudo tee). Keep backups outside the stack directory. Outposts on the Local Docker connection don\u0026rsquo;t reliably redeploy after a server upgrade. docker stop then docker start does nothing useful: the container comes back on the same old image. It has to be removed so authentik recreates it. The compose file is now compose.yml (it was docker-compose.yml before 2026.2). Diff before overwriting so you don\u0026rsquo;t lose custom Traefik labels. AUTHENTIK_POSTGRESQL__CONN_OPTIONS is deprecated; remove it from .env. 2026.8 rewrote the proxy outpost, so re-test any forward-auth apps after major upgrades. Upgrading Move one release family at a time. Patch bumps are routine; read the release notes before major bumps.\ncd /opt/stacks/authentik # 1. Back up the database sudo docker compose exec postgresql pg_dumpall -c -U ${PG_USER:-authentik} \u0026gt; ~/authentik_backup_$(date +%Y%m%d).sql # 2. (Major bumps only) fetch the new compose file, diff it, reapply your labels wget -O compose.new.yml https://goauthentik.io/version/\u0026lt;YYYY.M\u0026gt;/lifecycle/container/compose.yml diff compose.yml compose.new.yml # 3. Bump the tag in .env # AUTHENTIK_TAG=\u0026lt;new version\u0026gt; # 4. Pull and restart sudo docker compose pull sudo docker compose up -d # 5. Watch the migrations finish sudo docker compose logs -f worker Fixing outpost version drift Applications → Outposts flags any outpost that doesn\u0026rsquo;t match the server version.\n# find the outpost containers sudo docker ps --format \u0026#39;{{.Names}}\\t{{.Image}}\u0026#39; | grep -i outpost # remove (don\u0026#39;t just stop) so authentik recreates it on the new image sudo docker rm -f ak-outpost-ldap-outpost # wait about a minute, then confirm the new tag sudo docker ps --format \u0026#39;{{.Names}}\\t{{.Image}}\u0026#39; | grep -i outpost If it doesn\u0026rsquo;t come back, or comes back on the old tag:\nApplications → Outposts → edit the outpost and click Update to force a reconcile. Admin → Integrations → open the Local Docker connection and run its test/refresh. Run the docker rm -f again. Confirm the server containers themselves are on the new tag (docker ps | grep authentik). Post-upgrade checklist Admin → Dashboards → Overview shows the new version All outposts are Healthy with no version warning Apps behind forward-auth load through their normal URLs LDAP logins (for example from a NAS) still work Setting up from scratch sudo mkdir -p /opt/stacks/authentik \u0026amp;\u0026amp; cd /opt/stacks/authentik # Official compose file for the release you want sudo wget -O compose.yml https://goauthentik.io/version/\u0026lt;YYYY.M\u0026gt;/lifecycle/container/compose.yml # Secrets and version pin echo \u0026#34;PG_PASS=$(openssl rand -base64 36 | tr -d \u0026#39;\\n\u0026#39;)\u0026#34; | sudo tee -a .env echo \u0026#34;AUTHENTIK_SECRET_KEY=$(openssl rand -base64 60 | tr -d \u0026#39;\\n\u0026#39;)\u0026#34; | sudo tee -a .env echo \u0026#34;AUTHENTIK_TAG=\u0026lt;version\u0026gt;\u0026#34; | sudo tee -a .env sudo docker compose pull sudo docker compose up -d Open http://\u0026lt;host\u0026gt;:9000/if/flow/initial-setup/ and set the akadmin password. Add your Traefik router labels to the server service and attach it to the Traefik network. Leave the Docker socket mount on the worker intact. The Local Docker connection needs it to spawn outposts. LDAP outpost (for a NAS or other LDAP client) Create an LDAP provider and an application for it. Applications → Outposts → Create: type LDAP, integration Local Docker connection, and attach the application. authentik spawns an ak-outpost-... container. Check it with docker ps. Point your NAS at the host\u0026rsquo;s LDAP port using the bind DN and base DN shown on the provider. Proxy outposts (forward-auth apps) Create a Proxy provider per app, add each to a proxy outpost on the Local Docker connection, and keep your Traefik router labels in step with the forward-auth middleware.\nBackup and restore # backup sudo docker compose exec postgresql pg_dumpall -c -U ${PG_USER:-authentik} \u0026gt; ~/authentik_backup_$(date +%Y%m%d).sql # restore (stack running, fresh database) cat ~/authentik_backup_YYYYMMDD.sql | sudo docker compose exec -T postgresql psql -U ${PG_USER:-authentik} postgres If migrations fail during an upgrade, restore the backup and pin the old tag rather than pushing forward.\n","permalink":"http://liyafixes.dev/posts/upgrade-authentik-docker/","summary":"\u003cp\u003eauthentik upgrades are usually painless, until an LDAP or proxy outpost keeps running the old image and your NAS logins or forward-auth apps start acting strange. This is the routine I use for a Docker Compose install behind Traefik, plus a from-scratch setup at the end.\u003c/p\u003e\n\u003ch2 id=\"gotchas-to-know-first\"\u003eGotchas to know first\u003c/h2\u003e\n\u003cul\u003e\n\u003cli\u003e\u003ccode\u003esudo cmd \u0026gt; file\u003c/code\u003e fails in root-owned directories, because the redirect runs as your user. Write backups to \u003ccode\u003e~/\u003c/code\u003e (or pipe to \u003ccode\u003esudo tee\u003c/code\u003e).\u003c/li\u003e\n\u003cli\u003eKeep backups \u003cstrong\u003eoutside\u003c/strong\u003e the stack directory.\u003c/li\u003e\n\u003cli\u003eOutposts on the \u003cstrong\u003eLocal Docker connection\u003c/strong\u003e don\u0026rsquo;t reliably redeploy after a server upgrade.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003edocker stop\u003c/code\u003e then \u003ccode\u003edocker start\u003c/code\u003e does nothing useful: the container comes back on the same old image. It has to be \u003cstrong\u003eremoved\u003c/strong\u003e so authentik recreates it.\u003c/li\u003e\n\u003cli\u003eThe compose file is now \u003ccode\u003ecompose.yml\u003c/code\u003e (it was \u003ccode\u003edocker-compose.yml\u003c/code\u003e before 2026.2). Diff before overwriting so you don\u0026rsquo;t lose custom Traefik labels.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003eAUTHENTIK_POSTGRESQL__CONN_OPTIONS\u003c/code\u003e is deprecated; remove it from \u003ccode\u003e.env\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003e2026.8 rewrote the proxy outpost, so re-test any forward-auth apps after major upgrades.\u003c/li\u003e\n\u003c/ul\u003e\n\u003ch2 id=\"upgrading\"\u003eUpgrading\u003c/h2\u003e\n\u003cp\u003eMove one release family at a time. Patch bumps are routine; read the \u003ca href=\"https://docs.goauthentik.io/releases/\"\u003erelease notes\u003c/a\u003e before major bumps.\u003c/p\u003e","title":"How to Upgrade (and Set Up) authentik on Docker Compose Without Breaking Outposts"},{"content":"The Adafruit MacroPad RP2040 packs 12 mechanical keys with RGB LEDs, a rotary encoder, and a tiny OLED into one board you program in CircuitPython. Before writing any code, it helps to plan what each key does. Here\u0026rsquo;s how I laid mine out.\nThe layout Input Action How Encoder turn Volume up/down Consumer Control VOLUME_INCREMENT / DECREMENT Encoder click Play/pause Consumer Control PLAY_PAUSE Key 1 Open my homelab dashboard Win+R, type the URL, Enter Key 2 Quick search Alt+Space (PowerToys Run / Command Palette) Key 3 File Explorer Win+E Key 4 Desk LEDs on/off Home Assistant service call Key 5 Cycle desk LED effect Home Assistant script Key 6 Screenshot Win+Shift+S Keys 7-10 Spare Room to grow Key 11 System mute Consumer Control MUTE Key 12 Discord mute Alt+M (set as Discord\u0026rsquo;s mute keybind), LED red when muted, green when live The OLED: bongo cat The screen shows a bongo cat all the time:\nNo keys pressed: paws up. Any key pressed: paws down on the table. It\u0026rsquo;s just two bitmaps swapped based on whether any key is held, which is easy to do with displayio and a small sprite sheet.\nGetting started in CircuitPython Install the latest CircuitPython for the MacroPad from circuitpython.org. Copy the adafruit_macropad library (and its dependencies) from the library bundle into CIRCUITPY/lib. Start from a simple code.py: from adafruit_macropad import MacroPad macropad = MacroPad() last_position = macropad.encoder while True: # encoder -\u0026gt; volume position = macropad.encoder if position \u0026gt; last_position: macropad.consumer_control.send(macropad.ConsumerControlCode.VOLUME_INCREMENT) elif position \u0026lt; last_position: macropad.consumer_control.send(macropad.ConsumerControlCode.VOLUME_DECREMENT) last_position = position # encoder click -\u0026gt; play/pause macropad.encoder_switch_debounced.update() if macropad.encoder_switch_debounced.pressed: macropad.consumer_control.send(macropad.ConsumerControlCode.PLAY_PAUSE) # keys event = macropad.keys.events.get() if event and event.pressed: if event.key_number == 2: # Key 3: File Explorer macropad.keyboard.send(macropad.Keycode.WINDOWS, macropad.Keycode.E) Keys are numbered 0-11 in code, so \u0026ldquo;Key 3\u0026rdquo; in the table is key_number == 2.\nHome Assistant buttons The MacroPad is just a USB keyboard, so it can\u0026rsquo;t call Home Assistant directly. Two easy options:\nKeyboard shortcut + automation: send an unused combo like Ctrl+Alt+F13 and have a desktop tool (AutoHotkey, or the HASS.Agent app on Windows) call the Home Assistant service. Open a URL: point a key at a Home Assistant webhook automation. The Discord mute LED The MacroPad can\u0026rsquo;t know Discord\u0026rsquo;s real mute state, so the LED just tracks presses of the key: toggle a variable each time it\u0026rsquo;s pressed and set macropad.pixels[11] to red or green. If you mute with the mouse, it\u0026rsquo;ll drift out of sync. Press the key twice to fix it.\nKey icons If you print key labels or show icons on the OLED, free icon sets like Icons8 have matching styles for home, search, folder, lamp and list icons.\n","permalink":"http://liyafixes.dev/posts/circuitpython-macropad-shortcuts/","summary":"\u003cp\u003eThe \u003ca href=\"https://www.adafruit.com/product/5128\"\u003eAdafruit MacroPad RP2040\u003c/a\u003e packs 12 mechanical keys with RGB LEDs, a rotary encoder, and a tiny OLED into one board you program in CircuitPython. Before writing any code, it helps to plan what each key does. Here\u0026rsquo;s how I laid mine out.\u003c/p\u003e\n\u003ch2 id=\"the-layout\"\u003eThe layout\u003c/h2\u003e\n\u003ctable\u003e\n\t\u003cthead\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003cth\u003eInput\u003c/th\u003e\n\t\t\t\t\t\u003cth\u003eAction\u003c/th\u003e\n\t\t\t\t\t\u003cth\u003eHow\u003c/th\u003e\n\t\t\t\u003c/tr\u003e\n\t\u003c/thead\u003e\n\t\u003ctbody\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eEncoder turn\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eVolume up/down\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eConsumer Control \u003ccode\u003eVOLUME_INCREMENT\u003c/code\u003e / \u003ccode\u003eDECREMENT\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eEncoder click\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003ePlay/pause\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eConsumer Control \u003ccode\u003ePLAY_PAUSE\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eKey 1\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eOpen my homelab dashboard\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e\u003ccode\u003eWin+R\u003c/code\u003e, type the URL, \u003ccode\u003eEnter\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eKey 2\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eQuick search\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e\u003ccode\u003eAlt+Space\u003c/code\u003e (PowerToys Run / Command Palette)\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eKey 3\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eFile Explorer\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e\u003ccode\u003eWin+E\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eKey 4\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eDesk LEDs on/off\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eHome Assistant service call\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eKey 5\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eCycle desk LED effect\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eHome Assistant script\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eKey 6\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eScreenshot\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e\u003ccode\u003eWin+Shift+S\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eKeys 7-10\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eSpare\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eRoom to grow\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eKey 11\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eSystem mute\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eConsumer Control \u003ccode\u003eMUTE\u003c/code\u003e\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\t\t\u003ctr\u003e\n\t\t\t\t\t\u003ctd\u003eKey 12\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003eDiscord mute\u003c/td\u003e\n\t\t\t\t\t\u003ctd\u003e\u003ccode\u003eAlt+M\u003c/code\u003e (set as Discord\u0026rsquo;s mute keybind), LED red when muted, green when live\u003c/td\u003e\n\t\t\t\u003c/tr\u003e\n\t\u003c/tbody\u003e\n\u003c/table\u003e\n\u003ch2 id=\"the-oled-bongo-cat\"\u003eThe OLED: bongo cat\u003c/h2\u003e\n\u003cp\u003eThe screen shows a bongo cat all the time:\u003c/p\u003e","title":"How to Plan a CircuitPython Macropad Layout (with a Bongo Cat Screen)"},{"content":"Minecraft Bedrock on consoles makes it awkward to join custom servers, but every client will happily join a game listed under LAN Games. Phantom is a small proxy that makes a remote Bedrock server appear on your local network. Running it on your router means it\u0026rsquo;s always on and starts on boot, with no PC left running.\nGL.iNet routers run OpenWrt underneath, so this works on most OpenWrt devices too.\nStep 1: Get a shell on the router Open the router\u0026rsquo;s admin panel, go to Applications → Plugins, and install nano (optional, but easier than vi). SSH in. The password is the same as the admin panel password: ssh root@\u0026lt;router-ip\u0026gt; Step 2: Put the Phantom binary on the router Check the router\u0026rsquo;s CPU architecture: uname -m Download the matching build from the Phantom releases page and copy it to /root/phantom (for example with scp). Make it executable: chmod +x /root/phantom Step 3: Create a procd service OpenWrt manages services with procd, which is different from the SysV init.d scripts on Debian or Ubuntu. Create /etc/init.d/phantom with this content, replacing mc.example.com with your server\u0026rsquo;s address:\n#!/bin/sh /etc/rc.common USE_PROCD=1 START=99 start_service() { rm -f /tmp/phantom.log procd_open_instance procd_set_param command /bin/sh -c \u0026#39; for i in $(seq 1 30); do if nslookup mc.example.com \u0026gt;/dev/null 2\u0026gt;\u0026amp;1; then exec /root/phantom -server mc.example.com:19132 \u0026gt;\u0026gt;/tmp/phantom.log 2\u0026gt;\u0026amp;1 fi sleep 2 done exit 1 \u0026#39; procd_set_param respawn procd_close_instance } Why the DNS wait loop? On boot, the router may start services before the WAN link or DNS is up. The loop retries the lookup every 2 seconds for up to 60 seconds before launching Phantom. If DNS never resolves, the script exits and respawn tries again.\nStep 4: Enable and start it chmod +x /etc/init.d/phantom /etc/init.d/phantom enable # start on boot /etc/init.d/phantom start # start now Open Minecraft on any device on your network and check the Friends → LAN Games list. Your server should be there.\nUseful commands /etc/init.d/phantom stop /etc/init.d/phantom restart /etc/init.d/phantom enabled # exit code 0 means it\u0026#39;s set to start on boot logread | grep phantom # procd/system log cat /tmp/phantom.log # Phantom\u0026#39;s own output /tmp on OpenWrt is RAM-backed and wiped on reboot, so the log won\u0026rsquo;t grow forever and doesn\u0026rsquo;t need rotating.\nDebian or Ubuntu instead? On a regular Linux box, skip the init script and use a systemd unit:\n# /etc/systemd/system/phantom.service [Unit] Description=Phantom - show remote Bedrock server as a LAN game Wants=network-online.target After=network-online.target [Service] ExecStart=/usr/local/bin/phantom -server mc.example.com:19132 Restart=on-failure RestartSec=5 [Install] WantedBy=multi-user.target sudo systemctl daemon-reload sudo systemctl enable --now phantom References Phantom on GitHub OpenWrt init scripts ","permalink":"http://liyafixes.dev/posts/phantom-bedrock-glinet-router/","summary":"\u003cp\u003eMinecraft Bedrock on consoles makes it awkward to join custom servers, but every client will happily join a game listed under \u003cstrong\u003eLAN Games\u003c/strong\u003e. \u003ca href=\"https://github.com/jhead/phantom\"\u003ePhantom\u003c/a\u003e is a small proxy that makes a remote Bedrock server appear on your local network. Running it on your router means it\u0026rsquo;s always on and starts on boot, with no PC left running.\u003c/p\u003e\n\u003cp\u003eGL.iNet routers run OpenWrt underneath, so this works on most OpenWrt devices too.\u003c/p\u003e\n\u003ch2 id=\"step-1-get-a-shell-on-the-router\"\u003eStep 1: Get a shell on the router\u003c/h2\u003e\n\u003col\u003e\n\u003cli\u003eOpen the router\u0026rsquo;s admin panel, go to \u003cstrong\u003eApplications → Plugins\u003c/strong\u003e, and install \u003ccode\u003enano\u003c/code\u003e (optional, but easier than \u003ccode\u003evi\u003c/code\u003e).\u003c/li\u003e\n\u003cli\u003eSSH in. The password is the same as the admin panel password:\u003c/li\u003e\n\u003c/ol\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" class=\"chroma\"\u003e\u003ccode class=\"language-bash\" data-lang=\"bash\"\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003essh root@\u0026lt;router-ip\u0026gt;\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003ch2 id=\"step-2-put-the-phantom-binary-on-the-router\"\u003eStep 2: Put the Phantom binary on the router\u003c/h2\u003e\n\u003col\u003e\n\u003cli\u003eCheck the router\u0026rsquo;s CPU architecture:\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" class=\"chroma\"\u003e\u003ccode class=\"language-bash\" data-lang=\"bash\"\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003euname -m\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003c/li\u003e\n\u003cli\u003eDownload the matching build from the \u003ca href=\"https://github.com/jhead/phantom/releases\"\u003ePhantom releases page\u003c/a\u003e and copy it to \u003ccode\u003e/root/phantom\u003c/code\u003e (for example with \u003ccode\u003escp\u003c/code\u003e).\u003c/li\u003e\n\u003cli\u003eMake it executable:\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" class=\"chroma\"\u003e\u003ccode class=\"language-bash\" data-lang=\"bash\"\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003echmod +x /root/phantom\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003c/li\u003e\n\u003c/ol\u003e\n\u003ch2 id=\"step-3-create-a-procd-service\"\u003eStep 3: Create a procd service\u003c/h2\u003e\n\u003cp\u003eOpenWrt manages services with \u003cstrong\u003eprocd\u003c/strong\u003e, which is different from the SysV \u003ccode\u003einit.d\u003c/code\u003e scripts on Debian or Ubuntu. Create \u003ccode\u003e/etc/init.d/phantom\u003c/code\u003e with this content, replacing \u003ccode\u003emc.example.com\u003c/code\u003e with your server\u0026rsquo;s address:\u003c/p\u003e","title":"How to Run Phantom on a GL.iNet Router So Remote Minecraft Bedrock Servers Show Up as LAN Games"},{"content":"Apprise sends a notification to almost any service using a single URL format. It\u0026rsquo;s great for cron jobs, backup scripts, and anything else that should tell you when it finishes or fails.\nInstall pip install apprise # or: brew install apprise The basic shape apprise -vv -t \u0026#34;Title\u0026#34; -b \u0026#34;Body\u0026#34; \u0026#34;\u0026lt;service-url\u0026gt;\u0026#34; -v adds verbosity; stack them (-vv, -vvv) when debugging.\nSend to several services at once Just list more URLs:\napprise -vv --body=\u0026#34;Backup finished\u0026#34; \\ \u0026#34;mailto://user:password@example.com\u0026#34; \\ \u0026#34;slack://token_a/token_b/token_c\u0026#34; \\ \u0026#34;kodi://media-box.local\u0026#34; Service examples Gmail Gmail needs an app password (Google Account → Security → App passwords), not your normal password. Turn on 2-step verification first.\napprise -b \u0026#34;My message\u0026#34; \u0026#34;mailto://your.name:APP_PASSWORD@gmail.com\u0026#34; macOS notification centre apprise -vv -t \u0026#34;Test title\u0026#34; -b \u0026#34;Test body\u0026#34; \u0026#34;macosx://\u0026#34; Discord Create a webhook (Channel Settings → Integrations → Webhooks). Its URL looks like https://discord.com/api/webhooks/\u0026lt;id\u0026gt;/\u0026lt;token\u0026gt;. Apprise takes the same two parts:\napprise -vv -t \u0026#34;Test title\u0026#34; -b \u0026#34;Test body\u0026#34; \u0026#34;discord://\u0026lt;id\u0026gt;/\u0026lt;token\u0026gt;/\u0026#34; Got a 401 error? Make sure you copied the token exactly. It often contains hyphens and underscores, and dropping or changing one character gives a verification failure. You can also paste the full https://discord.com/api/webhooks/... URL straight into Apprise.\nMatrix apprise -vv -t \u0026#34;Test title\u0026#34; -b \u0026#34;Test body\u0026#34; \u0026#34;matrixs://user:password@matrix.example.com/!roomid\u0026#34; \u0026ldquo;Event not found\u0026rdquo;? Check the room ID (it starts with !, not #), that the account has joined the room, and that the homeserver allows password logins. Some bridged or hosted services (Beeper, for example) don\u0026rsquo;t support it, so a dedicated bot account on a regular homeserver is more reliable.\nHome Assistant Create a long-lived access token in your Home Assistant profile:\napprise -vvv \u0026#34;hassio://homeassistant.local/\u0026lt;long-lived-token\u0026gt;\u0026#34; Use hassios:// if Home Assistant is behind HTTPS.\nCommand just hangs? Check the host and port (hassio://host:8123/token), and that the machine running Apprise can actually reach Home Assistant.\nKeep secrets out of your shell history Every one of these URLs contains a password or token. Instead of typing them inline, put them in a config file only you can read:\nmkdir -p ~/.config/apprise cat \u0026gt; ~/.config/apprise/apprise.yml \u0026lt;\u0026lt;\u0026#39;EOF\u0026#39; urls: - discord://\u0026lt;id\u0026gt;/\u0026lt;token\u0026gt;/: tag: discord - mailto://your.name:APP_PASSWORD@gmail.com: tag: email EOF chmod 600 ~/.config/apprise/apprise.yml Apprise reads that file automatically, and you pick services by tag:\napprise -t \u0026#34;Backup\u0026#34; -b \u0026#34;Done\u0026#34; --tag=discord If a token ever ends up in a screenshot, a note, or git, revoke it and make a new one. Webhook URLs and app passwords are as good as a password to whoever has them.\n","permalink":"http://liyafixes.dev/posts/apprise-notifications-cheat-sheet/","summary":"\u003cp\u003e\u003ca href=\"https://github.com/caronc/apprise\"\u003eApprise\u003c/a\u003e sends a notification to almost any service using a single URL format. It\u0026rsquo;s great for cron jobs, backup scripts, and anything else that should tell you when it finishes or fails.\u003c/p\u003e\n\u003ch2 id=\"install\"\u003eInstall\u003c/h2\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" class=\"chroma\"\u003e\u003ccode class=\"language-bash\" data-lang=\"bash\"\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003epip install apprise      \u003cspan class=\"c1\"\u003e# or: brew install apprise\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003ch2 id=\"the-basic-shape\"\u003eThe basic shape\u003c/h2\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" class=\"chroma\"\u003e\u003ccode class=\"language-bash\" data-lang=\"bash\"\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003eapprise -vv -t \u003cspan class=\"s2\"\u003e\u0026#34;Title\u0026#34;\u003c/span\u003e -b \u003cspan class=\"s2\"\u003e\u0026#34;Body\u0026#34;\u003c/span\u003e \u003cspan class=\"s2\"\u003e\u0026#34;\u0026lt;service-url\u0026gt;\u0026#34;\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003e\u003ccode\u003e-v\u003c/code\u003e adds verbosity; stack them (\u003ccode\u003e-vv\u003c/code\u003e, \u003ccode\u003e-vvv\u003c/code\u003e) when debugging.\u003c/p\u003e\n\u003ch2 id=\"send-to-several-services-at-once\"\u003eSend to several services at once\u003c/h2\u003e\n\u003cp\u003eJust list more URLs:\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" class=\"chroma\"\u003e\u003ccode class=\"language-bash\" data-lang=\"bash\"\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003eapprise -vv --body\u003cspan class=\"o\"\u003e=\u003c/span\u003e\u003cspan class=\"s2\"\u003e\u0026#34;Backup finished\u0026#34;\u003c/span\u003e \u003cspan class=\"se\"\u003e\\\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e   \u003cspan class=\"s2\"\u003e\u0026#34;mailto://user:password@example.com\u0026#34;\u003c/span\u003e \u003cspan class=\"se\"\u003e\\\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e   \u003cspan class=\"s2\"\u003e\u0026#34;slack://token_a/token_b/token_c\u0026#34;\u003c/span\u003e \u003cspan class=\"se\"\u003e\\\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e   \u003cspan class=\"s2\"\u003e\u0026#34;kodi://media-box.local\u0026#34;\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003ch2 id=\"service-examples\"\u003eService examples\u003c/h2\u003e\n\u003ch3 id=\"gmail\"\u003eGmail\u003c/h3\u003e\n\u003cp\u003eGmail needs an \u003cstrong\u003eapp password\u003c/strong\u003e (Google Account → Security → App passwords), not your normal password. Turn on 2-step verification first.\u003c/p\u003e","title":"How to Send Notifications Anywhere with Apprise (Email, Discord, Matrix, Home Assistant)"},{"content":"I upgraded nearly everything in my desktop (CPU, motherboard, RAM and GPU) but kept the old SSD, case and fans. On first boot it blue-screened over and over during light use: a Discord call and a browser. Resetting Windows didn\u0026rsquo;t fix it.\nWhen you see a different stop code almost every crash, that\u0026rsquo;s a clue. It usually means something low-level (memory, CPU stability, firmware or a driver) is corrupting whatever happens to be running, rather than one specific broken program.\nWhat the stop codes mean Code Name Usually points to 0x0000003B SYSTEM_SERVICE_EXCEPTION Driver or memory fault in a system call 0x00000109 CRITICAL_STRUCTURE_CORRUPTION Kernel data corrupted; often RAM or a bad driver 0x00000050 PAGE_FAULT_IN_NONPAGED_AREA Invalid memory referenced; RAM or driver 0x0000007F UNEXPECTED_KERNEL_MODE_TRAP CPU trap; often unstable CPU/RAM settings 0x0000000A IRQL_NOT_LESS_OR_EQUAL Driver accessing memory it shouldn\u0026rsquo;t 0x0000007E SYSTEM_THREAD_EXCEPTION_NOT_HANDLED Driver crash in a system thread 0x0000001A MEMORY_MANAGEMENT Serious memory management error; very often RAM 0x00000133 DPC_WATCHDOG_VIOLATION Driver or storage controller hanging Notice the theme: memory and drivers.\nStep 1: Update the BIOS and reset memory settings New boards often ship with early firmware that has memory-compatibility bugs.\nUpdate the motherboard BIOS to the latest version from the manufacturer\u0026rsquo;s site. Load optimized defaults. Turn off XMP/EXPO for now and test at stock memory speed. If the crashes stop, your RAM kit is unstable at its rated profile on this board/CPU. Step 2: Test the RAM Run Windows Memory Diagnostic (mdsched.exe) as a quick check. For a thorough test, boot MemTest86 from a USB stick and let it run several passes. If you have two sticks, test one at a time in the slot the manual recommends. Any error at all means a bad stick, bad settings, or a seating problem. Reseat the RAM and try again.\nStep 3: Repair Windows system files Open Terminal (Admin) and run:\nsfc /scannow DISM.exe /Online /Cleanup-Image /RestoreHealth Run sfc /scannow a second time after DISM finishes.\nStep 4: Clean up old drivers Carrying an old Windows install over to new hardware is a classic cause of this. Old chipset, storage and GPU drivers stay around.\nInstall the chipset drivers for your new motherboard from the board or CPU maker. Use DDU (Display Driver Uninstaller) in Safe Mode to remove old GPU drivers, then install fresh ones. Remove old motherboard utilities (RGB software, fan controllers, tuning apps) from the previous system. If none of that helps, a truly clean install is better than a \u0026ldquo;reset\u0026rdquo;: back up your files, create a USB installer with the Media Creation Tool, and delete the old partitions during setup.\nStep 5: Read the dump files Install WinDbg from the Microsoft Store, open a file from C:\\Windows\\Minidump, and run:\n!analyze -v Look for the MODULE_NAME / IMAGE_NAME line. If it keeps naming the same driver (a .sys file), you\u0026rsquo;ve found your suspect.\nStep 6: Check the hardware basics Make sure the 24-pin and CPU 8-pin power cables are fully seated. Confirm your PSU is big enough for the new parts, and the GPU has its own PCIe power cables rather than one daisy-chained cable. Check CPU temperatures under load with HWiNFO. The short version BIOS update → defaults → XMP/EXPO off MemTest86 sfc + DISM New chipset drivers, DDU for GPU, remove old utilities Clean install if it\u0026rsquo;s still crashing Read the minidumps to find the driver ","permalink":"http://liyafixes.dev/posts/fix-bsod-after-pc-upgrade/","summary":"\u003cp\u003eI upgraded nearly everything in my desktop (CPU, motherboard, RAM and GPU) but kept the old SSD, case and fans. On first boot it blue-screened over and over during light use: a Discord call and a browser. Resetting Windows didn\u0026rsquo;t fix it.\u003c/p\u003e\n\u003cp\u003eWhen you see a \u003cem\u003edifferent\u003c/em\u003e stop code almost every crash, that\u0026rsquo;s a clue. It usually means something low-level (memory, CPU stability, firmware or a driver) is corrupting whatever happens to be running, rather than one specific broken program.\u003c/p\u003e","title":"How to Troubleshoot Constant Blue Screens After a PC Upgrade"},{"content":"A running list of commands I keep having to look up. Bookmark it and steal whatever is useful.\nmacOS Back up your list of installed apps Handy before reinstalling macOS or setting up a new Mac:\nbrew list \u0026gt; ~/Desktop/brew_installed_apps.txt mas list \u0026gt; ~/Desktop/macappstore_apps.txt # needs: brew install mas Better still, make a Brewfile that can reinstall everything in one go:\nbrew bundle dump --file=~/Desktop/Brewfile brew bundle --file=~/Desktop/Brewfile # on the new Mac Download a video with yt-dlp brew install yt-dlp ffmpeg # as MP4 yt-dlp --recode-video mp4 \u0026#34;URL\u0026#34; # audio only, as MP3 yt-dlp -x --audio-format mp3 \u0026#34;URL\u0026#34; Only download things you have the right to keep.\nWindows Repair system files Run in Terminal (Admin):\nsfc /scannow DISM.exe /Online /Cleanup-Image /RestoreHealth Run sfc again after DISM. This is my first step whenever Windows starts acting strangely.\nTurn off Focused Inbox in the new Outlook There\u0026rsquo;s no simple toggle any more. Go to Settings (gear) → Mail → Layout, and under Focused Inbox choose Don\u0026rsquo;t sort my messages, then Save.\nLinux Rescue a Home Assistant backup from the command line If Home Assistant OS won\u0026rsquo;t boot properly but you can get to a shell, you can copy the backups off the data partition and make a fresh one:\n# find the right disk and partition lsblk -o+FSTYPE,MODEL # mount it somewhere temporary mkdir -p /mnt/data/temp/backup mount /dev/sdX2 /mnt/data/temp/backup # replace sdX2 with your partition # copy the existing backups across cp -Rv /mnt/data/supervisor/backup/* /mnt/data/temp/backup/ umount /mnt/data/temp/backup/ # create a new full backup ha backup new --name \u0026#34;fullbackup\u0026#34; Double-check the device name from lsblk before mounting anything.\nBrowsers Force dark mode on every site in Brave or Chrome Paste this into the address bar and set it to Enabled:\nbrave://flags/#enable-force-dark In Chrome it\u0026rsquo;s chrome://flags/#enable-force-dark.\n","permalink":"http://liyafixes.dev/posts/handy-terminal-commands/","summary":"\u003cp\u003eA running list of commands I keep having to look up. Bookmark it and steal whatever is useful.\u003c/p\u003e\n\u003ch2 id=\"macos\"\u003emacOS\u003c/h2\u003e\n\u003ch3 id=\"back-up-your-list-of-installed-apps\"\u003eBack up your list of installed apps\u003c/h3\u003e\n\u003cp\u003eHandy before reinstalling macOS or setting up a new Mac:\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" class=\"chroma\"\u003e\u003ccode class=\"language-bash\" data-lang=\"bash\"\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003ebrew list \u0026gt; ~/Desktop/brew_installed_apps.txt\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003emas list \u0026gt; ~/Desktop/macappstore_apps.txt    \u003cspan class=\"c1\"\u003e# needs: brew install mas\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003eBetter still, make a Brewfile that can reinstall everything in one go:\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" class=\"chroma\"\u003e\u003ccode class=\"language-bash\" data-lang=\"bash\"\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003ebrew bundle dump --file\u003cspan class=\"o\"\u003e=\u003c/span\u003e~/Desktop/Brewfile\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003ebrew bundle --file\u003cspan class=\"o\"\u003e=\u003c/span\u003e~/Desktop/Brewfile         \u003cspan class=\"c1\"\u003e# on the new Mac\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003ch3 id=\"download-a-video-with-yt-dlp\"\u003eDownload a video with yt-dlp\u003c/h3\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" class=\"chroma\"\u003e\u003ccode class=\"language-bash\" data-lang=\"bash\"\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003ebrew install yt-dlp ffmpeg\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e\u003cspan class=\"c1\"\u003e# as MP4\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003eyt-dlp --recode-video mp4 \u003cspan class=\"s2\"\u003e\u0026#34;URL\u0026#34;\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003e\u003cspan class=\"c1\"\u003e# audio only, as MP3\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"line\"\u003e\u003cspan class=\"cl\"\u003eyt-dlp -x --audio-format mp3 \u003cspan class=\"s2\"\u003e\u0026#34;URL\u0026#34;\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003eOnly download things you have the right to keep.\u003c/p\u003e","title":"Handy Terminal Commands I Keep Coming Back To (macOS, Windows, Linux)"},{"content":"You run docker compose up on a new stack and get this:\nfailed to create network file-browser_default: Error response from daemon: all predefined address pools have been fully subnetted Every Compose project gets its own bridge network, and Docker\u0026rsquo;s default pools (172.17-31.0.0/16 plus some 192.168.x.x blocks) only stretch so far. Once you have a few dozen stacks, you run out.\nI hit this on an ASUSTOR NAS running Docker CE from App Central, which has some quirks: no systemd, a BusyBox shell, and sudo needed for every Docker command. The fix works on any Linux host; only the restart step differs.\nStep 1: Define a bigger address pool sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json \u0026lt;\u0026lt;\u0026#39;EOF\u0026#39; { \u0026#34;default-address-pools\u0026#34;: [ {\u0026#34;base\u0026#34;: \u0026#34;10.200.0.0/16\u0026#34;, \u0026#34;size\u0026#34;: 24} ] } EOF That gives you 256 networks of /24 each. Pick a base that doesn\u0026rsquo;t overlap your LAN, VPNs or any other route. Check with ip route.\nIf you already have a daemon.json, merge the key in rather than overwriting the file.\nStep 2: Restart Docker On a normal Linux host:\nsudo systemctl restart docker On ASUSTOR ADM, use the App Central control script (or toggle Docker CE off and on in App Central):\nsudo /usr/local/AppCentral/docker-ce/CONTROL/start-stop.sh stop sudo /usr/local/AppCentral/docker-ce/CONTROL/start-stop.sh start Either way this restarts every container, so pick a quiet moment. On ADM you\u0026rsquo;ll see harmless noise like can't unmount docker_lib or rpcbind already running.\nStep 3: Check the new pool is live ps | grep [d]ockerd # the PID should be different from before sudo docker network create test-net sudo docker network inspect test-net | grep Subnet sudo docker network rm test-net You should see a 10.200.x.0/24 subnet.\nStep 4: Pin a subnet if the stack still fails In my case the original stack still threw the pool error after the restart, even though manual docker network create worked. Pinning an explicit subnet in the compose file fixed it, because explicit subnets skip the pool allocator:\nnetworks: default: ipam: config: - subnet: 10.201.0.0/24 Choose a range that isn\u0026rsquo;t already in use (sudo docker network ls, ip route) and sits outside your new pool. 10.201.x is outside 10.200.0.0/16.\nOther things that help sudo docker network prune removes networks with no containers attached. It clears leftovers from stacks you stopped using. Existing networks keep their old 172.x subnets. Only new networks come from the new pool. After a daemon restart, apps with dependencies (a database, Redis) may restart-loop briefly until those are healthy. Give it a minute before you panic. NAS caveats (ASUSTOR ADM) /etc/docker/daemon.json may not survive a reboot or a Docker CE package update. Check it with cat /etc/docker/daemon.json afterwards. If it\u0026rsquo;s gone, recreate it, or add --default-address-pool base=10.200.0.0/16,size=24 to the dockerd line in start-stop.sh (updates can overwrite that too). dockerd on ADM runs with --iptables=false, so Docker isn\u0026rsquo;t managing NAT rules for bridge networks. That\u0026rsquo;s unrelated to this error but worth knowing if a container can\u0026rsquo;t reach out. Quick reference Task Command List Compose projects and paths sudo docker compose ls -a List networks sudo docker network ls Show every network\u0026rsquo;s subnet sudo docker network inspect $(sudo docker network ls -q) | grep -E '\u0026quot;Name\u0026quot;|Subnet' Show host routes ip route Prune unused networks sudo docker network prune ","permalink":"http://liyafixes.dev/posts/docker-address-pools-fully-subnetted/","summary":"\u003cp\u003eYou run \u003ccode\u003edocker compose up\u003c/code\u003e on a new stack and get this:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003efailed to create network file-browser_default: Error response from daemon:\nall predefined address pools have been fully subnetted\n\u003c/code\u003e\u003c/pre\u003e\u003cp\u003eEvery Compose project gets its own bridge network, and Docker\u0026rsquo;s default pools (\u003ccode\u003e172.17-31.0.0/16\u003c/code\u003e plus some \u003ccode\u003e192.168.x.x\u003c/code\u003e blocks) only stretch so far. Once you have a few dozen stacks, you run out.\u003c/p\u003e\n\u003cp\u003eI hit this on an ASUSTOR NAS running Docker CE from App Central, which has some quirks: no systemd, a BusyBox shell, and \u003ccode\u003esudo\u003c/code\u003e needed for every Docker command. The fix works on any Linux host; only the restart step differs.\u003c/p\u003e","title":"How to Fix \"All Predefined Address Pools Have Been Fully Subnetted\" in Docker"},{"content":"Old phone backups and SD card dumps end up as one giant folder of IMG_1234.HEIC files. This script reads the camera model and capture date from each file\u0026rsquo;s metadata and moves it into:\nSorted Pictures/ └── iPhone 13/ └── 2023/ └── 07/ └── 14/ └── IMG_1234.HEIC What makes it safe Dry run by default. Nothing changes until you add --move. Moves, never copies. On the same drive that\u0026rsquo;s a true rename, so created and modified dates are preserved. Never overwrites. Name clashes get _1, _2 and so on. Re-runnable. The output folder is skipped when scanning. Step 1: Install the tools These steps are for macOS, but the script works anywhere Python 3 and exiftool are installed.\nInstall Homebrew if you don\u0026rsquo;t have it. Install exiftool: brew install exiftool Check for Python 3: python3 --version If it\u0026rsquo;s missing, macOS will offer to install the Command Line Tools, or run brew install python. Step 2: Save the script Save the script at the bottom of this post as sort_pictures.py, for example in ~/Scripts.\nStep 3: Do a dry run python3 ~/Scripts/sort_pictures.py \u0026#34;/Volumes/Backup/Old iPhone\u0026#34; Read the summary at the end. Pay attention to how many files landed in Unknown Device and how many fell back to the file-modified date.\nStep 4: Run it for real python3 ~/Scripts/sort_pictures.py \u0026#34;/Volumes/Backup/Old iPhone\u0026#34; --move Options Flag What it does --device \u0026quot;Name\u0026quot; Uses one device name for every file instead of reading the Model tag --out \u0026quot;PATH\u0026quot; Puts sorted folders somewhere other than \u0026lt;source\u0026gt;/Sorted Pictures Always quote paths; spaces and + signs are common in folder names.\n--device is handy for Samsung phones, which store a model code like SM-S906B rather than a friendly name:\npython3 sort_pictures.py \u0026#34;/Volumes/Backup/Samsung/DCIM/Camera\u0026#34; --device \u0026#34;Galaxy S22+\u0026#34; --move Things to know The Sorted Pictures folder doesn\u0026rsquo;t exist after a dry run; it\u0026rsquo;s only created with --move. Date priority: DateTimeOriginal → CreateDate → MediaCreateDate → file modified date. Files with no camera model go under Unknown Device. Only photos and videos are moved. Sidecar files like iPhone .AAE stay put. Hidden files, including macOS ._ files on external drives, are skipped. Moving across drives turns into a copy and changes dates, so keep --out on the same volume as the source. Troubleshooting Problem Fix exiftool not found brew install exiftool Can\u0026rsquo;t find Sorted Pictures You only did a dry run. Re-run with --move Found 0 media files Check the path, the quotes, and that the drive is mounted Folders named like SM-S906B Use --device \u0026quot;Friendly Name\u0026quot; The script #!/usr/bin/env python3 \u0026#34;\u0026#34;\u0026#34; Sort photos/videos into: \u0026lt;Device Name\u0026gt;/\u0026lt;YYYY\u0026gt;/\u0026lt;MM\u0026gt;/\u0026lt;DD\u0026gt;/ - Dry run by default (nothing is touched). Add --move to actually do it. - Files are MOVED (renamed) on the same volume, never copied, so created/modified dates stay exactly as they are. - Never overwrites: name clashes get _1, _2, ... appended. - Requires exiftool: brew install exiftool \u0026#34;\u0026#34;\u0026#34; import argparse import json import os import re import subprocess import sys from collections import Counter OUT_NAME = \u0026#34;Sorted Pictures\u0026#34; MEDIA_EXTS = { \u0026#34;.jpg\u0026#34;, \u0026#34;.jpeg\u0026#34;, \u0026#34;.heic\u0026#34;, \u0026#34;.heif\u0026#34;, \u0026#34;.png\u0026#34;, \u0026#34;.gif\u0026#34;, \u0026#34;.tif\u0026#34;, \u0026#34;.tiff\u0026#34;, \u0026#34;.bmp\u0026#34;, \u0026#34;.webp\u0026#34;, \u0026#34;.dng\u0026#34;, \u0026#34;.raw\u0026#34;, \u0026#34;.cr2\u0026#34;, \u0026#34;.cr3\u0026#34;, \u0026#34;.nef\u0026#34;, \u0026#34;.arw\u0026#34;, \u0026#34;.mov\u0026#34;, \u0026#34;.mp4\u0026#34;, \u0026#34;.m4v\u0026#34;, \u0026#34;.avi\u0026#34;, \u0026#34;.3gp\u0026#34;, } DATE_TAGS = [\u0026#34;DateTimeOriginal\u0026#34;, \u0026#34;CreateDate\u0026#34;, \u0026#34;MediaCreateDate\u0026#34;, \u0026#34;FileModifyDate\u0026#34;] DATE_RE = re.compile(r\u0026#34;^(\\d{4}):(\\d{2}):(\\d{2})\u0026#34;) CHUNK = 500 def find_files(src, out_dir): out_abs = os.path.abspath(out_dir) found = [] for root, dirs, files in os.walk(src): # don\u0026#39;t re-scan the output folder, skip hidden dirs dirs[:] = [ d for d in dirs if not d.startswith(\u0026#34;.\u0026#34;) and os.path.abspath(os.path.join(root, d)) != out_abs ] for f in files: if f.startswith(\u0026#34;.\u0026#34;): # includes ._AppleDouble files continue if os.path.splitext(f)[1].lower() in MEDIA_EXTS: found.append(os.path.join(root, f)) return found def read_metadata(paths): \u0026#34;\u0026#34;\u0026#34;Yield exiftool metadata dicts, in chunks.\u0026#34;\u0026#34;\u0026#34; for i in range(0, len(paths), CHUNK): chunk = paths[i:i + CHUNK] cmd = [ \u0026#34;exiftool\u0026#34;, \u0026#34;-json\u0026#34;, \u0026#34;-charset\u0026#34;, \u0026#34;filename=UTF8\u0026#34;, \u0026#34;-api\u0026#34;, \u0026#34;QuickTimeUTC=1\u0026#34;, \u0026#34;-Model\u0026#34;, *[f\u0026#34;-{t}\u0026#34; for t in DATE_TAGS], \u0026#34;-@\u0026#34;, \u0026#34;-\u0026#34;, ] res = subprocess.run( cmd, input=\u0026#34;\\n\u0026#34;.join(chunk), capture_output=True, text=True ) if not res.stdout.strip(): print(res.stderr, file=sys.stderr) continue for item in json.loads(res.stdout): yield item def pick_date(meta): for tag in DATE_TAGS: m = DATE_RE.match(str(meta.get(tag, \u0026#34;\u0026#34;))) if m and m.group(1) != \u0026#34;0000\u0026#34; and m.group(2) != \u0026#34;00\u0026#34; and m.group(3) != \u0026#34;00\u0026#34;: return m.groups(), tag return None, None def clean(name): name = re.sub(r\u0026#39;[/:\\\\\\0]\u0026#39;, \u0026#34;-\u0026#34;, str(name)).strip() return name or \u0026#34;Unknown Device\u0026#34; def unique_path(path): if not os.path.exists(path): return path base, ext = os.path.splitext(path) n = 1 while os.path.exists(f\u0026#34;{base}_{n}{ext}\u0026#34;): n += 1 return f\u0026#34;{base}_{n}{ext}\u0026#34; def main(): ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) ap.add_argument(\u0026#34;src\u0026#34;, help=\u0026#34;source folder\u0026#34;) ap.add_argument(\u0026#34;--out\u0026#34;, help=f\u0026#39;output folder (default: \u0026#34;\u0026lt;src\u0026gt;/{OUT_NAME}\u0026#34;)\u0026#39;) ap.add_argument(\u0026#34;--move\u0026#34;, action=\u0026#34;store_true\u0026#34;, help=\u0026#34;actually move files (default is dry run)\u0026#34;) ap.add_argument(\u0026#34;--device\u0026#34;, help=\u0026#34;force a device name for every file (skips Model lookup)\u0026#34;) args = ap.parse_args() src = os.path.abspath(args.src) out_dir = os.path.abspath(args.out or os.path.join(src, OUT_NAME)) if not os.path.isdir(src): sys.exit(f\u0026#34;Source not found: {src}\u0026#34;) if subprocess.run([\u0026#34;which\u0026#34;, \u0026#34;exiftool\u0026#34;], capture_output=True).returncode != 0: sys.exit(\u0026#34;exiftool not found. Install with: brew install exiftool\u0026#34;) mode = \u0026#34;MOVING\u0026#34; if args.move else \u0026#34;DRY RUN (nothing will be changed)\u0026#34; print(f\u0026#34;{mode}\\n from: {src}\\n to: {out_dir}\\n\u0026#34;) files = find_files(src, out_dir) print(f\u0026#34;Found {len(files)} media files. Reading metadata...\\n\u0026#34;) moved = 0 errors = 0 fallback_dates = 0 per_device = Counter() for meta in read_metadata(files): path = meta[\u0026#34;SourceFile\u0026#34;] date, tag = pick_date(meta) if date is None: print(f\u0026#34;SKIP (no usable date): {path}\u0026#34;) errors += 1 continue if tag == \u0026#34;FileModifyDate\u0026#34;: fallback_dates += 1 device = clean(args.device or meta.get(\u0026#34;Model\u0026#34;) or \u0026#34;Unknown Device\u0026#34;) yyyy, mm, dd = date dest_dir = os.path.join(out_dir, device, yyyy, mm, dd) dest = unique_path(os.path.join(dest_dir, os.path.basename(path))) print(f\u0026#34;{os.path.relpath(path, src)} -\u0026gt; {os.path.relpath(dest, out_dir)}\u0026#34;) if args.move: try: os.makedirs(dest_dir, exist_ok=True) # os.rename = a true move on the same volume; keeps all timestamps. os.rename(path, dest) except OSError as e: print(f\u0026#34; ERROR: {e}\u0026#34;) errors += 1 continue moved += 1 per_device[device] += 1 verb = \u0026#34;Moved\u0026#34; if args.move else \u0026#34;Would move\u0026#34; print(f\u0026#34;\\n{verb} {moved} files. Errors/skipped: {errors}.\u0026#34;) if fallback_dates: print(f\u0026#34;{fallback_dates} files had no capture date and used the file modified date instead.\u0026#34;) for dev, n in per_device.most_common(): print(f\u0026#34; {dev}: {n}\u0026#34;) if not args.move: print(\u0026#34;\\nLooks right? Re-run with --move to do it for real.\u0026#34;) if __name__ == \u0026#34;__main__\u0026#34;: main() ","permalink":"http://liyafixes.dev/posts/sort-photos-by-camera-and-date/","summary":"\u003cp\u003eOld phone backups and SD card dumps end up as one giant folder of \u003ccode\u003eIMG_1234.HEIC\u003c/code\u003e files. This script reads the camera model and capture date from each file\u0026rsquo;s metadata and moves it into:\u003c/p\u003e\n\u003cpre tabindex=\"0\"\u003e\u003ccode\u003eSorted Pictures/\n└── iPhone 13/\n    └── 2023/\n        └── 07/\n            └── 14/\n                └── IMG_1234.HEIC\n\u003c/code\u003e\u003c/pre\u003e\u003ch2 id=\"what-makes-it-safe\"\u003eWhat makes it safe\u003c/h2\u003e\n\u003cul\u003e\n\u003cli\u003e\u003cstrong\u003eDry run by default.\u003c/strong\u003e Nothing changes until you add \u003ccode\u003e--move\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eMoves, never copies.\u003c/strong\u003e On the same drive that\u0026rsquo;s a true rename, so created and modified dates are preserved.\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eNever overwrites.\u003c/strong\u003e Name clashes get \u003ccode\u003e_1\u003c/code\u003e, \u003ccode\u003e_2\u003c/code\u003e and so on.\u003c/li\u003e\n\u003cli\u003e\u003cstrong\u003eRe-runnable.\u003c/strong\u003e The output folder is skipped when scanning.\u003c/li\u003e\n\u003c/ul\u003e\n\u003ch2 id=\"step-1-install-the-tools\"\u003eStep 1: Install the tools\u003c/h2\u003e\n\u003cp\u003eThese steps are for macOS, but the script works anywhere Python 3 and exiftool are installed.\u003c/p\u003e","title":"How to Sort Photos into Device/Year/Month/Day Folders with exiftool and Python"},{"content":"","permalink":"http://liyafixes.dev/portfolio/","summary":"","title":"Portfolio"}]