Compare commits
4 commits
9da25c99fe
...
a07a96b3bd
Author | SHA1 | Date | |
---|---|---|---|
a07a96b3bd | |||
324814f7e2 | |||
49d0cf16e3 | |||
ed511cd0fd |
24
flake.lock
24
flake.lock
|
@ -28,11 +28,11 @@
|
|||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1722339003,
|
||||
"narHash": "sha256-ZeS51uJI30ehNkcZ4uKqT4ZDARPyqrHADSKAwv5vVCU=",
|
||||
"lastModified": 1723293904,
|
||||
"narHash": "sha256-b+uqzj+Wa6xgMS9aNbX4I+sXeb5biPDi39VgvSFqFvU=",
|
||||
"owner": "ryantm",
|
||||
"repo": "agenix",
|
||||
"rev": "3f1dae074a12feb7327b4bf43cbac0d124488bb7",
|
||||
"rev": "f6291c5935fdc4e0bef208cfc0dcab7e3f7a1c41",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -176,11 +176,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1723080788,
|
||||
"narHash": "sha256-C5LbM5VMdcolt9zHeLQ0bYMRjUL+N+AL5pK7/tVTdes=",
|
||||
"lastModified": 1723685519,
|
||||
"narHash": "sha256-GkXQIoZmW2zCPp1YFtAYGg/xHNyFH/Mgm79lcs81rq0=",
|
||||
"owner": "nix-community",
|
||||
"repo": "disko",
|
||||
"rev": "ffc1f95f6c28e1c6d1e587b51a2147027a3e45ed",
|
||||
"rev": "276a0d055a720691912c6a34abb724e395c8e38a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -414,11 +414,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1722740924,
|
||||
"narHash": "sha256-UQPgA5d8azLZuDHZMPmvDszhuKF1Ek89SrTRtqsQ4Ss=",
|
||||
"lastModified": 1723352546,
|
||||
"narHash": "sha256-WTIrvp0yV8ODd6lxAq4F7EbrPQv0gscBnyfn559c3k8=",
|
||||
"owner": "Mic92",
|
||||
"repo": "nix-index-database",
|
||||
"rev": "97ca0a0fca0391de835f57e44f369a283e37890f",
|
||||
"rev": "ec78079a904d7d55e81a0468d764d0fffb50ac06",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -456,11 +456,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1722869614,
|
||||
"narHash": "sha256-7ojM1KSk3mzutD7SkrdSflHXEujPvW1u7QuqWoTLXQU=",
|
||||
"lastModified": 1723556749,
|
||||
"narHash": "sha256-+CHVZnTnIYRLYsARInHYoWkujzcRkLY/gXm3s5bE52o=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "883180e6550c1723395a3a342f830bfc5c371f6b",
|
||||
"rev": "4a92571f9207810b559c9eac203d1f4d79830073",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
@ -128,7 +128,12 @@
|
|||
auto_connect_gamepad = [
|
||||
bluez
|
||||
coreutils
|
||||
gnugrep
|
||||
final.gnugrep
|
||||
];
|
||||
powerplay-led-idle = [
|
||||
final.bash
|
||||
libinput
|
||||
libratbag
|
||||
];
|
||||
}
|
||||
// lib.mapAttrs import_script {
|
||||
|
|
79
scripts/powerplay-led-idle
Executable file
79
scripts/powerplay-led-idle
Executable file
|
@ -0,0 +1,79 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
# Constants
|
||||
SECONDS_UNTIL_FADE=$(( 1 * 60))
|
||||
SECONDS_UNTIL_OFF=$(( 5 * 60))
|
||||
|
||||
COLOR_ON=ff0000
|
||||
COLOR_FADE=880000
|
||||
COLOR_OFF=000000
|
||||
|
||||
# Logging
|
||||
|
||||
if [[ "$1" = "debug" ]]; then
|
||||
echo "Running with debugging" >&2
|
||||
DEBUG="true"
|
||||
|
||||
SECONDS_UNTIL_FADE=$(( 3 ))
|
||||
SECONDS_UNTIL_OFF=$(( 5 ))
|
||||
fi
|
||||
|
||||
log() {
|
||||
if [[ "$DEBUG" = "true" ]]; then
|
||||
echo "$@" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
# Implementation
|
||||
|
||||
main() {
|
||||
CURRENT_STATE="UNKNOWN"
|
||||
LAST_POINTER_MOTION="$(date +%s)"
|
||||
|
||||
if [ "$(ratbagctl list | wc -l)" -ne 1 ]; then
|
||||
echo "Not exactly one device found, exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DEVICE="$(ratbagctl list | cut -d: -f1)"
|
||||
|
||||
while true; do
|
||||
while read line; do
|
||||
LAST_POINTER_MOTION="$(date +%s)"
|
||||
break
|
||||
done < <(
|
||||
timeout 5s \
|
||||
libinput debug-events \
|
||||
| grep POINTER_MOTION
|
||||
)
|
||||
TIME_SINCE_LAST=$(( "$(date +%s)" - "$LAST_POINTER_MOTION" ))
|
||||
log "Last pointer motion was $TIME_SINCE_LAST seconds ago"
|
||||
if [ "$TIME_SINCE_LAST" -gt "$SECONDS_UNTIL_OFF" ]; then
|
||||
setState OFF "$COLOR_OFF"
|
||||
elif [ "$TIME_SINCE_LAST" -gt "$SECONDS_UNTIL_FADE" ]; then
|
||||
setState FADE "$COLOR_FADE"
|
||||
else
|
||||
setState ON "$COLOR_ON"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
setState() {
|
||||
STATE="$1"
|
||||
COLOR="$2"
|
||||
MODE="$3"
|
||||
|
||||
if [[ "$STATE" = "$CURRENT_STATE" ]]; then
|
||||
log "Already in $STATE state"
|
||||
return
|
||||
fi
|
||||
log "Changing state to $STATE"
|
||||
CURRENT_STATE="$STATE"
|
||||
|
||||
ratbagctl "$DEVICE" led 0 set mode on
|
||||
ratbagctl "$DEVICE" led 0 set color "$COLOR"
|
||||
}
|
||||
|
||||
main
|
|
@ -49,11 +49,6 @@ in
|
|||
url = "https://github.com/OhMyGuus/I-Still-Dont-Care-About-Cookies/releases/download/v1.1.4/istilldontcareaboutcookies-1.1.4.xpi";
|
||||
hash = "sha256-yt6yRiLTuaK4K/QwgkL9gCVGsSa7ndFOHqZvKqIGZ5U=";
|
||||
})
|
||||
(pkgs.fetchFirefoxAddon {
|
||||
name = "github_no_more";
|
||||
url = "https://addons.mozilla.org/firefox/downloads/file/4293306/github_no_more-0.0.1.xpi";
|
||||
hash = "sha256-1vzgo7z4K6aZAVAo5VqihYQi77mZ0rE68xbt7Oqz29s=";
|
||||
})
|
||||
|
||||
(pkgs.fetchFirefoxAddon {
|
||||
name = "vimium_ff";
|
||||
|
|
|
@ -23,6 +23,7 @@ in
|
|||
./swayidle.nix
|
||||
./swaylock.nix
|
||||
./theme.nix
|
||||
./powerplay-led-idle.nix
|
||||
];
|
||||
config = lib.mkIf (config.my.desktop == "sway") {
|
||||
services.mako.enable = true;
|
||||
|
|
17
user/sway/powerplay-led-idle.nix
Normal file
17
user/sway/powerplay-led-idle.nix
Normal file
|
@ -0,0 +1,17 @@
|
|||
{ pkgs, lib, ... }:
|
||||
{
|
||||
systemd.user.services.powerplay-led-idle = {
|
||||
Unit = {
|
||||
Description = "Autosuspend Powerplay mousepad led";
|
||||
PartOf = [ "graphical-session.target" ];
|
||||
After = [ "graphical-session.target" ];
|
||||
};
|
||||
Service = {
|
||||
ExecStart = lib.getExe pkgs.powerplay-led-idle;
|
||||
Restart = "on-failure";
|
||||
};
|
||||
Install = {
|
||||
WantedBy = [ "sway-session.target" ];
|
||||
};
|
||||
};
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
programs.vscode = {
|
||||
enable = true;
|
||||
package = pkgs.vscodium-fhs;
|
||||
package = pkgs.vscodium;
|
||||
extensions = with pkgs.vscode-extensions; [
|
||||
jnoortheen.nix-ide
|
||||
github.github-vscode-theme
|
||||
|
|
Loading…
Reference in a new issue