Rebuild dotfiles as one branch with per-host layers
Replaces the previous repo, which had split into two histories that never met (mainframe on a dead GitLab remote, the laptops on Gitea) with 146 dirty files across three machines and the NAS never enrolled at all. Branch-per-machine is gone. One main, with host differences expressed as small files under hosts/<hostname>/ rather than as branches, so there is nothing to merge. The reconciled zsh layer reduces 15-33 line forks to 1-7 effective lines per host; distro differences (oh-my-zsh prefix, syntax-highlighting path, fd vs fdfind) are probed in common/ instead. Fresh history: the old one carried six plaintext credentials, 45 MB of mail caches, browser caches and vendored binaries. 5,096 tracked files and 144 MB become 462 files and 2.6 MB. The .gitignore is now an allowlist, which is what keeps that true. Root cause of the rot: ~/.local/bin was a symlink to scripts/ with GOPATH inside it, so every go install wrote into version control (2.2 GB on the work laptop). PATH now points at the repo instead of the reverse. Also: Hyprland replaces sway and is sourced in two halves so $browser is defined before use; singleton automations carry ConditionHost= alongside host-layer-only placement; ddns moves from cron to a guarded timer; package manifests and pkg-snapshot/pkg-restore replace the X11-era install_scripts/; networkmanager-dmenu added to system76 (the binding always existed, the package never did).
This commit is contained in:
Executable
+46
@@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
# Sample backlight state so an unattended dim/restore cycle can be reconstructed.
|
||||
# A long gap between samples means the machine was suspended, which is the window
|
||||
# where DDC writes are suspected to be lost, so that case is sampled densely.
|
||||
LOG=$HOME/.local/state/backlight-probe.log
|
||||
|
||||
read_all() {
|
||||
out=
|
||||
for p in /sys/class/backlight/*; do
|
||||
[ -e "$p" ] || continue
|
||||
out="$out ${p##*/}=$(cat "$p/brightness" 2>/dev/null)/$(timeout 2 cat "$p/actual_brightness" 2>/dev/null || echo ERR)"
|
||||
done
|
||||
printf '%s' "$out"
|
||||
}
|
||||
|
||||
cached() {
|
||||
out=
|
||||
for p in /sys/class/backlight/*; do
|
||||
[ -e "$p" ] || continue
|
||||
out="$out ${p##*/}=$(cat "$p/brightness" 2>/dev/null)"
|
||||
done
|
||||
printf '%s' "$out"
|
||||
}
|
||||
|
||||
prev=
|
||||
last=$(date +%s)
|
||||
printf '%s START%s\n' "$(date '+%F %T')" "$(read_all)" >>"$LOG"
|
||||
|
||||
while :; do
|
||||
now=$(date +%s); gap=$((now - last)); last=$now
|
||||
cur=$(cached)
|
||||
|
||||
if [ "$gap" -gt 10 ]; then
|
||||
printf '%s GAP %ss (suspend/resume)\n' "$(date '+%F %T')" "$gap" >>"$LOG"
|
||||
i=0
|
||||
while [ "$i" -lt 40 ]; do
|
||||
printf '%s +%02ds%s\n' "$(date '+%F %T')" "$i" "$(read_all)" >>"$LOG"
|
||||
i=$((i + 1)); sleep 1
|
||||
done
|
||||
prev=
|
||||
elif [ "$cur" != "$prev" ]; then
|
||||
printf '%s CHANGE%s\n' "$(date '+%F %T')" "$(read_all)" >>"$LOG"
|
||||
prev=$cur
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
# Absolute path is required: the shared $HOME puts the host's pip shim at
|
||||
# ~/.local/bin/qutebrowser, which shadows the container's and runs an incompatible python.
|
||||
|
||||
# Both builds hash to the same IPC socket name, so a running host instance would
|
||||
# silently swallow this launch and open a tab there instead.
|
||||
if pgrep -f '\.local/apps/qutebrowser/\.venv/bin/python3 -m qutebrowser' >/dev/null 2>&1; then
|
||||
echo "qutebrowser-arch: the host (pip) qutebrowser is running and shares the IPC socket." >&2
|
||||
echo "Quit it first, or this launch will just open a tab in that instance." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# QB_MODE works around eglCreateImage returning EGL_NOT_INITIALIZED under native
|
||||
# Wayland, which loses the GL context and leaves pages rendering as background only.
|
||||
PRE=""
|
||||
EXTRA=""
|
||||
case "${QB_MODE:-xwayland}" in
|
||||
xwayland)
|
||||
# XWayland cannot do fractional scaling, so Hyprland upscales a 1x buffer and
|
||||
# blurs it. Needs `xwayland { force_zero_scaling = true }` in hyprland.conf to help.
|
||||
SCALE=$(hyprctl monitors -j 2>/dev/null | grep -m1 '"scale"' | tr -dc '0-9.' )
|
||||
PRE="QT_QPA_PLATFORM=xcb QT_SCALE_FACTOR=${SCALE:-1}"
|
||||
;;
|
||||
software) EXTRA="--qt-flag disable-gpu" ;;
|
||||
wayland) ;;
|
||||
*) echo "qutebrowser-arch: unknown QB_MODE '$QB_MODE' (wayland|xwayland|software)" >&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
exec "$HOME/.local/bin/distrobox" enter --no-tty --name arch -- sh -c \
|
||||
"$PRE exec /usr/bin/qutebrowser $EXTRA \"\$@\"" -- "$@"
|
||||
Executable
+80
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Total time tagged language:spanish in Traggo, as decimal hours."""
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
import urllib.request
|
||||
from collections import defaultdict
|
||||
from datetime import datetime, timezone
|
||||
|
||||
URL = "https://time.rcjohnstone.com/graphql"
|
||||
USER = "connor"
|
||||
|
||||
|
||||
def gql(query, cookie=None):
|
||||
req = urllib.request.Request(
|
||||
URL,
|
||||
data=json.dumps({"query": query}).encode(),
|
||||
headers={"Content-Type": "application/json"},
|
||||
)
|
||||
if cookie:
|
||||
req.add_header("Cookie", f"traggo={cookie}")
|
||||
body = json.load(urllib.request.urlopen(req))
|
||||
if body.get("errors"):
|
||||
sys.exit(f"traggo: {body['errors'][0]['message']}")
|
||||
return body["data"]
|
||||
|
||||
|
||||
def login():
|
||||
pw = subprocess.run(
|
||||
["rbw", "get", "Traggo"], capture_output=True, text=True, check=True
|
||||
).stdout.strip()
|
||||
data = gql(
|
||||
'mutation{login(username:"%s",pass:%s,deviceName:"spanish-time",'
|
||||
"type:LongExpiry,cookie:false){token}}" % (USER, json.dumps(pw))
|
||||
)
|
||||
return data["login"]["token"]
|
||||
|
||||
|
||||
def spans(token):
|
||||
offset, start_id = 0, None
|
||||
while True:
|
||||
cur = f"offset:{offset},pageSize:200"
|
||||
if start_id is not None:
|
||||
cur += f",startId:{start_id}"
|
||||
data = gql(
|
||||
'{timeSpans(fromInclusive:"2000-01-01T00:00:00Z",'
|
||||
'toInclusive:"2100-01-01T00:00:00Z",cursor:{%s})'
|
||||
"{cursor{hasMore offset startId} timeSpans{start end tags{key value}}}}"
|
||||
% cur,
|
||||
token,
|
||||
)["timeSpans"]
|
||||
yield from data["timeSpans"]
|
||||
if not data["cursor"]["hasMore"]:
|
||||
return
|
||||
offset, start_id = data["cursor"]["offset"], data["cursor"]["startId"]
|
||||
|
||||
|
||||
def main():
|
||||
by_mode = defaultdict(float)
|
||||
for span in spans(login()):
|
||||
tags = {t["key"]: t["value"] for t in span["tags"]}
|
||||
if tags.get("language") != "spanish":
|
||||
continue
|
||||
start = datetime.fromisoformat(span["start"])
|
||||
end = (
|
||||
datetime.fromisoformat(span["end"])
|
||||
if span["end"]
|
||||
else datetime.now(timezone.utc)
|
||||
)
|
||||
by_mode[tags.get("mode", "untagged")] += (end - start).total_seconds() / 3600
|
||||
|
||||
if "--by-mode" in sys.argv:
|
||||
for mode, hours in sorted(by_mode.items(), key=lambda kv: -kv[1]):
|
||||
print(f"{mode:12s} {hours:8.2f}")
|
||||
print(f"{sum(by_mode.values()):.2f}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Executable
+257
@@ -0,0 +1,257 @@
|
||||
#!/usr/bin/env python3
|
||||
"""usb3check - watch USB/Thunderbolt enumeration and report cable tier.
|
||||
|
||||
Plug a device in while this runs and it reports the negotiated link speed and
|
||||
which cable tier that qualifies for.
|
||||
|
||||
Tier 1 Thunderbolt 4/5, 240W EPR dock uplink, displays, external SSDs
|
||||
Tier 2 >=10Gbps, 240W EPR general data
|
||||
Tier 3 charge-only, 240W EPR bench power, laptop charging
|
||||
Tier 4 everything else phone charging, or the bin
|
||||
|
||||
Data rate is measured. Wattage is NOT - nothing in sysfs exposes the cable's
|
||||
e-marker, so the tier printed is the ceiling the data rate allows. Confirm the
|
||||
power rating from the purchase or an inline analyzer before promoting a cable.
|
||||
|
||||
Reads /sys/bus/usb/devices and /sys/bus/thunderbolt/devices. No root, no deps.
|
||||
|
||||
./usb3check.py watch continuously
|
||||
./usb3check.py --once print current devices grouped by speed
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
USB_SYSFS = "/sys/bus/usb/devices"
|
||||
TB_SYSFS = "/sys/bus/thunderbolt/devices"
|
||||
|
||||
TIER_NOTES = {
|
||||
1: "Thunderbolt link established. Tier 1 if the cable is also 240W EPR.",
|
||||
2: "SuperSpeed link established. Tier 2 if the cable is also 240W EPR.",
|
||||
3: "No SuperSpeed link - data-incapable. Tier 3 if 240W EPR, else tier 4.",
|
||||
4: "No link worth keeping. Tier 4.",
|
||||
}
|
||||
|
||||
|
||||
def read_attr(path, name):
|
||||
try:
|
||||
with open(os.path.join(path, name)) as fh:
|
||||
return fh.read().strip()
|
||||
except OSError:
|
||||
return None
|
||||
|
||||
|
||||
def usb_snapshot():
|
||||
"""Map of sysfs name -> device info, excluding root hubs and interfaces."""
|
||||
devices = {}
|
||||
try:
|
||||
entries = os.listdir(USB_SYSFS)
|
||||
except OSError as exc:
|
||||
sys.exit(f"cannot read {USB_SYSFS}: {exc}")
|
||||
|
||||
for name in entries:
|
||||
if name.startswith("usb") or ":" in name:
|
||||
continue # root hub, or an interface rather than a device
|
||||
path = os.path.join(USB_SYSFS, name)
|
||||
raw_speed = read_attr(path, "speed")
|
||||
if raw_speed is None:
|
||||
continue
|
||||
try:
|
||||
speed = float(raw_speed)
|
||||
except ValueError:
|
||||
continue
|
||||
devices[name] = {
|
||||
"kind": "usb",
|
||||
"speed": speed,
|
||||
"vid": read_attr(path, "idVendor") or "????",
|
||||
"pid": read_attr(path, "idProduct") or "????",
|
||||
"product": read_attr(path, "product") or "",
|
||||
"vendor": read_attr(path, "manufacturer") or "",
|
||||
"class": read_attr(path, "bDeviceClass") or "",
|
||||
}
|
||||
return devices
|
||||
|
||||
|
||||
def tb_snapshot():
|
||||
"""Map of sysfs name -> Thunderbolt device info. Empty if no TB subsystem."""
|
||||
devices = {}
|
||||
if not os.path.isdir(TB_SYSFS):
|
||||
return devices
|
||||
|
||||
for name in os.listdir(TB_SYSFS):
|
||||
if name.startswith("domain") or ":" in name:
|
||||
continue # domain controller, or a retimer/port entry
|
||||
path = os.path.join(TB_SYSFS, name)
|
||||
if read_attr(path, "device_name") is None and read_attr(path, "device") is None:
|
||||
continue
|
||||
devices[name] = {
|
||||
"kind": "thunderbolt",
|
||||
"product": read_attr(path, "device_name") or "",
|
||||
"vendor": read_attr(path, "vendor_name") or "",
|
||||
"authorized": read_attr(path, "authorized") or "0",
|
||||
"rx": read_attr(path, "rx_speed") or "",
|
||||
"tx": read_attr(path, "tx_speed") or "",
|
||||
"generation": read_attr(path, "generation") or "",
|
||||
}
|
||||
return devices
|
||||
|
||||
|
||||
def snapshot():
|
||||
combined = usb_snapshot()
|
||||
for name, info in tb_snapshot().items():
|
||||
combined[f"tb:{name}"] = info
|
||||
return combined
|
||||
|
||||
|
||||
def fmt_speed(mbps):
|
||||
if mbps >= 1000:
|
||||
return f"{mbps / 1000:g} Gbps"
|
||||
return f"{mbps:g} Mbps"
|
||||
|
||||
|
||||
def generation(mbps):
|
||||
if mbps >= 20000:
|
||||
return "USB 3.2 Gen 2x2"
|
||||
if mbps >= 10000:
|
||||
return "USB 3.1 Gen 2 (SuperSpeed+)"
|
||||
if mbps >= 5000:
|
||||
return "USB 3.0 (SuperSpeed)"
|
||||
if mbps >= 480:
|
||||
return "USB 2.0 (High Speed)"
|
||||
return "USB 1.x (Full/Low Speed)"
|
||||
|
||||
|
||||
def describe(info):
|
||||
label = " ".join(x for x in (info.get("vendor", ""), info.get("product", ""))).strip()
|
||||
if not label:
|
||||
label = f"{info.get('vid', '????')}:{info.get('pid', '????')}"
|
||||
if info["kind"] == "thunderbolt":
|
||||
gen = info.get("generation")
|
||||
label += f" [thunderbolt{' gen ' + gen if gen else ''}]"
|
||||
elif info.get("class") == "09":
|
||||
label += " [hub]"
|
||||
return label
|
||||
|
||||
|
||||
def speed_column(info):
|
||||
if info["kind"] == "thunderbolt":
|
||||
return info.get("rx") or "TB link"
|
||||
return fmt_speed(info["speed"])
|
||||
|
||||
|
||||
def classify(added):
|
||||
"""Best tier the observed links qualify for."""
|
||||
if any(i["kind"] == "thunderbolt" and i.get("authorized") == "1" for i in added.values()):
|
||||
return 1
|
||||
usb = [i["speed"] for i in added.values() if i["kind"] == "usb"]
|
||||
if not usb:
|
||||
return 4
|
||||
best = max(usb)
|
||||
if best >= 10000:
|
||||
return 2
|
||||
if best >= 5000:
|
||||
return 2
|
||||
if best >= 480:
|
||||
return 3
|
||||
return 4
|
||||
|
||||
|
||||
def report(added, removed):
|
||||
print(f"\n-- {time.strftime('%H:%M:%S')} " + "-" * 44)
|
||||
for name, info in sorted(removed.items()):
|
||||
print(f" - {name:<14} {'':>10} {describe(info)}")
|
||||
for name, info in sorted(added.items()):
|
||||
print(f" + {name:<14} {speed_column(info):>10} {describe(info)}")
|
||||
|
||||
if not added:
|
||||
return
|
||||
|
||||
tier = classify(added)
|
||||
usb = [i["speed"] for i in added.values() if i["kind"] == "usb"]
|
||||
print()
|
||||
if usb:
|
||||
print(f" fastest USB link: {fmt_speed(max(usb))} ({generation(max(usb))})")
|
||||
print(f" TIER {tier}: {TIER_NOTES[tier]}")
|
||||
if tier >= 3:
|
||||
print(" a USB 3 hub always enumerates twice - once at 480 Mbps and")
|
||||
print(" again on the SuperSpeed bus. Only one showed up here.")
|
||||
if tier == 2:
|
||||
print(" not a Thunderbolt link. Tier 1 needs `boltctl list` with the dock.")
|
||||
|
||||
|
||||
def print_tree(devices):
|
||||
if not devices:
|
||||
print("no devices found")
|
||||
return
|
||||
tb = {k: v for k, v in devices.items() if v["kind"] == "thunderbolt"}
|
||||
usb = {k: v for k, v in devices.items() if v["kind"] == "usb"}
|
||||
|
||||
if tb:
|
||||
print("\nThunderbolt")
|
||||
for name, info in sorted(tb.items()):
|
||||
state = "authorized" if info.get("authorized") == "1" else "not authorized"
|
||||
print(f" {name:<14} {info.get('rx', ''):>10} {describe(info)} [{state}]")
|
||||
|
||||
by_speed = {}
|
||||
for name, info in usb.items():
|
||||
by_speed.setdefault(info["speed"], []).append((name, info))
|
||||
for speed in sorted(by_speed, reverse=True):
|
||||
print(f"\n{fmt_speed(speed)} ({generation(speed)})")
|
||||
for name, info in sorted(by_speed[speed]):
|
||||
print(f" {name:<14} {describe(info)}")
|
||||
|
||||
|
||||
def watch(interval, settle):
|
||||
base = snapshot()
|
||||
fast = sum(1 for i in base.values() if i["kind"] == "usb" and i["speed"] >= 5000)
|
||||
tb = sum(1 for i in base.values() if i["kind"] == "thunderbolt")
|
||||
print(f"watching {USB_SYSFS}" + (f" and {TB_SYSFS}" if os.path.isdir(TB_SYSFS) else ""))
|
||||
print(f"baseline: {len(base)} devices, {fast} at SuperSpeed, {tb} Thunderbolt")
|
||||
print("plug something in - Ctrl-C to stop")
|
||||
|
||||
while True:
|
||||
time.sleep(interval)
|
||||
current = snapshot()
|
||||
if current == base:
|
||||
continue
|
||||
|
||||
# Let enumeration settle before reporting; a hub plus its downstream
|
||||
# devices arrive over several hundred milliseconds.
|
||||
while True:
|
||||
time.sleep(settle)
|
||||
following = snapshot()
|
||||
if following == current:
|
||||
break
|
||||
current = following
|
||||
|
||||
added = {k: v for k, v in current.items() if k not in base}
|
||||
removed = {k: v for k, v in base.items() if k not in current}
|
||||
report(added, removed)
|
||||
base = current
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
parser.add_argument("--once", action="store_true",
|
||||
help="print current devices grouped by speed, then exit")
|
||||
parser.add_argument("--interval", type=float, default=0.4,
|
||||
help="poll interval in seconds (default: 0.4)")
|
||||
parser.add_argument("--settle", type=float, default=1.0,
|
||||
help="settle time after a change before reporting (default: 1.0)")
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.once:
|
||||
print_tree(snapshot())
|
||||
return
|
||||
|
||||
try:
|
||||
watch(args.interval, args.settle)
|
||||
except KeyboardInterrupt:
|
||||
print()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
# Hyprland propagates PRIMARY ownership across the Xwayland boundary but not the
|
||||
# contents, so Xwayland clients get an empty middle-click paste. Its proxy will
|
||||
# still serve a direct STRING request, but it advertises no text target, and Qt
|
||||
# asks for TARGETS first and gives up. See hyprwm/Hyprland#6603.
|
||||
|
||||
wl-paste --primary --watch xclip -selection primary -i &
|
||||
|
||||
# Mapping a new Xwayland window makes Hyprland seize PRIMARY back, so re-push
|
||||
# whenever the X side stops offering a text target.
|
||||
while sleep 1; do
|
||||
wl-paste --primary --no-newline >/dev/null 2>&1 || continue
|
||||
xclip -o -selection primary -t TARGETS 2>/dev/null | grep -qE 'STRING|text/plain' && continue
|
||||
wl-paste --primary --no-newline 2>/dev/null | xclip -selection primary -i
|
||||
done
|
||||
@@ -0,0 +1,3 @@
|
||||
[user]
|
||||
email = connor.johnstone@scout.space
|
||||
name = Connor Johnstone
|
||||
Executable
+53
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# --- CONFIGURATION ---
|
||||
# Change this to your internal monitor name (use 'hyprctl monitors' to find it)
|
||||
INTERNAL_DISPLAY="eDP-1"
|
||||
|
||||
# Icons for notifications (ensure you have an icon theme installed)
|
||||
ICON_LAPTOP="computer-laptop"
|
||||
ICON_MONITOR="video-display"
|
||||
|
||||
# --- FUNCTIONS ---
|
||||
notify_user() {
|
||||
# Change '-u low' to '-u normal' if you want popups to stay longer
|
||||
notify-send -u low -i "$3" "$1" "$2"
|
||||
}
|
||||
|
||||
# --- MODES ---
|
||||
mode_close() {
|
||||
# Only disable internal screen if an external monitor is connected
|
||||
MONITORS_COUNT=$(hyprctl monitors all | grep -c "Monitor")
|
||||
if [[ $MONITORS_COUNT -gt 1 ]]; then
|
||||
hyprctl keyword monitor "$INTERNAL_DISPLAY, disable"
|
||||
sed -i "s/^monitor = $INTERNAL_DISPLAY, preferred, auto, auto$/monitor = $INTERNAL_DISPLAY, disable/" ~/.config/hypr/hyprland.conf
|
||||
fi
|
||||
}
|
||||
|
||||
mode_open() {
|
||||
# Force enable internal screen
|
||||
hyprctl keyword monitor "$INTERNAL_DISPLAY, preferred, auto, 1"
|
||||
sed -i "s/^monitor = $INTERNAL_DISPLAY, disable$/monitor = $INTERNAL_DISPLAY, preferred, auto, auto/" ~/.config/hypr/hyprland.conf
|
||||
}
|
||||
|
||||
# --- LOGIC ---
|
||||
if [[ "$1" == "close" ]]; then
|
||||
mode_close
|
||||
notify_user "Clamshell Mode" "External monitor active. Laptop screen disabled." "$ICON_MONITOR"
|
||||
|
||||
elif [[ "$1" == "open" ]]; then
|
||||
mode_open
|
||||
notify_user "Laptop Mode" "Laptop screen enabled." "$ICON_LAPTOP"
|
||||
|
||||
elif [[ "$1" == "check" ]]; then
|
||||
# Silent check for startup/reload to sync state
|
||||
if grep -q "open" /proc/acpi/button/lid/*/state; then
|
||||
mode_open
|
||||
else
|
||||
mode_close
|
||||
fi
|
||||
|
||||
else
|
||||
echo "Usage: $0 [open|close|check]"
|
||||
exit 1
|
||||
fi
|
||||
@@ -0,0 +1,15 @@
|
||||
# Hyprland with colors from wallust
|
||||
# The
|
||||
# You can use this template by adding the following to wallust.toml:
|
||||
# hypr = { src = "hyprland-colors.conf", dst = "~/.config/hypr/colors.conf" }
|
||||
# and then on hyprland.conf:
|
||||
# source = ~/.config/hypr/colors.conf
|
||||
|
||||
general {
|
||||
# Here we use `saturate` filter to have more vibrant colors,
|
||||
# not matter the scheme, since the border should seek the attention
|
||||
col.active_border = rgb(A7692E) rgb(A96D3C) rgb(63B044) rgb(C98945) rgb(F8A24F) rgb(F7A257)
|
||||
# color0 is almost the same as the background color,
|
||||
# by putting ee as the alpha, it makes it 100% transparent
|
||||
col.inactive_border = rgba(3A3939ee)
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
general {
|
||||
lock_cmd = pidof hyprlock || hyprlock # avoid starting multiple hyprlock instances.
|
||||
before_sleep_cmd = loginctl lock-session # lock before suspend.
|
||||
after_sleep_cmd = hyprctl dispatch dpms on # to avoid having to press a key twice to turn on the display.
|
||||
}
|
||||
|
||||
listener {
|
||||
timeout = 600 # 10min.
|
||||
on-timeout = /usr/local/bin/backlight-idle dim
|
||||
on-resume = /usr/local/bin/backlight-idle restore
|
||||
}
|
||||
|
||||
# turn off keyboard backlight, comment out this section if you dont have a keyboard backlight.
|
||||
listener {
|
||||
timeout = 600 # 10min.
|
||||
on-timeout = brightnessctl -sd rgb:kbd_backlight set 0 # turn off keyboard backlight.
|
||||
on-resume = brightnessctl -rd rgb:kbd_backlight # turn on keyboard backlight.
|
||||
}
|
||||
|
||||
listener {
|
||||
timeout = 900 # 15min
|
||||
on-timeout = loginctl lock-session # lock screen when timeout has passed
|
||||
}
|
||||
|
||||
listener {
|
||||
timeout = 930 # 15.5min
|
||||
on-timeout = hyprctl dispatch dpms off # screen off when timeout has passed
|
||||
on-resume = hyprctl dispatch dpms on # screen on when activity is detected after timeout has fired.
|
||||
}
|
||||
|
||||
listener {
|
||||
timeout = 1800 # 30min
|
||||
on-timeout = systemctl suspend # suspend pc
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
# Sourced near the top of common/hypr/hyprland.conf. Anything used later in
|
||||
# that file — $browser, env vars, monitor layout — must be defined here.
|
||||
|
||||
# Real layout lives in ~/.config/kanshi/config. This is only a fallback.
|
||||
monitor = ,preferred,auto,auto
|
||||
|
||||
env = XCURSOR_THEME,capitaine-cursors-light
|
||||
env = XCURSOR_SIZE,36
|
||||
env = HYPRCURSOR_SIZE,36
|
||||
|
||||
# Ubuntu's qutebrowser is too old for common/qutebrowser; self-built wrapper.
|
||||
$browser = /home/connorjohnstone/.local/bin/qutebrowser-arch
|
||||
@@ -0,0 +1,12 @@
|
||||
# Sourced at the very end of common/hypr/hyprland.conf.
|
||||
|
||||
general {
|
||||
gaps_in = 5
|
||||
gaps_out = 10
|
||||
}
|
||||
|
||||
xwayland {
|
||||
# Stops the 1x-buffer upscale that blurs XWayland apps on these 1.5x
|
||||
# monitors. Apps launched under XWayland set their own scale factor.
|
||||
force_zero_scaling = true
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
include /home/connorjohnstone/.config/kanshi/generated
|
||||
|
||||
profile ext_other {
|
||||
output eDP-1 enable position 0,0 scale 1
|
||||
output "*" enable position 2560,0
|
||||
}
|
||||
|
||||
profile laptop {
|
||||
output eDP-1 enable position 0,0 scale 1
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
profile generated_dock {
|
||||
output DP-6 enable position 0,0 scale 1.5
|
||||
output DP-5 enable position 2560,0 scale 1.5
|
||||
output eDP-1 disable
|
||||
}
|
||||
Executable
+76
@@ -0,0 +1,76 @@
|
||||
#!/bin/sh
|
||||
# Dim or restore every backlight device present, including any external monitor
|
||||
# that ddcci has registered. DDC/CI writes take about a second each, so the
|
||||
# monitors are driven concurrently rather than in sequence.
|
||||
|
||||
DIM_LEVEL=5
|
||||
RESTORE_TIMEOUT=60
|
||||
STATE="${XDG_STATE_HOME:-$HOME/.local/state}/backlight-idle"
|
||||
LOG="$STATE/log"
|
||||
|
||||
mkdir -p "$STATE" 2>/dev/null
|
||||
|
||||
log() { printf '%s %s\n' "$(date '+%F %T.%3N')" "$*" >>"$LOG" 2>/dev/null; }
|
||||
|
||||
is_num() { case "$1" in ''|*[!0-9]*) return 1 ;; *) return 0 ;; esac; }
|
||||
|
||||
# actual_brightness is a live DDC read, so it reports what the panel really has.
|
||||
# brightness is only the driver's cache, which accepts a write even when the bus
|
||||
# is down and then reverts to the panel's value seconds later.
|
||||
panel_level() { cat "/sys/class/backlight/$1/actual_brightness" 2>/dev/null; }
|
||||
|
||||
dim_dev() {
|
||||
dev=$1
|
||||
cur=$(cat "/sys/class/backlight/$dev/brightness" 2>/dev/null)
|
||||
is_num "$cur" || { log " dim $dev skipped, unreadable"; return; }
|
||||
|
||||
# Re-dimming would overwrite the saved level with the dimmed one.
|
||||
[ "$cur" -le "$DIM_LEVEL" ] && { log " dim $dev skipped, already dim"; return; }
|
||||
|
||||
level=$(panel_level "$dev")
|
||||
is_num "$level" || level=$cur
|
||||
printf '%s\n' "$level" >"$STATE/$dev" || { log " dim $dev skipped, cannot save"; return; }
|
||||
|
||||
brightnessctl -d "$dev" set "$DIM_LEVEL" >/dev/null 2>&1
|
||||
log " dim $dev rc=$? saved=$level"
|
||||
}
|
||||
|
||||
# The panel is read back after every write because a write issued while DDC is
|
||||
# down is silently kept in the driver cache and never reaches the monitor.
|
||||
restore_dev() {
|
||||
dev=$1
|
||||
target=$(cat "$STATE/$dev" 2>/dev/null)
|
||||
is_num "$target" || { log " restore $dev skipped, no saved level"; return; }
|
||||
|
||||
deadline=$(($(date +%s) + RESTORE_TIMEOUT))
|
||||
tries=0
|
||||
while :; do
|
||||
brightnessctl -d "$dev" set "$target" >/dev/null 2>&1
|
||||
tries=$((tries + 1))
|
||||
actual=$(panel_level "$dev")
|
||||
|
||||
[ "$actual" = "$target" ] && { log " restore $dev ok target=$target tries=$tries"; return; }
|
||||
[ "$(date +%s)" -ge "$deadline" ] && {
|
||||
log " restore $dev FAILED target=$target actual=${actual:-unreadable} tries=$tries"; return; }
|
||||
sleep 2
|
||||
done
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
dim|restore) ;;
|
||||
*) echo "usage: ${0##*/} {dim|restore}" >&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
log "$1 begin"
|
||||
|
||||
for path in /sys/class/backlight/*; do
|
||||
[ -e "$path" ] || continue
|
||||
dev=${path##*/}
|
||||
case "$1" in
|
||||
dim) dim_dev "$dev" & ;;
|
||||
restore) restore_dev "$dev" & ;;
|
||||
esac
|
||||
done
|
||||
|
||||
wait
|
||||
log "$1 end"
|
||||
Executable
+63
@@ -0,0 +1,63 @@
|
||||
#!/bin/sh
|
||||
# Attach the ddcci driver to external monitors on their DP AUX bus.
|
||||
# The connector's `ddc` symlink points at the native I2C bus, which is dead on
|
||||
# DisplayPort, so the aux adapter is selected by name instead.
|
||||
#
|
||||
# Monitors often do not answer DDC/CI for the first several seconds after boot
|
||||
# or a hotplug, and that probe failure leaves a live i2c client with no backlight
|
||||
# behind, so binding is retried rather than attempted once.
|
||||
#
|
||||
# Retries only ever discard a client whose probe failed. ddcci-dkms 0.4.4 leaks a
|
||||
# chardev minor whenever a real ddcci device is destroyed, and the orphan blocks
|
||||
# the next monitor with -EEXIST until a reboot, but a failed probe never created
|
||||
# one. A client that did produce a ddcci device is left strictly alone.
|
||||
|
||||
RETRIES=5
|
||||
SETTLE=3
|
||||
|
||||
exec 9>/run/ddcci-bind.lock
|
||||
flock -w 120 9 || exit 0
|
||||
|
||||
[ -n "$DDCCI_BIND_DELAY" ] && sleep "$DDCCI_BIND_DELAY"
|
||||
|
||||
has_backlight() {
|
||||
ls "/sys/bus/i2c/devices/$1-0037"/ddcci*/backlight/* >/dev/null 2>&1
|
||||
}
|
||||
|
||||
has_ddcci_device() {
|
||||
ls -d "/sys/bus/i2c/devices/$1-0037"/ddcci* >/dev/null 2>&1
|
||||
}
|
||||
|
||||
bind_bus() {
|
||||
n=$1
|
||||
i=0
|
||||
while [ "$i" -lt "$RETRIES" ]; do
|
||||
has_backlight "$n" && return 0
|
||||
|
||||
if [ -e "/sys/bus/i2c/devices/$n-0037" ]; then
|
||||
has_ddcci_device "$n" && return 1
|
||||
echo 0x37 > "/sys/bus/i2c/devices/i2c-$n/delete_device" 2>/dev/null
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
echo ddcci 0x37 > "/sys/bus/i2c/devices/i2c-$n/new_device" 2>/dev/null
|
||||
sleep "$SETTLE"
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
has_backlight "$n"
|
||||
}
|
||||
|
||||
for conn in /sys/class/drm/card*-DP-* /sys/class/drm/card*-HDMI-*; do
|
||||
[ -r "$conn/status" ] || continue
|
||||
[ "$(cat "$conn/status")" = connected ] || continue
|
||||
|
||||
for bus in "$conn"/i2c-*; do
|
||||
[ -d "$bus" ] || continue
|
||||
n=${bus##*/i2c-}
|
||||
|
||||
case "$(cat "/sys/bus/i2c/devices/i2c-$n/name" 2>/dev/null)" in
|
||||
*aux*) bind_bus "$n" ;;
|
||||
esac
|
||||
done
|
||||
done
|
||||
Executable
+65
@@ -0,0 +1,65 @@
|
||||
#!/bin/sh
|
||||
# Generate kanshi's dock profile from kernel EDID.
|
||||
#
|
||||
# Neither identity kanshi can see is trustworthy here: Hyprland reports each
|
||||
# monitor's serial on the other monitor's output, and connector names get
|
||||
# renumbered when the dock brings displays back in a different order. The
|
||||
# kernel reads EDID over each connector's own DDC channel and is correct, so
|
||||
# connector names are resolved from serials fresh on every display change.
|
||||
|
||||
USER_NAME=connorjohnstone
|
||||
CONF=/home/$USER_NAME/.config/kanshi/generated
|
||||
SCALE=1.5
|
||||
|
||||
# Serials in the physical left-to-right order they sit on the desk.
|
||||
ORDER="PB4HB16301805 PB4HB16301801"
|
||||
|
||||
exec 9>/run/monitor-layout.lock
|
||||
flock -w 60 9 || exit 0
|
||||
|
||||
[ -n "$LAYOUT_DELAY" ] && sleep "$LAYOUT_DELAY"
|
||||
|
||||
connector_for_serial() {
|
||||
for c in /sys/class/drm/card*-*; do
|
||||
[ -r "$c/status" ] || continue
|
||||
[ "$(cat "$c/status")" = connected ] || continue
|
||||
if edid-decode <"$c/edid" 2>/dev/null | grep -qF "'$1'"; then
|
||||
echo "$c"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# Same directory as $CONF so the final rename is atomic: kanshi reloads on
|
||||
# SIGHUP and must never observe a half-written config.
|
||||
tmp=$(mktemp "$CONF.XXXXXX") || exit 1
|
||||
trap 'rm -f "$tmp"' EXIT INT TERM
|
||||
|
||||
body=""
|
||||
x=0
|
||||
|
||||
for serial in $ORDER; do
|
||||
path=$(connector_for_serial "$serial") || continue
|
||||
name=$(basename "$path" | sed 's/^card[0-9]*-//')
|
||||
|
||||
mode=$(head -1 "$path/modes" 2>/dev/null)
|
||||
[ -n "$mode" ] || continue
|
||||
width=$(awk -v m="${mode%%x*}" -v s="$SCALE" 'BEGIN{printf "%d", m / s}')
|
||||
|
||||
body="$body output $name enable position $x,0 scale $SCALE
|
||||
"
|
||||
x=$((x + width))
|
||||
done
|
||||
|
||||
if [ -n "$body" ]; then
|
||||
printf 'profile generated_dock {\n%s output eDP-1 disable\n}\n' "$body" >"$tmp"
|
||||
else
|
||||
: >"$tmp"
|
||||
fi
|
||||
|
||||
chown "$USER_NAME:$USER_NAME" "$tmp"
|
||||
chmod 0644 "$tmp"
|
||||
mv -f "$tmp" "$CONF"
|
||||
|
||||
pkill -HUP -u "$USER_NAME" kanshi
|
||||
@@ -0,0 +1,19 @@
|
||||
@define-color cursor #D3CBC4;
|
||||
@define-color background #121110;
|
||||
@define-color foreground #FCF7F2;
|
||||
@define-color color0 #3A3939;
|
||||
@define-color color1 #A78C72;
|
||||
@define-color color2 #A99F97;
|
||||
@define-color color3 #ABB0A9;
|
||||
@define-color color4 #C9BBAC;
|
||||
@define-color color5 #F8DEC5;
|
||||
@define-color color6 #F7E7D9;
|
||||
@define-color color7 #F3EAE3;
|
||||
@define-color color8 #AAA49F;
|
||||
@define-color color9 #A78C72;
|
||||
@define-color color10 #A99F97;
|
||||
@define-color color11 #ABB0A9;
|
||||
@define-color color12 #C9BBAC;
|
||||
@define-color color13 #F8DEC5;
|
||||
@define-color color14 #F7E7D9;
|
||||
@define-color color15 #F3EAE3;
|
||||
@@ -0,0 +1 @@
|
||||
/* Defaults from common/waybar/style.css already suit these monitors. */
|
||||
@@ -0,0 +1 @@
|
||||
alias dc="docker compose"
|
||||
@@ -0,0 +1,3 @@
|
||||
# Ubuntu ships qutebrowser too old for the config in common/; this wrapper
|
||||
# points at a self-managed build.
|
||||
export BROWSER="$HOME/.local/bin/qutebrowser-arch"
|
||||
@@ -0,0 +1,7 @@
|
||||
# Managed by juliaup's installer; kept verbatim so a re-run is a no-op.
|
||||
path=("$HOME/.juliaup/bin" $path)
|
||||
export PATH
|
||||
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
|
||||
Reference in New Issue
Block a user