Compare commits
40
Commits
36655ac153
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c29f8c94e3 | ||
|
|
f537765495 | ||
|
|
a9ffe67b8b | ||
|
|
fab534431c | ||
|
|
ddbeaa7b5b | ||
|
|
3a6a75bffa | ||
|
|
ef499b0581 | ||
|
|
d469f067bd | ||
|
|
cc4b41a4b0 | ||
|
|
ef21a9a785 | ||
|
|
0ec4085359 | ||
|
|
c40dec90bd | ||
|
|
c8b2340d14 | ||
|
|
3ddba7f670 | ||
|
|
ec4d407422 | ||
|
|
301aa7c1bb | ||
|
|
a52494e39b | ||
|
|
66f65a1131 | ||
|
|
6ef357012d | ||
|
|
323707c21c | ||
|
|
a0654a6619 | ||
|
|
470eb72279 | ||
|
|
b91a9abb85 | ||
|
|
e4ba4fefc6 | ||
|
|
8bb925d9e7 | ||
|
|
7ad43db433 | ||
|
|
f4b0269b08 | ||
|
|
f31ac25f3d | ||
|
|
b4b9136593 | ||
|
|
0d1e7d4c77 | ||
|
|
a981623b67 | ||
|
|
de1b78561d | ||
|
|
69bc014849 | ||
|
|
542a83b07d | ||
|
|
3153366a06 | ||
|
|
a3c9c28875 | ||
|
|
629e26fb28 | ||
|
|
d6068b10ae | ||
|
|
c9304fbc54 | ||
|
|
404138d411 |
No files matched your search
Generated
+16
-72
@@ -60,11 +60,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1793797582,
|
"lastModified": 1795167012,
|
||||||
"narHash": "sha256-jEdYjdicxnCdlD4A7+s+iKPc2N0NSWzCHyPkHC5sXow=",
|
"narHash": "sha256-lrLLMUJNddmAMMDobTJVshu7ckzMTmTab4S3XPFgT1E=",
|
||||||
"ref": "main",
|
"ref": "main",
|
||||||
"rev": "81d87991086b96a185834702efced1e7a9b29b2f",
|
"rev": "7be6c580cb78e8e3267b6d98e421275aacc8140b",
|
||||||
"revCount": 25,
|
"revCount": 30,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "ssh://gitea@git.ppp.pm:1122/alex/ct.git"
|
"url": "ssh://gitea@git.ppp.pm:1122/alex/ct.git"
|
||||||
},
|
},
|
||||||
@@ -81,11 +81,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1794228227,
|
"lastModified": 1795169003,
|
||||||
"narHash": "sha256-PBSsjv/YspImKvqukcjk5EPCFNM4JGwgg6QBlNXZNdg=",
|
"narHash": "sha256-He4Tde9AYNSIb8D8ZowMAUECQnUM07cSEwqc10D04xc=",
|
||||||
"ref": "main",
|
"ref": "main",
|
||||||
"rev": "67e8044772f6e00abe179a0dc0b0a85554b842a7",
|
"rev": "c3114be05fda532d8fbb14149a5a662550bc49f2",
|
||||||
"revCount": 45,
|
"revCount": 61,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "ssh://gitea@git.ppp.pm:1122/alex/dagbok.git"
|
"url": "ssh://gitea@git.ppp.pm:1122/alex/dagbok.git"
|
||||||
},
|
},
|
||||||
@@ -222,24 +222,6 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"flake-utils_4": {
|
|
||||||
"inputs": {
|
|
||||||
"systems": "systems_6"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1731533236,
|
|
||||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"heldtenkeltdotse-site": {
|
"heldtenkeltdotse-site": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
@@ -711,11 +693,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1794225659,
|
"lastModified": 1795359024,
|
||||||
"narHash": "sha256-dr9VmlZa9Cwd7EbKFaYxjch4Px4AG0O6tv9a2dJusLo=",
|
"narHash": "sha256-y8QxP87mNSW+Dzb4MnTmibVkrQ9yrz+WJthJaFKr9h0=",
|
||||||
"ref": "main",
|
"ref": "main",
|
||||||
"rev": "a62467743b50203188a079c9e3267ff676478877",
|
"rev": "dd0c3762e91759ebd6fb449194690bf4cddb824f",
|
||||||
"revCount": 12,
|
"revCount": 48,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "ssh://gitea@git.ppp.pm:1122/alex/ndp.git"
|
"url": "ssh://gitea@git.ppp.pm:1122/alex/ndp.git"
|
||||||
},
|
},
|
||||||
@@ -912,11 +894,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1793606847,
|
"lastModified": 1794479223,
|
||||||
"narHash": "sha256-ELwXp0cLgYzFO5t8dMRXbpQ/9AGc/Gyo+JNB6H3YHqg=",
|
"narHash": "sha256-Ys2deXGT4PEbsaXBm+jDNFsk0DW6POT6tYNJzI/gycU=",
|
||||||
"ref": "main",
|
"ref": "main",
|
||||||
"rev": "f98137097cefae9b695bf2237077104d0752c835",
|
"rev": "a01d74e9d528ee9a293319310c8d3496617f4539",
|
||||||
"revCount": 143,
|
"revCount": 144,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "ssh://gitea@git.ppp.pm:1122/alex/puppy-tracker.git"
|
"url": "ssh://gitea@git.ppp.pm:1122/alex/puppy-tracker.git"
|
||||||
},
|
},
|
||||||
@@ -950,7 +932,6 @@
|
|||||||
"pppdotpm-site": "pppdotpm-site",
|
"pppdotpm-site": "pppdotpm-site",
|
||||||
"puppy-tracker": "puppy-tracker",
|
"puppy-tracker": "puppy-tracker",
|
||||||
"schema": "schema",
|
"schema": "schema",
|
||||||
"solo-referee": "solo-referee",
|
|
||||||
"todo": "todo",
|
"todo": "todo",
|
||||||
"whib-backend": "whib-backend",
|
"whib-backend": "whib-backend",
|
||||||
"whib-frontend": "whib-frontend"
|
"whib-frontend": "whib-frontend"
|
||||||
@@ -977,28 +958,6 @@
|
|||||||
"url": "ssh://gitea@git.ppp.pm:1122/alex/schema.git"
|
"url": "ssh://gitea@git.ppp.pm:1122/alex/schema.git"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"solo-referee": {
|
|
||||||
"inputs": {
|
|
||||||
"flake-utils": "flake-utils_4",
|
|
||||||
"nixpkgs": [
|
|
||||||
"nixpkgs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1793606847,
|
|
||||||
"narHash": "sha256-S1TQWwx1dm9Y/TWWmaxUGCuBIKmftiXx+uNshj/2K7M=",
|
|
||||||
"ref": "main",
|
|
||||||
"rev": "cf0ebe6df54fd1d3203f531d90718ca54803abb9",
|
|
||||||
"revCount": 81,
|
|
||||||
"type": "git",
|
|
||||||
"url": "ssh://gitea@git.ppp.pm:1122/alex/solo-referee.git"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"ref": "main",
|
|
||||||
"type": "git",
|
|
||||||
"url": "ssh://gitea@git.ppp.pm:1122/alex/solo-referee.git"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"systems": {
|
"systems": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1689347949,
|
"lastModified": 1689347949,
|
||||||
@@ -1074,21 +1033,6 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"systems_6": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"todo": {
|
"todo": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
|
|||||||
@@ -105,12 +105,6 @@
|
|||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
solo-referee = {
|
|
||||||
url = "git+ssh://gitea@git.ppp.pm:1122/alex/solo-referee.git?ref=main";
|
|
||||||
# url = "path:/home/alex/code/solo-referee";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
|
|
||||||
schema = {
|
schema = {
|
||||||
url = "git+ssh://gitea@git.ppp.pm:1122/alex/schema.git?ref=main";
|
url = "git+ssh://gitea@git.ppp.pm:1122/alex/schema.git?ref=main";
|
||||||
# url = "path:/home/alex/code/schema";
|
# url = "path:/home/alex/code/schema";
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
{ lib, pkgs, ... }:
|
||||||
|
let
|
||||||
|
py = pkgs.python3Packages;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
# The K400 Plus firmware turns two-finger swipes into coarse wheel ticks.
|
||||||
|
# This switches its touchpad to raw HID++ reporting and exposes it as a
|
||||||
|
# native multitouch touchpad, so GNOME scrolls it smoothly.
|
||||||
|
systemd.services.k400-touchpad = {
|
||||||
|
description = "Logitech K400 Plus raw touchpad bridge";
|
||||||
|
wants = [ "systemd-udevd.service" ];
|
||||||
|
after = [ "systemd-udevd.service" ];
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
|
||||||
|
environment = {
|
||||||
|
# `toPythonModule` exposes Solaar's `logitech_receiver`. Not a
|
||||||
|
# `withPackages` env, since Solaar bundles a conflicting `hid_parser`.
|
||||||
|
PYTHONPATH = py.makePythonPath [
|
||||||
|
(py.toPythonModule pkgs.solaar)
|
||||||
|
py.evdev
|
||||||
|
py.pygobject3
|
||||||
|
];
|
||||||
|
|
||||||
|
# `logitech_receiver` imports Gdk at load time
|
||||||
|
GI_TYPELIB_PATH = lib.makeSearchPath "lib/girepository-1.0" [
|
||||||
|
pkgs.gtk3
|
||||||
|
pkgs.pango.out
|
||||||
|
pkgs.gdk-pixbuf
|
||||||
|
pkgs.harfbuzz
|
||||||
|
pkgs.gobject-introspection
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
ExecStart = "${py.python.interpreter} ${./k400-touchpad.py}";
|
||||||
|
Restart = "on-failure";
|
||||||
|
RestartSec = 3;
|
||||||
|
TimeoutStopSec = 8;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
boot.kernelModules = [ "uinput" ];
|
||||||
|
}
|
||||||
@@ -0,0 +1,648 @@
|
|||||||
|
# Logitech K400 Plus raw touchpad bridge.
|
||||||
|
#
|
||||||
|
# Trimmed copy of the touchpad mode of k400-raw
|
||||||
|
# (https://github.com/Infinality/k400-raw, commit 04f2e58). The K400 Plus
|
||||||
|
# firmware quantizes touchpad movement into coarse mouse/wheel steps. This
|
||||||
|
# switches the touchpad to HID++ TOUCHPAD_RAW_XY (0x6100) reporting and
|
||||||
|
# exposes the raw contacts as a two-finger multitouch touchpad, so
|
||||||
|
# libinput/GNOME handle motion, tapping and scrolling. The keyboard and the
|
||||||
|
# physical buttons stay on the kernel's input device.
|
||||||
|
#
|
||||||
|
# Dropped from upstream: pointer mode, F-key configuration, CLI tunables and
|
||||||
|
# receiver/slot overrides.
|
||||||
|
#
|
||||||
|
# MIT License
|
||||||
|
#
|
||||||
|
# Copyright (c) 2026 Infinality
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
|
# copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import logging
|
||||||
|
import signal
|
||||||
|
import struct
|
||||||
|
import threading
|
||||||
|
import time
|
||||||
|
from dataclasses import dataclass
|
||||||
|
|
||||||
|
from evdev import AbsInfo, UInput, ecodes
|
||||||
|
|
||||||
|
# Solaar warns at import time when libnotify is missing; nothing here sends
|
||||||
|
# desktop notifications
|
||||||
|
logging.getLogger("logitech_receiver.desktop_notifications").setLevel(logging.ERROR)
|
||||||
|
|
||||||
|
from logitech_receiver import base, listener # noqa: E402
|
||||||
|
from logitech_receiver import receiver as receiver_mod # noqa: E402
|
||||||
|
from logitech_receiver.hidpp20_constants import SupportedFeature # noqa: E402
|
||||||
|
|
||||||
|
LOG = logging.getLogger("k400-touchpad")
|
||||||
|
|
||||||
|
WPID_K400_PLUS = "404D"
|
||||||
|
RAW_FEATURE = SupportedFeature.TOUCHPAD_RAW_XY
|
||||||
|
RAW_FLAG = 0x01
|
||||||
|
ENHANCED_FLAG = 0x04
|
||||||
|
RAW_ENHANCED = RAW_FLAG | ENHANCED_FLAG
|
||||||
|
ORIGIN_LOWER_LEFT = 0x01
|
||||||
|
ORIGIN_LOWER_RIGHT = 0x02
|
||||||
|
ORIGIN_UPPER_RIGHT = 0x04
|
||||||
|
|
||||||
|
TOUCHPAD_NAME = "Logitech K400 Raw Touchpad"
|
||||||
|
FEATURE_WAIT_SECONDS = 15.0
|
||||||
|
RECONNECT_DELAY_SECONDS = 2.0
|
||||||
|
|
||||||
|
|
||||||
|
class DeviceNotReady(RuntimeError):
|
||||||
|
"""Expected transient state: the K400 is paired but asleep/offline."""
|
||||||
|
|
||||||
|
|
||||||
|
# --- HID++ raw report parsing ------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Touch:
|
||||||
|
finger_id: int
|
||||||
|
contact_status: int
|
||||||
|
x: int
|
||||||
|
y: int
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class RawFrame:
|
||||||
|
spurious: bool
|
||||||
|
touches: tuple[Touch, Touch]
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class TouchpadInfo:
|
||||||
|
x_size: int
|
||||||
|
y_size: int
|
||||||
|
max_fingers: int
|
||||||
|
origin: int
|
||||||
|
dpi: int
|
||||||
|
|
||||||
|
|
||||||
|
def parse_touch(data: bytes, offset: int) -> Touch:
|
||||||
|
x_high = data[offset]
|
||||||
|
y_high = data[offset + 2]
|
||||||
|
return Touch(
|
||||||
|
finger_id=data[offset + 6] >> 4,
|
||||||
|
contact_status=y_high >> 6,
|
||||||
|
x=((x_high & 0x3F) << 8) | data[offset + 1],
|
||||||
|
y=((y_high & 0x3F) << 8) | data[offset + 3],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_frame(data: bytes) -> RawFrame | None:
|
||||||
|
if len(data) < 16:
|
||||||
|
return None
|
||||||
|
return RawFrame(
|
||||||
|
spurious=bool(data[8] & 0x02),
|
||||||
|
touches=(parse_touch(data, 2), parse_touch(data, 9)),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_info(data: bytes) -> TouchpadInfo:
|
||||||
|
if not data or len(data) < 15:
|
||||||
|
raise RuntimeError(f"Short/empty TOUCHPAD_RAW_XY GetTouchpadInfo response: {data!r}")
|
||||||
|
return TouchpadInfo(
|
||||||
|
x_size=int.from_bytes(data[0:2], "big"),
|
||||||
|
y_size=int.from_bytes(data[2:4], "big"),
|
||||||
|
max_fingers=data[7],
|
||||||
|
origin=data[8],
|
||||||
|
dpi=int.from_bytes(data[13:15], "big"),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def active_touches(frame: RawFrame) -> list[Touch]:
|
||||||
|
touches = [t for t in frame.touches if t.finger_id != 0 and t.contact_status != 0]
|
||||||
|
if touches:
|
||||||
|
return touches
|
||||||
|
|
||||||
|
# Defensive fallback in case this firmware represents contact status
|
||||||
|
# differently while still supplying finger IDs.
|
||||||
|
return [t for t in frame.touches if t.finger_id != 0]
|
||||||
|
|
||||||
|
|
||||||
|
def origin_inversions(origin: int) -> tuple[bool, bool]:
|
||||||
|
# Screen-relative coordinates: +X right, +Y down.
|
||||||
|
invert_x = origin in (ORIGIN_LOWER_RIGHT, ORIGIN_UPPER_RIGHT)
|
||||||
|
invert_y = origin in (ORIGIN_LOWER_LEFT, ORIGIN_LOWER_RIGHT)
|
||||||
|
return invert_x, invert_y
|
||||||
|
|
||||||
|
|
||||||
|
# --- HID++ device access (via Solaar's logitech_receiver) --------------------
|
||||||
|
|
||||||
|
|
||||||
|
class StartedEventsListener(listener.EventsListener):
|
||||||
|
def __init__(self, receiver, callback):
|
||||||
|
self.started_event = threading.Event()
|
||||||
|
super().__init__(receiver, callback)
|
||||||
|
|
||||||
|
def has_started(self):
|
||||||
|
self.started_event.set()
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Candidate:
|
||||||
|
receiver: object
|
||||||
|
device: object
|
||||||
|
path: str
|
||||||
|
online: bool
|
||||||
|
has_raw_feature: bool
|
||||||
|
|
||||||
|
|
||||||
|
def find_k400():
|
||||||
|
"""Find the paired K400 Plus.
|
||||||
|
|
||||||
|
Prefer one that is awake and answers TOUCHPAD_RAW_XY, then one that is
|
||||||
|
awake. A sole paired K400 is used even while asleep; wait_for_feature()
|
||||||
|
then waits for it to wake.
|
||||||
|
"""
|
||||||
|
opened = []
|
||||||
|
candidates = []
|
||||||
|
|
||||||
|
for dev_info in base.receivers():
|
||||||
|
try:
|
||||||
|
r = receiver_mod.create_receiver(base, dev_info)
|
||||||
|
if not r:
|
||||||
|
continue
|
||||||
|
opened.append(r)
|
||||||
|
|
||||||
|
# Solaar stops iterating after the receiver's paired-device count
|
||||||
|
for dev in list(r):
|
||||||
|
if (dev.wpid or "").upper() != WPID_K400_PLUS:
|
||||||
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
|
online = bool(dev.ping())
|
||||||
|
except Exception:
|
||||||
|
online = False
|
||||||
|
|
||||||
|
has_raw_feature = False
|
||||||
|
if online:
|
||||||
|
try:
|
||||||
|
has_raw_feature = bool(dev.features[RAW_FEATURE])
|
||||||
|
except Exception as exc:
|
||||||
|
LOG.debug("K400 slot %d could not probe 0x6100: %s", dev.number, exc)
|
||||||
|
|
||||||
|
candidates.append(Candidate(r, dev, dev_info.path, online, has_raw_feature))
|
||||||
|
except Exception as exc:
|
||||||
|
LOG.debug("Unable to inspect receiver %s: %s", dev_info.path, exc)
|
||||||
|
|
||||||
|
preferred = (
|
||||||
|
[c for c in candidates if c.online and c.has_raw_feature]
|
||||||
|
or [c for c in candidates if c.online]
|
||||||
|
or candidates
|
||||||
|
)
|
||||||
|
selected = preferred[0] if len(preferred) == 1 else None
|
||||||
|
|
||||||
|
for r in opened:
|
||||||
|
if selected is None or r is not selected.receiver:
|
||||||
|
try:
|
||||||
|
r.close()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if selected is None:
|
||||||
|
if not preferred:
|
||||||
|
raise RuntimeError("Could not find a paired Logitech K400 Plus")
|
||||||
|
if not any(c.online for c in preferred):
|
||||||
|
raise DeviceNotReady("Multiple paired K400 Plus records, none responding; waiting for one to wake")
|
||||||
|
locations = ", ".join(f"{c.path} slot {c.device.number}" for c in preferred)
|
||||||
|
raise RuntimeError(f"Found multiple responding K400 Plus devices: {locations}")
|
||||||
|
|
||||||
|
LOG.info(
|
||||||
|
"Selected K400 Plus on receiver %s slot %d (online=%s)",
|
||||||
|
selected.path, selected.device.number, selected.online,
|
||||||
|
)
|
||||||
|
return selected.receiver, selected.device
|
||||||
|
|
||||||
|
|
||||||
|
def wait_for_feature(dev, timeout_seconds: float, interval_seconds: float = 0.25) -> int:
|
||||||
|
"""Wake the device and wait for TOUCHPAD_RAW_XY to become queryable.
|
||||||
|
|
||||||
|
Solaar's FeaturesArray refuses feature discovery while dev.online is false,
|
||||||
|
and a K400 may be paired but asleep. Retry ping/feature discovery, falling
|
||||||
|
back to a direct ROOT.GetFeature query. If a transient lookup cached False,
|
||||||
|
the false entry is removed before installing the known-good feature index.
|
||||||
|
"""
|
||||||
|
deadline = time.monotonic() + timeout_seconds
|
||||||
|
last_error = None
|
||||||
|
|
||||||
|
while time.monotonic() < deadline:
|
||||||
|
try:
|
||||||
|
dev.ping()
|
||||||
|
except Exception as exc:
|
||||||
|
last_error = exc
|
||||||
|
|
||||||
|
if dev.online:
|
||||||
|
try:
|
||||||
|
index = dev.features[RAW_FEATURE]
|
||||||
|
if index:
|
||||||
|
return index
|
||||||
|
except Exception as exc:
|
||||||
|
last_error = exc
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = dev.request(0x0000, struct.pack("!H", int(RAW_FEATURE)))
|
||||||
|
if response and response[0]:
|
||||||
|
index = response[0]
|
||||||
|
|
||||||
|
# FeaturesArray forbids deletion through its public API, so
|
||||||
|
# use the underlying dict operation only for this recovery
|
||||||
|
if dict.get(dev.features, RAW_FEATURE) is False:
|
||||||
|
dict.__delitem__(dev.features, RAW_FEATURE)
|
||||||
|
|
||||||
|
dev.features[RAW_FEATURE] = index
|
||||||
|
if len(response) > 1:
|
||||||
|
dev.features.flags[RAW_FEATURE] = response[1]
|
||||||
|
if len(response) > 2:
|
||||||
|
dev.features.version[RAW_FEATURE] = response[2]
|
||||||
|
return index
|
||||||
|
except Exception as exc:
|
||||||
|
last_error = exc
|
||||||
|
|
||||||
|
time.sleep(interval_seconds)
|
||||||
|
|
||||||
|
message = (
|
||||||
|
f"Timed out waiting for HID++ feature 0x{int(RAW_FEATURE):04X} "
|
||||||
|
f"(online={dev.online}; last error: {last_error!r})"
|
||||||
|
)
|
||||||
|
if not dev.online:
|
||||||
|
raise DeviceNotReady(message)
|
||||||
|
raise RuntimeError(message)
|
||||||
|
|
||||||
|
|
||||||
|
def enable_raw_reports(dev) -> None:
|
||||||
|
dev.feature_request(RAW_FEATURE, 0x20, bytes([RAW_ENHANCED]))
|
||||||
|
reply = dev.feature_request(RAW_FEATURE, 0x10)
|
||||||
|
if not reply or (reply[0] & RAW_FLAG) == 0:
|
||||||
|
raise RuntimeError(f"Failed to enable HID++ raw reporting; readback was {reply!r}")
|
||||||
|
if reply[0] != RAW_ENHANCED:
|
||||||
|
LOG.warning(
|
||||||
|
"Device did not preserve every requested state bit: requested=0x%02X actual=0x%02X",
|
||||||
|
RAW_ENHANCED, reply[0],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# --- Virtual touchpad --------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
def make_absinfo(maximum: int, resolution: int = 0) -> AbsInfo:
|
||||||
|
return AbsInfo(value=0, min=0, max=maximum, fuzz=0, flat=0, resolution=resolution)
|
||||||
|
|
||||||
|
|
||||||
|
class VirtualTouchpad:
|
||||||
|
"""Translate K400 raw contacts into a two-slot Linux Type-B MT touchpad.
|
||||||
|
|
||||||
|
The uinput device is created on first connect and kept across HID++
|
||||||
|
reconnects, so the desktop keeps its settings for it.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.ui = None
|
||||||
|
self.geometry = None
|
||||||
|
self.invert_x = False
|
||||||
|
self.invert_y = False
|
||||||
|
# The HID++ listener thread and the reconnect loop both write events
|
||||||
|
self.lock = threading.Lock()
|
||||||
|
|
||||||
|
self.finger_to_slot: dict[int, int] = {}
|
||||||
|
self.slot_to_finger: dict[int, int] = {}
|
||||||
|
self.slot_xy: dict[int, tuple[int, int]] = {}
|
||||||
|
self.next_tracking_id = 1
|
||||||
|
|
||||||
|
self.last_btn_touch = 0
|
||||||
|
self.last_tool_finger = 0
|
||||||
|
self.last_tool_doubletap = 0
|
||||||
|
|
||||||
|
def configure(self, info: TouchpadInfo):
|
||||||
|
self.invert_x, self.invert_y = origin_inversions(info.origin)
|
||||||
|
resolution = max(1, round(info.dpi / 25.4))
|
||||||
|
geometry = (info.x_size, info.y_size, resolution)
|
||||||
|
|
||||||
|
if self.ui is not None:
|
||||||
|
if geometry != self.geometry:
|
||||||
|
LOG.warning(
|
||||||
|
"K400 geometry changed after reconnect: was %s now %s; keeping the original",
|
||||||
|
self.geometry, geometry,
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
self.geometry = geometry
|
||||||
|
x_max, y_max, _ = geometry
|
||||||
|
self.ui = UInput(
|
||||||
|
{
|
||||||
|
ecodes.EV_KEY: [ecodes.BTN_TOUCH, ecodes.BTN_TOOL_FINGER, ecodes.BTN_TOOL_DOUBLETAP],
|
||||||
|
ecodes.EV_ABS: [
|
||||||
|
(ecodes.ABS_X, make_absinfo(x_max, resolution)),
|
||||||
|
(ecodes.ABS_Y, make_absinfo(y_max, resolution)),
|
||||||
|
(ecodes.ABS_MT_SLOT, make_absinfo(1)),
|
||||||
|
(ecodes.ABS_MT_TRACKING_ID, make_absinfo(65535)),
|
||||||
|
(ecodes.ABS_MT_POSITION_X, make_absinfo(x_max, resolution)),
|
||||||
|
(ecodes.ABS_MT_POSITION_Y, make_absinfo(y_max, resolution)),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
name=TOUCHPAD_NAME,
|
||||||
|
# Logitech's vendor ID with a deliberately synthetic product ID
|
||||||
|
vendor=0x046D,
|
||||||
|
product=0xF400,
|
||||||
|
version=1,
|
||||||
|
bustype=ecodes.BUS_USB,
|
||||||
|
phys="k400-touchpad/input0",
|
||||||
|
# Indirect pointing device, not a touchscreen
|
||||||
|
input_props=[ecodes.INPUT_PROP_POINTER],
|
||||||
|
)
|
||||||
|
LOG.info(
|
||||||
|
"Created virtual touchpad %s, %dx%d, %d units/mm (~%.1fx%.1f mm)",
|
||||||
|
self.ui.device.path if self.ui.device else self.ui.devnode,
|
||||||
|
x_max, y_max, resolution, x_max / resolution, y_max / resolution,
|
||||||
|
)
|
||||||
|
# Give udev/libinput time to pick up the device before the first events
|
||||||
|
time.sleep(0.5)
|
||||||
|
|
||||||
|
def _xy(self, touch: Touch) -> tuple[int, int]:
|
||||||
|
x_max, y_max, _ = self.geometry
|
||||||
|
x = x_max - touch.x if self.invert_x else touch.x
|
||||||
|
y = y_max - touch.y if self.invert_y else touch.y
|
||||||
|
return max(0, min(x_max, x)), max(0, min(y_max, y))
|
||||||
|
|
||||||
|
def _new_tracking_id(self) -> int:
|
||||||
|
tid = self.next_tracking_id
|
||||||
|
self.next_tracking_id = tid + 1 if tid < 65535 else 1
|
||||||
|
return tid
|
||||||
|
|
||||||
|
def release_all(self):
|
||||||
|
with self.lock:
|
||||||
|
if self.ui is None:
|
||||||
|
return
|
||||||
|
changed = False
|
||||||
|
|
||||||
|
for slot in sorted(self.slot_to_finger):
|
||||||
|
self.ui.write(ecodes.EV_ABS, ecodes.ABS_MT_SLOT, slot)
|
||||||
|
self.ui.write(ecodes.EV_ABS, ecodes.ABS_MT_TRACKING_ID, -1)
|
||||||
|
changed = True
|
||||||
|
|
||||||
|
self.finger_to_slot.clear()
|
||||||
|
self.slot_to_finger.clear()
|
||||||
|
self.slot_xy.clear()
|
||||||
|
|
||||||
|
for code, attr in (
|
||||||
|
(ecodes.BTN_TOUCH, "last_btn_touch"),
|
||||||
|
(ecodes.BTN_TOOL_FINGER, "last_tool_finger"),
|
||||||
|
(ecodes.BTN_TOOL_DOUBLETAP, "last_tool_doubletap"),
|
||||||
|
):
|
||||||
|
if getattr(self, attr):
|
||||||
|
self.ui.write(ecodes.EV_KEY, code, 0)
|
||||||
|
setattr(self, attr, 0)
|
||||||
|
changed = True
|
||||||
|
|
||||||
|
if changed:
|
||||||
|
self.ui.syn()
|
||||||
|
|
||||||
|
def process(self, frame: RawFrame):
|
||||||
|
if frame.spurious:
|
||||||
|
return
|
||||||
|
|
||||||
|
# The K400 reports at most two contacts. If malformed data ever
|
||||||
|
# contains duplicate IDs, keep only the first occurrence.
|
||||||
|
current = {}
|
||||||
|
for touch in active_touches(frame):
|
||||||
|
current.setdefault(touch.finger_id, touch)
|
||||||
|
|
||||||
|
with self.lock:
|
||||||
|
if self.ui is None:
|
||||||
|
return
|
||||||
|
old_ids = set(self.finger_to_slot)
|
||||||
|
new_ids = set(current)
|
||||||
|
|
||||||
|
# Release vanished contacts first so a slot can be reused this frame
|
||||||
|
for finger_id in sorted(old_ids - new_ids):
|
||||||
|
slot = self.finger_to_slot.pop(finger_id)
|
||||||
|
self.slot_to_finger.pop(slot, None)
|
||||||
|
self.slot_xy.pop(slot, None)
|
||||||
|
self.ui.write(ecodes.EV_ABS, ecodes.ABS_MT_SLOT, slot)
|
||||||
|
self.ui.write(ecodes.EV_ABS, ecodes.ABS_MT_TRACKING_ID, -1)
|
||||||
|
|
||||||
|
for finger_id in sorted(new_ids - old_ids):
|
||||||
|
free = next((s for s in (0, 1) if s not in self.slot_to_finger), None)
|
||||||
|
if free is None:
|
||||||
|
LOG.warning("More contacts than MT slots; ignoring finger id %d", finger_id)
|
||||||
|
continue
|
||||||
|
self.finger_to_slot[finger_id] = free
|
||||||
|
self.slot_to_finger[free] = finger_id
|
||||||
|
self.ui.write(ecodes.EV_ABS, ecodes.ABS_MT_SLOT, free)
|
||||||
|
self.ui.write(ecodes.EV_ABS, ecodes.ABS_MT_TRACKING_ID, self._new_tracking_id())
|
||||||
|
|
||||||
|
# Emit every tracked contact each frame so libinput sees the raw
|
||||||
|
# sensor report cadence
|
||||||
|
for finger_id, slot in sorted(self.finger_to_slot.items(), key=lambda p: p[1]):
|
||||||
|
touch = current.get(finger_id)
|
||||||
|
if touch is None:
|
||||||
|
continue
|
||||||
|
x, y = self._xy(touch)
|
||||||
|
self.ui.write(ecodes.EV_ABS, ecodes.ABS_MT_SLOT, slot)
|
||||||
|
self.ui.write(ecodes.EV_ABS, ecodes.ABS_MT_POSITION_X, x)
|
||||||
|
self.ui.write(ecodes.EV_ABS, ecodes.ABS_MT_POSITION_Y, y)
|
||||||
|
self.slot_xy[slot] = (x, y)
|
||||||
|
|
||||||
|
count = len(self.slot_to_finger)
|
||||||
|
|
||||||
|
# Touchpads also need the legacy single-touch axes; mirror the
|
||||||
|
# lowest-numbered active slot
|
||||||
|
if count:
|
||||||
|
xy = self.slot_xy.get(min(self.slot_to_finger))
|
||||||
|
if xy is not None:
|
||||||
|
self.ui.write(ecodes.EV_ABS, ecodes.ABS_X, xy[0])
|
||||||
|
self.ui.write(ecodes.EV_ABS, ecodes.ABS_Y, xy[1])
|
||||||
|
|
||||||
|
for code, attr, value in (
|
||||||
|
(ecodes.BTN_TOUCH, "last_btn_touch", int(count > 0)),
|
||||||
|
(ecodes.BTN_TOOL_FINGER, "last_tool_finger", int(count == 1)),
|
||||||
|
(ecodes.BTN_TOOL_DOUBLETAP, "last_tool_doubletap", int(count >= 2)),
|
||||||
|
):
|
||||||
|
if value != getattr(self, attr):
|
||||||
|
self.ui.write(ecodes.EV_KEY, code, value)
|
||||||
|
setattr(self, attr, value)
|
||||||
|
|
||||||
|
self.ui.syn()
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
self.release_all()
|
||||||
|
if self.ui is not None:
|
||||||
|
self.ui.close()
|
||||||
|
self.ui = None
|
||||||
|
|
||||||
|
|
||||||
|
# --- Session / reconnect loop ------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
def run(touchpad: VirtualTouchpad, stop: threading.Event):
|
||||||
|
session = 0
|
||||||
|
|
||||||
|
while not stop.is_set():
|
||||||
|
session += 1
|
||||||
|
r = dev = events = None
|
||||||
|
feature_index = None
|
||||||
|
old_raw_state = None
|
||||||
|
raw_enabled = False
|
||||||
|
reconfigure = threading.Event()
|
||||||
|
reconfigure_failures = 0
|
||||||
|
|
||||||
|
try:
|
||||||
|
r, dev = find_k400()
|
||||||
|
feature_index = wait_for_feature(dev, FEATURE_WAIT_SECONDS)
|
||||||
|
|
||||||
|
info = parse_info(dev.feature_request(RAW_FEATURE, 0x00))
|
||||||
|
LOG.info(
|
||||||
|
"K400 raw surface: %dx%d, dpi=%d, origin=%d, max_fingers=%d",
|
||||||
|
info.x_size, info.y_size, info.dpi, info.origin, info.max_fingers,
|
||||||
|
)
|
||||||
|
touchpad.configure(info)
|
||||||
|
|
||||||
|
def callback(n):
|
||||||
|
if n.devnumber != dev.number:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Receiver connection notification; the K400 forgets raw mode
|
||||||
|
# while asleep, so re-enable it on every link-up
|
||||||
|
if n.sub_id == 0x41:
|
||||||
|
flags = (n.data[0] & 0xF0) if n.data else 0x40
|
||||||
|
dev.online = not (flags & 0x40)
|
||||||
|
touchpad.release_all()
|
||||||
|
if dev.online:
|
||||||
|
LOG.debug("K400 link established; re-enabling raw mode")
|
||||||
|
reconfigure.set()
|
||||||
|
else:
|
||||||
|
LOG.debug("K400 asleep/offline")
|
||||||
|
return
|
||||||
|
|
||||||
|
if n.sub_id != feature_index or (n.address >> 4) != 0x00:
|
||||||
|
return
|
||||||
|
frame = parse_frame(n.data)
|
||||||
|
if frame is None:
|
||||||
|
LOG.warning("Short raw XY notification: %r", n.data)
|
||||||
|
return
|
||||||
|
touchpad.process(frame)
|
||||||
|
|
||||||
|
events = StartedEventsListener(r, callback)
|
||||||
|
events.start()
|
||||||
|
if not events.started_event.wait(timeout=3.0):
|
||||||
|
raise RuntimeError("Timed out starting HID++ receiver listener")
|
||||||
|
|
||||||
|
state_reply = dev.feature_request(RAW_FEATURE, 0x10)
|
||||||
|
old_raw_state = state_reply[0] if state_reply else 0x00
|
||||||
|
enable_raw_reports(dev)
|
||||||
|
raw_enabled = True
|
||||||
|
LOG.info("K400 raw touchpad active (receiver slot %d)", dev.number)
|
||||||
|
|
||||||
|
while not stop.is_set():
|
||||||
|
if not events.is_alive():
|
||||||
|
raise ConnectionError("HID++ receiver listener stopped")
|
||||||
|
if not reconfigure.wait(timeout=1.0):
|
||||||
|
continue
|
||||||
|
reconfigure.clear()
|
||||||
|
if stop.is_set():
|
||||||
|
break
|
||||||
|
|
||||||
|
touchpad.release_all()
|
||||||
|
try:
|
||||||
|
feature_index = wait_for_feature(dev, min(FEATURE_WAIT_SECONDS, 4.0))
|
||||||
|
enable_raw_reports(dev)
|
||||||
|
reconfigure_failures = 0
|
||||||
|
LOG.info("K400 raw mode re-enabled after wake")
|
||||||
|
except DeviceNotReady as exc:
|
||||||
|
reconfigure_failures = 0
|
||||||
|
LOG.debug("K400 went offline during re-enable (%s); waiting for next link-up", exc)
|
||||||
|
except Exception as exc:
|
||||||
|
reconfigure_failures += 1
|
||||||
|
if not events.is_alive() or reconfigure_failures >= 3:
|
||||||
|
raise ConnectionError("Repeated raw-mode re-enable failure") from exc
|
||||||
|
LOG.debug("Transient re-enable failure %d/3: %s", reconfigure_failures, exc)
|
||||||
|
if stop.wait(RECONNECT_DELAY_SECONDS):
|
||||||
|
break
|
||||||
|
reconfigure.set()
|
||||||
|
|
||||||
|
except DeviceNotReady as exc:
|
||||||
|
LOG.debug("K400 not ready (%s); retrying", exc)
|
||||||
|
except Exception as exc:
|
||||||
|
if stop.is_set():
|
||||||
|
break
|
||||||
|
LOG.warning(
|
||||||
|
"K400 HID++ session #%d lost (%s). Retrying in %.1f s.",
|
||||||
|
session, exc, RECONNECT_DELAY_SECONDS,
|
||||||
|
exc_info=LOG.isEnabledFor(logging.DEBUG),
|
||||||
|
)
|
||||||
|
finally:
|
||||||
|
try:
|
||||||
|
touchpad.release_all()
|
||||||
|
except Exception:
|
||||||
|
LOG.debug("Error releasing touches", exc_info=True)
|
||||||
|
|
||||||
|
if stop.is_set() and dev is not None and raw_enabled:
|
||||||
|
try:
|
||||||
|
restore = 0x00 if old_raw_state is None else old_raw_state
|
||||||
|
dev.feature_request(RAW_FEATURE, 0x20, bytes([restore]))
|
||||||
|
LOG.info("Restored HID++ raw-report state to 0x%02X", restore)
|
||||||
|
except Exception:
|
||||||
|
LOG.warning("Could not restore raw-report state during shutdown")
|
||||||
|
|
||||||
|
if events is not None:
|
||||||
|
try:
|
||||||
|
events.stop()
|
||||||
|
events.join(timeout=2.0)
|
||||||
|
except Exception:
|
||||||
|
LOG.debug("Error stopping receiver listener", exc_info=True)
|
||||||
|
if r is not None:
|
||||||
|
try:
|
||||||
|
r.close()
|
||||||
|
except Exception:
|
||||||
|
LOG.debug("Error closing receiver", exc_info=True)
|
||||||
|
|
||||||
|
if not stop.is_set():
|
||||||
|
stop.wait(RECONNECT_DELAY_SECONDS)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description="Logitech K400 Plus raw touchpad bridge")
|
||||||
|
parser.add_argument("-v", "--verbose", action="count", default=0, help="-v for info, -vv for debug")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# Keep Solaar's own logging at WARNING so journald isn't flooded with
|
||||||
|
# HID++ frames
|
||||||
|
logging.basicConfig(level=logging.WARNING, format="%(levelname)-8s %(name)s: %(message)s")
|
||||||
|
LOG.setLevel([logging.WARNING, logging.INFO, logging.DEBUG][min(args.verbose, 2)])
|
||||||
|
|
||||||
|
touchpad = VirtualTouchpad()
|
||||||
|
stop = threading.Event()
|
||||||
|
|
||||||
|
def on_signal(signum, _frame):
|
||||||
|
LOG.info("Received signal %s; stopping", signum)
|
||||||
|
stop.set()
|
||||||
|
|
||||||
|
signal.signal(signal.SIGINT, on_signal)
|
||||||
|
signal.signal(signal.SIGTERM, on_signal)
|
||||||
|
try:
|
||||||
|
run(touchpad, stop)
|
||||||
|
finally:
|
||||||
|
touchpad.close()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -1,9 +1,14 @@
|
|||||||
{ pkgs, ... }:
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
{
|
{
|
||||||
services.tailscale = {
|
services.tailscale = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
# Required for the GNOME extension to control tailscale without root
|
# Required for the systray to control tailscale without root
|
||||||
extraSetFlags = [ "--operator=alex" ];
|
extraSetFlags = [ "--operator=alex" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -13,12 +18,31 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
home-manager.users.alex = {
|
home-manager.users.alex = {
|
||||||
|
# The official tailscale systray, including the node list and exit nodes
|
||||||
|
services.tailscale-systray = {
|
||||||
|
enable = true;
|
||||||
|
package = config.services.tailscale.package;
|
||||||
|
};
|
||||||
|
|
||||||
|
# The systray never retries if no tray exists when it starts, so wait for the
|
||||||
|
# AppIndicator extension to provide one. This is done in the main process,
|
||||||
|
# rather than `ExecStartPre`, to not block activation while waiting
|
||||||
|
systemd.user.services.tailscale-systray.Service.ExecStart = lib.mkForce (toString (
|
||||||
|
pkgs.writeShellScript "tailscale-systray" ''
|
||||||
|
until ${pkgs.systemd}/bin/busctl --user status org.kde.StatusNotifierWatcher >/dev/null 2>&1; do
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
exec ${lib.getExe config.services.tailscale.package} systray
|
||||||
|
''
|
||||||
|
));
|
||||||
|
|
||||||
programs.gnome-shell = {
|
programs.gnome-shell = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
extensions = [
|
extensions = [
|
||||||
# Tailscale in the GNOME quick settings, including Mullvad exit nodes
|
# GNOME has no system tray without it
|
||||||
{ package = pkgs.gnomeExtensions.tailscale-qs; }
|
{ package = pkgs.gnomeExtensions.appindicator; }
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ in
|
|||||||
homepage.enable = true;
|
homepage.enable = true;
|
||||||
disk-smart.enable = true;
|
disk-smart.enable = true;
|
||||||
puppy-tracker.enable = true;
|
puppy-tracker.enable = true;
|
||||||
solo-referee.enable = true;
|
|
||||||
todo.enable = true;
|
todo.enable = true;
|
||||||
schema.enable = true;
|
schema.enable = true;
|
||||||
atuin.enable = true;
|
atuin.enable = true;
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ ${sectorEntitiesYaml}
|
|||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ trigger.from_state.state | int(-1) >= 0 and trigger.to_state.state | int(0) > trigger.from_state.state | int(0) }}"
|
value_template: "{{ trigger.from_state.state | int(-1) >= 0 and trigger.to_state.state | int(0) > trigger.from_state.state | int(0) }}"
|
||||||
action:
|
action:
|
||||||
- service: notify.phones
|
- service: notify.mobile_app_pixel_9_pro
|
||||||
data:
|
data:
|
||||||
title: "Disk SMART warning"
|
title: "Disk SMART warning"
|
||||||
message: "{{ trigger.to_state.attributes.friendly_name }} increased from {{ trigger.from_state.state }} to {{ trigger.to_state.state }}"
|
message: "{{ trigger.to_state.attributes.friendly_name }} increased from {{ trigger.from_state.state }} to {{ trigger.to_state.state }}"
|
||||||
@@ -120,7 +120,7 @@ ${smartPassedEntitiesYaml}
|
|||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ trigger.to_state.state | lower == 'false' }}"
|
value_template: "{{ trigger.to_state.state | lower == 'false' }}"
|
||||||
action:
|
action:
|
||||||
- service: notify.phones
|
- service: notify.mobile_app_pixel_9_pro
|
||||||
data:
|
data:
|
||||||
title: "Disk SMART FAILURE"
|
title: "Disk SMART FAILURE"
|
||||||
message: "{{ trigger.to_state.attributes.friendly_name }} reports SMART failure — drive is likely failing"
|
message: "{{ trigger.to_state.attributes.friendly_name }} reports SMART failure — drive is likely failing"
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ alert:
|
|||||||
state: "on"
|
state: "on"
|
||||||
repeat: 60
|
repeat: 60
|
||||||
notifiers:
|
notifiers:
|
||||||
- phones
|
- mobile_app_pixel_9_pro
|
||||||
|
|
||||||
${cfg.extraConfig}'';
|
${cfg.extraConfig}'';
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,6 @@ let
|
|||||||
snapshot /var/lib/jellyfin "$STATE/jellyfin" --exclude='transcodes/' --exclude='cache/' --exclude='metadata/' --exclude='log/' --exclude='data/subtitles/'
|
snapshot /var/lib/jellyfin "$STATE/jellyfin" --exclude='transcodes/' --exclude='cache/' --exclude='metadata/' --exclude='log/' --exclude='data/subtitles/'
|
||||||
snapshot /var/lib/audiobookshelf "$STATE/audiobookshelf" --exclude='metadata/'
|
snapshot /var/lib/audiobookshelf "$STATE/audiobookshelf" --exclude='metadata/'
|
||||||
snapshot /var/lib/puppy-tracker "$STATE/puppy-tracker"
|
snapshot /var/lib/puppy-tracker "$STATE/puppy-tracker"
|
||||||
snapshot /var/lib/solo-referee "$STATE/solo-referee"
|
|
||||||
snapshot /var/lib/todo "$STATE/todo"
|
snapshot /var/lib/todo "$STATE/todo"
|
||||||
snapshot /var/lib/schema "$STATE/schema"
|
snapshot /var/lib/schema "$STATE/schema"
|
||||||
snapshot /var/lib/dagbok "$STATE/dagbok"
|
snapshot /var/lib/dagbok "$STATE/dagbok"
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
{
|
|
||||||
inputs,
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
enabled = config.mod.solo-referee.enable;
|
|
||||||
port = 8090;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
mod.solo-referee = {
|
|
||||||
enable = lib.mkEnableOption "Enable solo-referee module";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
imports = [
|
|
||||||
inputs.solo-referee.nixosModules.default
|
|
||||||
];
|
|
||||||
|
|
||||||
config = lib.mkIf enabled {
|
|
||||||
mod.homepage.services = [
|
|
||||||
{
|
|
||||||
name = "Solo Referee";
|
|
||||||
port = port;
|
|
||||||
description = "Solo-RPG tool with Claude as GM";
|
|
||||||
# url omitted → homepage links to http://manatee:${port}.
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
services.solo-referee = {
|
|
||||||
enable = true;
|
|
||||||
inherit port;
|
|
||||||
# Reachable on the LAN / Tailscale at manatee:${port}; no public vhost.
|
|
||||||
address = "0.0.0.0";
|
|
||||||
openFirewall = true;
|
|
||||||
# Anthropic API key kept out of the store; the file holds
|
|
||||||
# `ANTHROPIC_API_KEY=...`. Without it the offline stub GM runs.
|
|
||||||
apiKeyFile = config.age.secrets."solo-referee-api-key".path;
|
|
||||||
};
|
|
||||||
|
|
||||||
age.secrets."solo-referee-api-key".file =
|
|
||||||
../../../../secrets/manatee/solo-referee-api-key.age;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -632,7 +632,7 @@ Setup prefix for keybindings.
|
|||||||
)
|
)
|
||||||
|
|
||||||
:custom
|
:custom
|
||||||
(eglot-code-action-indications nil)
|
(refactor-indications nil)
|
||||||
|
|
||||||
:hook (
|
:hook (
|
||||||
(eglot-managed-mode . mp-eglot-eldoc)
|
(eglot-managed-mode . mp-eglot-eldoc)
|
||||||
@@ -718,10 +718,12 @@ Setup prefix for keybindings.
|
|||||||
** Dagbok
|
** Dagbok
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package dagbok
|
(use-package dagbok
|
||||||
:commands (dagbok-today dagbok-open-date dagbok-next-day dagbok-previous-day
|
:commands (dagbok-today dagbok-year dagbok-next-day dagbok-previous-day
|
||||||
dagbok-switch-journal dagbok-note dagbok-tasks dagbok-search
|
dagbok-switch-journal dagbok-note dagbok-tasks dagbok-questions dagbok-search
|
||||||
dagbok-add-task dagbok-set-status dagbok-toggle-flag
|
dagbok-add-task dagbok-ask dagbok-set-status dagbok-toggle-flag
|
||||||
dagbok-toggle-highlight dagbok-reload dagbok-browse)
|
dagbok-toggle-highlight dagbok-toggle-completed dagbok-backlinks
|
||||||
|
dagbok-set-property dagbok-toggle-toc dagbok-goto-heading
|
||||||
|
dagbok-refresh dagbok-browse)
|
||||||
:custom
|
:custom
|
||||||
(dagbok-url "https://dagbok.ppp.pm")
|
(dagbok-url "https://dagbok.ppp.pm")
|
||||||
(dagbok-token-file "/run/agenix/dagbok-token")
|
(dagbok-token-file "/run/agenix/dagbok-token")
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ in
|
|||||||
_args = [
|
_args = [
|
||||||
"SUPER + SHIFT + x"
|
"SUPER + SHIFT + x"
|
||||||
(lib.generators.mkLuaInline
|
(lib.generators.mkLuaInline
|
||||||
''hl.dsp.exec_cmd("${pause-music}; ${pkgs.hyprlock}/bin/hyprlock & sleep 0.5; systemctl suspend")''
|
''hl.dsp.exec_cmd("${pause-music}; ${pkgs.hyprlock}/bin/hyprlock & sleep 0.5; systemctl suspend-then-hibernate")''
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ in
|
|||||||
server = "http://manatee:4533";
|
server = "http://manatee:4533";
|
||||||
user = "navi";
|
user = "navi";
|
||||||
passwordCommand = "cat ${config.age.secrets."navidrome-password".path}";
|
passwordCommand = "cat ${config.age.secrets."navidrome-password".path}";
|
||||||
|
anthropicKeyCommand = "cat ${config.age.secrets."ndp-llm-api-key".path}";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -84,4 +85,10 @@ in
|
|||||||
owner = "alex";
|
owner = "alex";
|
||||||
group = "users";
|
group = "users";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
age.secrets."ndp-llm-api-key" = {
|
||||||
|
file = ../../../../secrets/pinwheel/ndp-llm-api-key.age;
|
||||||
|
owner = "alex";
|
||||||
|
group = "users";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
{ pkgs, ... }:
|
||||||
|
let
|
||||||
|
picard = pkgs.symlinkJoin {
|
||||||
|
name = "picard";
|
||||||
|
paths = [ pkgs.picard ];
|
||||||
|
nativeBuildInputs = [ pkgs.makeWrapper ];
|
||||||
|
postBuild = ''
|
||||||
|
wrapProgram $out/bin/picard --set QT_SCREEN_SCALE_FACTORS 1.5
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
plugins = pkgs.linkFarm "picard-plugins" {
|
||||||
|
replaygain2 = pkgs.fetchFromGitHub {
|
||||||
|
owner = "metabrainz";
|
||||||
|
repo = "picard-plugin-replaygain2";
|
||||||
|
tag = "v2.3.1";
|
||||||
|
hash = "sha256-NBn/LgjDRVCHmbI+bU4j29UhrL33ctV9jXj6CfFRBWA=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
home-manager.users.alex = { lib, ... }: {
|
||||||
|
home.packages = [
|
||||||
|
picard
|
||||||
|
pkgs.rsgain
|
||||||
|
];
|
||||||
|
|
||||||
|
home.activation.picardReplayGainPlugin = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||||
|
if ! ${pkgs.picard}/bin/picard-cli plugins info replaygain2 2>/dev/null | grep -qF "${plugins}/replaygain2"; then
|
||||||
|
run ${pkgs.picard}/bin/picard-cli --yes plugins install --no-git --reinstall "${plugins}/replaygain2" \
|
||||||
|
|| warnEcho "Failed to install Picard plugin replaygain2"
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -27,17 +27,25 @@ in
|
|||||||
description = "Notify low battery at this level";
|
description = "Notify low battery at this level";
|
||||||
};
|
};
|
||||||
|
|
||||||
suspendCapacity = lib.mkOption {
|
hibernateCapacity = lib.mkOption {
|
||||||
default = 10;
|
default = 10;
|
||||||
description = "Warn at this level and then suspend if power is not plugged in";
|
description = "Warn at this level and then hibernate if power is not plugged in";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
|
swapDevices = lib.mkIf enabled [
|
||||||
|
{
|
||||||
|
device = "/var/lib/swapfile";
|
||||||
|
size = 64 * 1024; # MiB
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
services = lib.mkIf enabled {
|
services = lib.mkIf enabled {
|
||||||
upower = {
|
upower = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
criticalPowerAction = "Hibernate";
|
||||||
};
|
};
|
||||||
|
|
||||||
logind.settings.Login = {
|
logind.settings.Login = {
|
||||||
@@ -62,7 +70,7 @@ in
|
|||||||
timers = {
|
timers = {
|
||||||
"monitor-low-battery" = {
|
"monitor-low-battery" = {
|
||||||
unitConfig = {
|
unitConfig = {
|
||||||
Description = "monitors battery level and suspends computer if battery is low";
|
Description = "monitors battery level and hibernates computer if battery is low";
|
||||||
};
|
};
|
||||||
|
|
||||||
timerConfig = {
|
timerConfig = {
|
||||||
@@ -78,7 +86,7 @@ in
|
|||||||
services = {
|
services = {
|
||||||
"monitor-low-battery" = {
|
"monitor-low-battery" = {
|
||||||
unitConfig = {
|
unitConfig = {
|
||||||
Description = "monitors battery level and suspends computer if battery is low";
|
Description = "monitors battery level and hibernates computer if battery is low";
|
||||||
};
|
};
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
@@ -105,13 +113,13 @@ in
|
|||||||
notify-send --expire-time=0 --urgency=critical "Battery Low"
|
notify-send --expire-time=0 --urgency=critical "Battery Low"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $BATTERY_CAPACITY -le ${builtins.toString lowbat.suspendCapacity} && $BATTERY_STATUS = "Discharging" ]]; then
|
if [[ $BATTERY_CAPACITY -le ${builtins.toString lowbat.hibernateCapacity} && $BATTERY_STATUS = "Discharging" ]]; then
|
||||||
notify-send --expire-time=0 --urgency=critical "Battery Critically Low" "Suspending in 60 seconds if power is not plugged in"
|
notify-send --expire-time=0 --urgency=critical "Battery Critically Low" "Hibernating in 60 seconds if power is not plugged in"
|
||||||
sleep 60s
|
sleep 60s
|
||||||
|
|
||||||
BATTERY_STATUS=$(cat /sys/class/power_supply/${lowbat.battery}/status)
|
BATTERY_STATUS=$(cat /sys/class/power_supply/${lowbat.battery}/status)
|
||||||
if [[ $BATTERY_STATUS = "Discharging" ]]; then
|
if [[ $BATTERY_STATUS = "Discharging" ]]; then
|
||||||
${pause-music}; ${pkgs.hyprlock}/bin/hyprlock & sleep 0.5; systemctl suspend
|
${pause-music}; ${pkgs.hyprlock}/bin/hyprlock & sleep 0.5; systemctl hibernate
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|||||||
@@ -75,7 +75,12 @@ let
|
|||||||
if [ "$EXIT_NODE_ONLINE" == "true" ]; then
|
if [ "$EXIT_NODE_ONLINE" == "true" ]; then
|
||||||
tailscale set --exit-node="" && ${pkgs.libnotify}/bin/notify-send "Disconnected from Exit Node"
|
tailscale set --exit-node="" && ${pkgs.libnotify}/bin/notify-send "Disconnected from Exit Node"
|
||||||
else
|
else
|
||||||
tailscale set --exit-node=$PREFERRED_EXIT_NODE && ${pkgs.libnotify}/bin/notify-send "Connected to Exit Node"
|
tailscale set --exit-node=$PREFERRED_EXIT_NODE || exit 1
|
||||||
|
|
||||||
|
EXIT_NODE_NAME=$(tailscale status --json | ${pkgs.jq}/bin/jq -r '
|
||||||
|
.Peer.[] | select(.ExitNode)
|
||||||
|
| .HostName + (if .Location then " (\(.Location.City), \(.Location.Country))" else "" end)')
|
||||||
|
${pkgs.libnotify}/bin/notify-send "Connected to Exit Node" "$EXIT_NODE_NAME"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,26 +92,33 @@ let
|
|||||||
esac
|
esac
|
||||||
'';
|
'';
|
||||||
|
|
||||||
work-vpn-status = pkgs.writeShellScript "work-vpn-status" ''
|
work-vpn = pkgs.writeShellScript "work-vpn" ''
|
||||||
ACTIVE_ENVS=""
|
connected() {
|
||||||
|
systemctl is-active --quiet openvpn-work-staging.service openvpn-work-production.service
|
||||||
|
}
|
||||||
|
|
||||||
STAGING_STATUS=$(systemctl is-active openvpn-work-staging.service)
|
output() {
|
||||||
if [ "$STAGING_STATUS" == "active" ]; then
|
if connected; then
|
||||||
ACTIVE_ENVS="S"
|
echo '{ "text": "WORK-VPN ON", "class": "connected" }'
|
||||||
fi
|
|
||||||
|
|
||||||
PRODUCTION_STATUS=$(systemctl is-active openvpn-work-production.service)
|
|
||||||
if [ "$PRODUCTION_STATUS" == "active" ]; then
|
|
||||||
if [ -n "$ACTIVE_ENVS" ]; then
|
|
||||||
ACTIVE_ENVS="$ACTIVE_ENVS&P"
|
|
||||||
else
|
else
|
||||||
ACTIVE_ENVS="P"
|
echo "{ \"text\": \"<span font='16' rise='-3000'></span>\", \"tooltip\": \"Work VPN off\", \"class\": \"disconnected\" }"
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [ -n "$ACTIVE_ENVS" ]; then
|
toggle() {
|
||||||
echo "WORK-VPN $ACTIVE_ENVS ON"
|
if connected; then
|
||||||
|
systemctl stop work-vpn.target && ${pkgs.libnotify}/bin/notify-send "Disconnected from work VPN"
|
||||||
|
else
|
||||||
|
systemctl start work-vpn.target && ${pkgs.libnotify}/bin/notify-send "Connected to work VPN"
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
--toggle)
|
||||||
|
toggle ;;
|
||||||
|
--output)
|
||||||
|
output ;;
|
||||||
|
esac
|
||||||
'';
|
'';
|
||||||
|
|
||||||
toggle-bt-power = pkgs.writeShellScript "toggle-bt-power" ''
|
toggle-bt-power = pkgs.writeShellScript "toggle-bt-power" ''
|
||||||
@@ -142,20 +154,22 @@ in
|
|||||||
|
|
||||||
modules-left = lib.mkIf hyprlandEnabled [ "hyprland/workspaces" ];
|
modules-left = lib.mkIf hyprlandEnabled [ "hyprland/workspaces" ];
|
||||||
modules-right = [
|
modules-right = [
|
||||||
"custom/work-vpn-status"
|
|
||||||
"custom/music"
|
"custom/music"
|
||||||
"custom/container-status"
|
"custom/container-status"
|
||||||
"custom/dunst"
|
"custom/dunst"
|
||||||
"bluetooth"
|
"bluetooth"
|
||||||
"wireplumber"
|
"wireplumber"
|
||||||
|
"custom/work-vpn"
|
||||||
"custom/tailscale"
|
"custom/tailscale"
|
||||||
"network"
|
"network"
|
||||||
"battery"
|
"battery"
|
||||||
"clock"
|
"clock"
|
||||||
];
|
];
|
||||||
|
|
||||||
"custom/work-vpn-status" = {
|
"custom/work-vpn" = {
|
||||||
exec = "${work-vpn-status}";
|
exec = "${work-vpn} --output";
|
||||||
|
return-type = "json";
|
||||||
|
on-click-right = "${work-vpn} --toggle";
|
||||||
interval = 2;
|
interval = 2;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -247,12 +261,14 @@ in
|
|||||||
|
|
||||||
modules-left = lib.mkIf hyprlandEnabled [ "hyprland/workspaces" ];
|
modules-left = lib.mkIf hyprlandEnabled [ "hyprland/workspaces" ];
|
||||||
modules-right = [
|
modules-right = [
|
||||||
"custom/work-vpn-status"
|
"custom/work-vpn"
|
||||||
"clock"
|
"clock"
|
||||||
];
|
];
|
||||||
|
|
||||||
"custom/work-vpn-status" = {
|
"custom/work-vpn" = {
|
||||||
exec = "${work-vpn-status}";
|
exec = "${work-vpn} --output";
|
||||||
|
return-type = "json";
|
||||||
|
on-click-right = "${work-vpn} --toggle";
|
||||||
interval = 2;
|
interval = 2;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -306,10 +322,14 @@ in
|
|||||||
color: #${config.lib.colors.warning};
|
color: #${config.lib.colors.warning};
|
||||||
}
|
}
|
||||||
|
|
||||||
#custom-work-vpn-status {
|
#custom-work-vpn.connected {
|
||||||
color: #${config.lib.colors.warning};
|
color: #${config.lib.colors.warning};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#custom-work-vpn.disconnected {
|
||||||
|
color: #${config.lib.colors.foreground-dim};
|
||||||
|
}
|
||||||
|
|
||||||
#custom-container-status.running {
|
#custom-container-status.running {
|
||||||
color: #${config.lib.colors.warning};
|
color: #${config.lib.colors.warning};
|
||||||
font-size: 30px;
|
font-size: 30px;
|
||||||
|
|||||||
@@ -7,22 +7,25 @@
|
|||||||
let
|
let
|
||||||
inherit (config.boot.kernelPackages) kernel kernelModuleMakeFlags;
|
inherit (config.boot.kernelPackages) kernel kernelModuleMakeFlags;
|
||||||
|
|
||||||
ipu6-isys = pkgs.stdenv.mkDerivation {
|
mkPatchedModules =
|
||||||
pname = "ipu6-isys";
|
{
|
||||||
|
pname,
|
||||||
|
srcPaths,
|
||||||
|
dir,
|
||||||
|
patches,
|
||||||
|
postPatch,
|
||||||
|
}:
|
||||||
|
pkgs.stdenv.mkDerivation {
|
||||||
|
inherit pname patches postPatch;
|
||||||
inherit (kernel) version;
|
inherit (kernel) version;
|
||||||
|
|
||||||
__structuredAttrs = true;
|
__structuredAttrs = true;
|
||||||
|
|
||||||
patches = [ ./ipu6-isys-runtime-pm-null-check.patch ];
|
|
||||||
|
|
||||||
nativeBuildInputs = kernel.moduleBuildDependencies;
|
nativeBuildInputs = kernel.moduleBuildDependencies;
|
||||||
|
|
||||||
unpackPhase = ''
|
unpackPhase = ''
|
||||||
tar -xf ${kernel.src} --strip-components=1 --wildcards '*/drivers/media/pci/intel/ipu6/*'
|
tar -xf ${kernel.src} --strip-components=1 --wildcards \
|
||||||
'';
|
${lib.escapeShellArgs (map (path: "*/${path}") srcPaths)}
|
||||||
|
|
||||||
postPatch = ''
|
|
||||||
sed -i '/+= intel-ipu6\.o/d' drivers/media/pci/intel/ipu6/Makefile
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
makeFlags = kernelModuleMakeFlags ++ [
|
makeFlags = kernelModuleMakeFlags ++ [
|
||||||
@@ -37,18 +40,46 @@ let
|
|||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
runHook preBuild
|
runHook preBuild
|
||||||
make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build \
|
make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build \
|
||||||
M=$(pwd)/drivers/media/pci/intel/ipu6 "''${makeFlags[@]}"
|
M=$(pwd)/${dir} "''${makeFlags[@]}"
|
||||||
runHook postBuild
|
runHook postBuild
|
||||||
'';
|
'';
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build \
|
make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build \
|
||||||
M=$(pwd)/drivers/media/pci/intel/ipu6 modules_install \
|
M=$(pwd)/${dir} modules_install \
|
||||||
"''${makeFlags[@]}" "''${installFlags[@]}"
|
"''${makeFlags[@]}" "''${installFlags[@]}"
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ipu6-isys = mkPatchedModules {
|
||||||
|
pname = "ipu6-isys";
|
||||||
|
srcPaths = [ "drivers/media/pci/intel/ipu6/*" ];
|
||||||
|
dir = "drivers/media/pci/intel/ipu6";
|
||||||
|
patches = [ ./ipu6-isys-runtime-pm-null-check.patch ];
|
||||||
|
postPatch = ''
|
||||||
|
sed -i '/+= intel-ipu6\.o/d' drivers/media/pci/intel/ipu6/Makefile
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
usbio = mkPatchedModules {
|
||||||
|
pname = "usbio";
|
||||||
|
srcPaths = [
|
||||||
|
"drivers/usb/misc/usbio.c"
|
||||||
|
"drivers/gpio/gpio-usbio.c"
|
||||||
|
"include/linux/usb/usbio.h"
|
||||||
|
];
|
||||||
|
dir = "usbio";
|
||||||
|
patches = [ ./usbio-reset-resume.patch ];
|
||||||
|
postPatch = ''
|
||||||
|
mkdir -p usbio/include/linux/usb
|
||||||
|
cp drivers/usb/misc/usbio.c drivers/gpio/gpio-usbio.c usbio/
|
||||||
|
cp include/linux/usb/usbio.h usbio/include/linux/usb/
|
||||||
|
echo 'LINUXINCLUDE := -I$(src)/include $(LINUXINCLUDE)' > usbio/Kbuild
|
||||||
|
echo 'obj-m += usbio.o gpio-usbio.o' >> usbio/Kbuild
|
||||||
|
'';
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [
|
||||||
@@ -79,7 +110,10 @@ in
|
|||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
boot.extraModulePackages = [ ipu6-isys ];
|
boot.extraModulePackages = [
|
||||||
|
ipu6-isys
|
||||||
|
usbio
|
||||||
|
];
|
||||||
|
|
||||||
hardware.ipu6 = {
|
hardware.ipu6 = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|||||||
@@ -0,0 +1,320 @@
|
|||||||
|
--- a/drivers/usb/misc/usbio.c
|
||||||
|
+++ b/drivers/usb/misc/usbio.c
|
||||||
|
@@ -83,6 +83,7 @@
|
||||||
|
* @gpios: GPIO bank descriptors
|
||||||
|
* @nr_gpio_banks: Number of I2C busses
|
||||||
|
* @gpios: I2C bank descriptors
|
||||||
|
+ * @reset_count: Number of times the bridge was reset while bound
|
||||||
|
*/
|
||||||
|
struct usbio_device {
|
||||||
|
struct device *dev;
|
||||||
|
@@ -115,6 +116,8 @@
|
||||||
|
|
||||||
|
unsigned int nr_i2c_buses;
|
||||||
|
struct usbio_i2c_bus_desc i2cs[USBIO_MAX_I2CBUSES];
|
||||||
|
+
|
||||||
|
+ unsigned int reset_count;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@@ -428,6 +431,21 @@
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_NS_GPL(usbio_get_quirks, "USBIO");
|
||||||
|
|
||||||
|
+unsigned int usbio_get_reset_count(struct auxiliary_device *adev)
|
||||||
|
+{
|
||||||
|
+ struct usbio_client *client = adev_to_client(adev);
|
||||||
|
+ struct usbio_device *usbio;
|
||||||
|
+
|
||||||
|
+ guard(mutex)(&client->mutex);
|
||||||
|
+
|
||||||
|
+ usbio = client->bridge;
|
||||||
|
+ if (!usbio)
|
||||||
|
+ return 0; /* Disconnected */
|
||||||
|
+
|
||||||
|
+ return usbio->reset_count;
|
||||||
|
+}
|
||||||
|
+EXPORT_SYMBOL_NS_GPL(usbio_get_reset_count, "USBIO");
|
||||||
|
+
|
||||||
|
static void usbio_auxdev_release(struct device *dev)
|
||||||
|
{
|
||||||
|
struct auxiliary_device *adev = to_auxiliary_dev(dev);
|
||||||
|
@@ -503,6 +521,47 @@
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static int usbio_init_bridge(struct usbio_device *usbio)
|
||||||
|
+{
|
||||||
|
+ struct usbio_protver protver;
|
||||||
|
+ struct usbio_fwver fwver;
|
||||||
|
+ int ret;
|
||||||
|
+
|
||||||
|
+ guard(mutex)(&usbio->ctrl_mutex);
|
||||||
|
+
|
||||||
|
+ ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_HS, NULL, 0, NULL, 0);
|
||||||
|
+ if (ret < 0)
|
||||||
|
+ return ret;
|
||||||
|
+
|
||||||
|
+ ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_PROTVER, NULL, 0,
|
||||||
|
+ &protver, sizeof(protver));
|
||||||
|
+ if (ret < 0)
|
||||||
|
+ return ret;
|
||||||
|
+
|
||||||
|
+ ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_FWVER, NULL, 0,
|
||||||
|
+ &fwver, sizeof(fwver));
|
||||||
|
+ if (ret < 0)
|
||||||
|
+ return ret;
|
||||||
|
+
|
||||||
|
+ ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_ENUMGPIO, NULL, 0,
|
||||||
|
+ usbio->gpios, sizeof(usbio->gpios));
|
||||||
|
+ if (ret < 0 || ret % sizeof(struct usbio_gpio_bank_desc))
|
||||||
|
+ return (ret < 0) ? ret : -EPROTO;
|
||||||
|
+ usbio->nr_gpio_banks = ret / sizeof(struct usbio_gpio_bank_desc);
|
||||||
|
+
|
||||||
|
+ ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_ENUMI2C, NULL, 0,
|
||||||
|
+ usbio->i2cs, sizeof(usbio->i2cs));
|
||||||
|
+ if (ret < 0 || ret % sizeof(struct usbio_i2c_bus_desc))
|
||||||
|
+ return (ret < 0) ? ret : -EPROTO;
|
||||||
|
+ usbio->nr_i2c_buses = ret / sizeof(struct usbio_i2c_bus_desc);
|
||||||
|
+
|
||||||
|
+ dev_dbg(usbio->dev, "ProtVer(BCD): %02x FwVer: %d.%d.%d.%d\n",
|
||||||
|
+ protver.ver, fwver.major, fwver.minor,
|
||||||
|
+ le16_to_cpu(fwver.patch), le16_to_cpu(fwver.build));
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static int usbio_suspend(struct usb_interface *intf, pm_message_t msg)
|
||||||
|
{
|
||||||
|
struct usbio_device *usbio = usb_get_intfdata(intf);
|
||||||
|
@@ -519,6 +578,26 @@
|
||||||
|
return usb_submit_urb(usbio->urb, GFP_KERNEL);
|
||||||
|
}
|
||||||
|
|
||||||
|
+static int usbio_reset_resume(struct usb_interface *intf)
|
||||||
|
+{
|
||||||
|
+ struct usbio_device *usbio = usb_get_intfdata(intf);
|
||||||
|
+ int ret;
|
||||||
|
+
|
||||||
|
+ ret = usb_submit_urb(usbio->urb, GFP_KERNEL);
|
||||||
|
+ if (ret)
|
||||||
|
+ return ret;
|
||||||
|
+
|
||||||
|
+ ret = usbio_init_bridge(usbio);
|
||||||
|
+ if (ret) {
|
||||||
|
+ usb_kill_urb(usbio->urb);
|
||||||
|
+ return ret;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ usbio->reset_count++;
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static void usbio_disconnect(struct usb_interface *intf)
|
||||||
|
{
|
||||||
|
struct usbio_device *usbio = usb_get_intfdata(intf);
|
||||||
|
@@ -550,9 +629,7 @@
|
||||||
|
struct usb_device *udev = interface_to_usbdev(intf);
|
||||||
|
struct usb_endpoint_descriptor *ep_in, *ep_out;
|
||||||
|
struct device *dev = &intf->dev;
|
||||||
|
- struct usbio_protver protver;
|
||||||
|
struct usbio_device *usbio;
|
||||||
|
- struct usbio_fwver fwver;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
usbio = devm_kzalloc(dev, sizeof(*usbio), GFP_KERNEL);
|
||||||
|
@@ -623,51 +700,16 @@
|
||||||
|
goto err_free_urb;
|
||||||
|
}
|
||||||
|
|
||||||
|
- mutex_lock(&usbio->ctrl_mutex);
|
||||||
|
-
|
||||||
|
- ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_HS, NULL, 0, NULL, 0);
|
||||||
|
- if (ret < 0)
|
||||||
|
- goto err_unlock;
|
||||||
|
-
|
||||||
|
- ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_PROTVER, NULL, 0,
|
||||||
|
- &protver, sizeof(protver));
|
||||||
|
- if (ret < 0)
|
||||||
|
- goto err_unlock;
|
||||||
|
-
|
||||||
|
- ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_FWVER, NULL, 0,
|
||||||
|
- &fwver, sizeof(fwver));
|
||||||
|
- if (ret < 0)
|
||||||
|
- goto err_unlock;
|
||||||
|
-
|
||||||
|
- ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_ENUMGPIO, NULL, 0,
|
||||||
|
- usbio->gpios, sizeof(usbio->gpios));
|
||||||
|
- if (ret < 0 || ret % sizeof(struct usbio_gpio_bank_desc)) {
|
||||||
|
- ret = (ret < 0) ? ret : -EPROTO;
|
||||||
|
- goto err_unlock;
|
||||||
|
- }
|
||||||
|
- usbio->nr_gpio_banks = ret / sizeof(struct usbio_gpio_bank_desc);
|
||||||
|
-
|
||||||
|
- ret = usbio_ctrl_msg(usbio, USBIO_PKTTYPE_CTRL, USBIO_CTRLCMD_ENUMI2C, NULL, 0,
|
||||||
|
- usbio->i2cs, sizeof(usbio->i2cs));
|
||||||
|
- if (ret < 0 || ret % sizeof(struct usbio_i2c_bus_desc)) {
|
||||||
|
- ret = (ret < 0) ? ret : -EPROTO;
|
||||||
|
- goto err_unlock;
|
||||||
|
- }
|
||||||
|
- usbio->nr_i2c_buses = ret / sizeof(struct usbio_i2c_bus_desc);
|
||||||
|
-
|
||||||
|
- mutex_unlock(&usbio->ctrl_mutex);
|
||||||
|
-
|
||||||
|
- dev_dbg(dev, "ProtVer(BCD): %02x FwVer: %d.%d.%d.%d\n",
|
||||||
|
- protver.ver, fwver.major, fwver.minor,
|
||||||
|
- le16_to_cpu(fwver.patch), le16_to_cpu(fwver.build));
|
||||||
|
+ ret = usbio_init_bridge(usbio);
|
||||||
|
+ if (ret)
|
||||||
|
+ goto err_kill_urb;
|
||||||
|
|
||||||
|
usbio_enum_gpios(usbio);
|
||||||
|
usbio_enum_i2cs(usbio);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
-err_unlock:
|
||||||
|
- mutex_unlock(&usbio->ctrl_mutex);
|
||||||
|
+err_kill_urb:
|
||||||
|
usb_kill_urb(usbio->urb);
|
||||||
|
err_free_urb:
|
||||||
|
usb_free_urb(usbio->urb);
|
||||||
|
@@ -694,6 +736,7 @@
|
||||||
|
.disconnect = usbio_disconnect,
|
||||||
|
.suspend = usbio_suspend,
|
||||||
|
.resume = usbio_resume,
|
||||||
|
+ .reset_resume = usbio_reset_resume,
|
||||||
|
.id_table = usbio_table,
|
||||||
|
.supports_autosuspend = 1,
|
||||||
|
};
|
||||||
|
--- a/drivers/gpio/gpio-usbio.c
|
||||||
|
+++ b/drivers/gpio/gpio-usbio.c
|
||||||
|
@@ -15,14 +15,16 @@
|
||||||
|
|
||||||
|
struct usbio_gpio_bank {
|
||||||
|
u8 config[USBIO_GPIOSPERBANK];
|
||||||
|
+ u32 value;
|
||||||
|
u32 bitmap;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct usbio_gpio {
|
||||||
|
- struct mutex config_mutex; /* Protects banks[x].config */
|
||||||
|
+ struct mutex config_mutex; /* Protects banks[x].config and banks[x].value */
|
||||||
|
struct usbio_gpio_bank banks[USBIO_MAX_GPIOBANKS];
|
||||||
|
struct gpio_chip gc;
|
||||||
|
struct auxiliary_device *adev;
|
||||||
|
+ unsigned int reset_count;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct acpi_device_id usbio_gpio_acpi_hids[] = {
|
||||||
|
@@ -101,6 +103,13 @@
|
||||||
|
|
||||||
|
usbio_gpio_get_bank_and_pin(gc, offset, &bank, &pin);
|
||||||
|
|
||||||
|
+ scoped_guard(mutex, &gpio->config_mutex) {
|
||||||
|
+ if (value)
|
||||||
|
+ bank->value |= BIT(pin);
|
||||||
|
+ else
|
||||||
|
+ bank->value &= ~BIT(pin);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
gbuf.bankid = offset / USBIO_GPIOSPERBANK;
|
||||||
|
gbuf.pincount = 1;
|
||||||
|
gbuf.pin = pin;
|
||||||
|
@@ -178,6 +187,66 @@
|
||||||
|
return usbio_gpio_update_config(gc, offset, USBIO_GPIO_PINCFG_MASK, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
+static int usbio_gpio_restore(struct usbio_gpio *gpio)
|
||||||
|
+{
|
||||||
|
+ struct usbio_gpio_init ginit;
|
||||||
|
+ struct usbio_gpio_rw gbuf;
|
||||||
|
+ int ret;
|
||||||
|
+
|
||||||
|
+ guard(mutex)(&gpio->config_mutex);
|
||||||
|
+
|
||||||
|
+ for (unsigned int b = 0; b < USBIO_MAX_GPIOBANKS; b++) {
|
||||||
|
+ struct usbio_gpio_bank *bank = &gpio->banks[b];
|
||||||
|
+
|
||||||
|
+ for (unsigned int pin = 0; pin < USBIO_GPIOSPERBANK; pin++) {
|
||||||
|
+ u8 mode = bank->config[pin] & USBIO_GPIO_PINMOD_MASK;
|
||||||
|
+
|
||||||
|
+ if (mode == USBIO_GPIO_PINMOD_INVAL)
|
||||||
|
+ continue;
|
||||||
|
+
|
||||||
|
+ ginit.bankid = b;
|
||||||
|
+ ginit.config = bank->config[pin];
|
||||||
|
+ ginit.pincount = 1;
|
||||||
|
+ ginit.pin = pin;
|
||||||
|
+
|
||||||
|
+ ret = usbio_control_msg(gpio->adev, USBIO_PKTTYPE_GPIO, USBIO_GPIOCMD_INIT,
|
||||||
|
+ &ginit, sizeof(ginit), NULL, 0);
|
||||||
|
+ if (ret)
|
||||||
|
+ return ret;
|
||||||
|
+
|
||||||
|
+ if (mode != USBIO_GPIO_PINMOD_OUTPUT)
|
||||||
|
+ continue;
|
||||||
|
+
|
||||||
|
+ gbuf.bankid = b;
|
||||||
|
+ gbuf.pincount = 1;
|
||||||
|
+ gbuf.pin = pin;
|
||||||
|
+ gbuf.value = cpu_to_le32(bank->value & BIT(pin));
|
||||||
|
+
|
||||||
|
+ ret = usbio_control_msg(gpio->adev, USBIO_PKTTYPE_GPIO, USBIO_GPIOCMD_WRITE,
|
||||||
|
+ &gbuf, sizeof(gbuf), NULL, 0);
|
||||||
|
+ if (ret)
|
||||||
|
+ return ret;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int usbio_gpio_resume(struct device *dev)
|
||||||
|
+{
|
||||||
|
+ struct usbio_gpio *gpio = dev_get_drvdata(dev);
|
||||||
|
+ unsigned int reset_count = usbio_get_reset_count(gpio->adev);
|
||||||
|
+
|
||||||
|
+ if (reset_count == gpio->reset_count)
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+ gpio->reset_count = reset_count;
|
||||||
|
+
|
||||||
|
+ return usbio_gpio_restore(gpio);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static DEFINE_SIMPLE_DEV_PM_OPS(usbio_gpio_pm_ops, NULL, usbio_gpio_resume);
|
||||||
|
+
|
||||||
|
static int usbio_gpio_probe(struct auxiliary_device *adev,
|
||||||
|
const struct auxiliary_device_id *adev_id)
|
||||||
|
{
|
||||||
|
@@ -199,6 +268,8 @@
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
gpio->adev = adev;
|
||||||
|
+ gpio->reset_count = usbio_get_reset_count(adev);
|
||||||
|
+ dev_set_drvdata(dev, gpio);
|
||||||
|
|
||||||
|
usbio_acpi_bind(gpio->adev, usbio_gpio_acpi_hids);
|
||||||
|
|
||||||
|
@@ -238,7 +309,8 @@
|
||||||
|
static struct auxiliary_driver usbio_gpio_driver = {
|
||||||
|
.name = USBIO_GPIO_CLIENT,
|
||||||
|
.probe = usbio_gpio_probe,
|
||||||
|
- .id_table = usbio_gpio_id_table
|
||||||
|
+ .id_table = usbio_gpio_id_table,
|
||||||
|
+ .driver.pm = pm_sleep_ptr(&usbio_gpio_pm_ops),
|
||||||
|
};
|
||||||
|
module_auxiliary_driver(usbio_gpio_driver);
|
||||||
|
|
||||||
|
--- a/include/linux/usb/usbio.h
|
||||||
|
+++ b/include/linux/usb/usbio.h
|
||||||
|
@@ -172,6 +172,7 @@
|
||||||
|
void usbio_release(struct auxiliary_device *adev);
|
||||||
|
void usbio_get_txrxbuf_len(struct auxiliary_device *adev, u16 *txbuf_len, u16 *rxbuf_len);
|
||||||
|
unsigned long usbio_get_quirks(struct auxiliary_device *adev);
|
||||||
|
+unsigned int usbio_get_reset_count(struct auxiliary_device *adev);
|
||||||
|
void usbio_acpi_bind(struct auxiliary_device *adev, const struct acpi_device_id *hids);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -91,10 +91,10 @@ EOF
|
|||||||
(pkgs.writeShellScriptBin "work-vpn" ''
|
(pkgs.writeShellScriptBin "work-vpn" ''
|
||||||
case $1 in
|
case $1 in
|
||||||
up)
|
up)
|
||||||
sudo sh -c "systemctl start openvpn-work-staging.service; systemctl start openvpn-work-production.service"
|
systemctl start work-vpn.target
|
||||||
;;
|
;;
|
||||||
down)
|
down)
|
||||||
sudo sh -c "systemctl stop openvpn-work-staging.service; systemctl stop openvpn-work-production.service"
|
systemctl stop work-vpn.target
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
'')
|
'')
|
||||||
@@ -142,6 +142,34 @@ EOF
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemd.targets.work-vpn = lib.mkIf openvpnEnabled {
|
||||||
|
description = "Work VPN";
|
||||||
|
requires = [
|
||||||
|
"openvpn-work-staging.service"
|
||||||
|
"openvpn-work-production.service"
|
||||||
|
];
|
||||||
|
after = [
|
||||||
|
"openvpn-work-staging.service"
|
||||||
|
"openvpn-work-production.service"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services = lib.mkIf openvpnEnabled {
|
||||||
|
openvpn-work-staging.partOf = [ "work-vpn.target" ];
|
||||||
|
openvpn-work-production.partOf = [ "work-vpn.target" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
security.polkit.extraConfig = lib.mkIf openvpnEnabled ''
|
||||||
|
polkit.addRule(function(action, subject) {
|
||||||
|
if (action.id == "org.freedesktop.systemd1.manage-units" &&
|
||||||
|
subject.user == "alex" &&
|
||||||
|
action.lookup("unit") == "work-vpn.target" &&
|
||||||
|
["start", "stop", "restart"].indexOf(action.lookup("verb")) >= 0) {
|
||||||
|
return polkit.Result.YES;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
'';
|
||||||
|
|
||||||
age.secrets = {
|
age.secrets = {
|
||||||
"work-gitconfig" = lib.mkIf gitEnabled {
|
"work-gitconfig" = lib.mkIf gitEnabled {
|
||||||
file = ../../../../secrets/pinwheel/work-gitconfig.age;
|
file = ../../../../secrets/pinwheel/work-gitconfig.age;
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
+1
-1
@@ -28,6 +28,7 @@ in {
|
|||||||
"pinwheel/work-production-ovpn.age".publicKeys = [ pinwheel alex ];
|
"pinwheel/work-production-ovpn.age".publicKeys = [ pinwheel alex ];
|
||||||
"pinwheel/naviterm-config.age".publicKeys = [ pinwheel alex ];
|
"pinwheel/naviterm-config.age".publicKeys = [ pinwheel alex ];
|
||||||
"pinwheel/navidrome-password.age".publicKeys = [ pinwheel alex ];
|
"pinwheel/navidrome-password.age".publicKeys = [ pinwheel alex ];
|
||||||
|
"pinwheel/ndp-llm-api-key.age".publicKeys = [ pinwheel alex ];
|
||||||
"pinwheel/atuin-key.age".publicKeys = [ pinwheel alex ];
|
"pinwheel/atuin-key.age".publicKeys = [ pinwheel alex ];
|
||||||
|
|
||||||
"manatee/root.manatee.age".publicKeys = [ manatee alex ];
|
"manatee/root.manatee.age".publicKeys = [ manatee alex ];
|
||||||
@@ -47,7 +48,6 @@ in {
|
|||||||
"manatee/romm-db-password.age".publicKeys = [ manatee alex ];
|
"manatee/romm-db-password.age".publicKeys = [ manatee alex ];
|
||||||
"manatee/romm-metadata-api-keys.age".publicKeys = [ manatee alex ];
|
"manatee/romm-metadata-api-keys.age".publicKeys = [ manatee alex ];
|
||||||
"manatee/puppy-tracker-invite-code.age".publicKeys = [ manatee alex ];
|
"manatee/puppy-tracker-invite-code.age".publicKeys = [ manatee alex ];
|
||||||
"manatee/solo-referee-api-key.age".publicKeys = [ manatee alex ];
|
|
||||||
"manatee/todo-token.age".publicKeys = [ manatee alex ];
|
"manatee/todo-token.age".publicKeys = [ manatee alex ];
|
||||||
"manatee/dagbok-token.age".publicKeys = [ manatee pinwheel alex ];
|
"manatee/dagbok-token.age".publicKeys = [ manatee pinwheel alex ];
|
||||||
"manatee/schema-invite-code.age".publicKeys = [ manatee alex ];
|
"manatee/schema-invite-code.age".publicKeys = [ manatee alex ];
|
||||||
|
|||||||
Reference in new issue
Block a user