Compare commits

...

4 commits

Author SHA1 Message Date
Leonardo Eugênio a07a96b3bd firefox: remove github autoload extension 2024-08-17 02:40:11 -03:00
Leonardo Eugênio 324814f7e2 sway: suspend powerplay mousepad led in sync with mouse 2024-08-17 02:05:00 -03:00
Leonardo Eugênio 49d0cf16e3 vscode: don't use fhs 2024-08-16 21:21:54 -03:00
Leonardo Eugênio ed511cd0fd update 2024-08-16 21:21:39 -03:00
7 changed files with 116 additions and 19 deletions

View file

@ -28,11 +28,11 @@
"systems": "systems" "systems": "systems"
}, },
"locked": { "locked": {
"lastModified": 1722339003, "lastModified": 1723293904,
"narHash": "sha256-ZeS51uJI30ehNkcZ4uKqT4ZDARPyqrHADSKAwv5vVCU=", "narHash": "sha256-b+uqzj+Wa6xgMS9aNbX4I+sXeb5biPDi39VgvSFqFvU=",
"owner": "ryantm", "owner": "ryantm",
"repo": "agenix", "repo": "agenix",
"rev": "3f1dae074a12feb7327b4bf43cbac0d124488bb7", "rev": "f6291c5935fdc4e0bef208cfc0dcab7e3f7a1c41",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -176,11 +176,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1723080788, "lastModified": 1723685519,
"narHash": "sha256-C5LbM5VMdcolt9zHeLQ0bYMRjUL+N+AL5pK7/tVTdes=", "narHash": "sha256-GkXQIoZmW2zCPp1YFtAYGg/xHNyFH/Mgm79lcs81rq0=",
"owner": "nix-community", "owner": "nix-community",
"repo": "disko", "repo": "disko",
"rev": "ffc1f95f6c28e1c6d1e587b51a2147027a3e45ed", "rev": "276a0d055a720691912c6a34abb724e395c8e38a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -414,11 +414,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1722740924, "lastModified": 1723352546,
"narHash": "sha256-UQPgA5d8azLZuDHZMPmvDszhuKF1Ek89SrTRtqsQ4Ss=", "narHash": "sha256-WTIrvp0yV8ODd6lxAq4F7EbrPQv0gscBnyfn559c3k8=",
"owner": "Mic92", "owner": "Mic92",
"repo": "nix-index-database", "repo": "nix-index-database",
"rev": "97ca0a0fca0391de835f57e44f369a283e37890f", "rev": "ec78079a904d7d55e81a0468d764d0fffb50ac06",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -456,11 +456,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1722869614, "lastModified": 1723556749,
"narHash": "sha256-7ojM1KSk3mzutD7SkrdSflHXEujPvW1u7QuqWoTLXQU=", "narHash": "sha256-+CHVZnTnIYRLYsARInHYoWkujzcRkLY/gXm3s5bE52o=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "883180e6550c1723395a3a342f830bfc5c371f6b", "rev": "4a92571f9207810b559c9eac203d1f4d79830073",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -128,7 +128,12 @@
auto_connect_gamepad = [ auto_connect_gamepad = [
bluez bluez
coreutils coreutils
gnugrep final.gnugrep
];
powerplay-led-idle = [
final.bash
libinput
libratbag
]; ];
} }
// lib.mapAttrs import_script { // lib.mapAttrs import_script {

79
scripts/powerplay-led-idle Executable file
View 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

View file

@ -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"; 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="; 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 { (pkgs.fetchFirefoxAddon {
name = "vimium_ff"; name = "vimium_ff";

View file

@ -23,6 +23,7 @@ in
./swayidle.nix ./swayidle.nix
./swaylock.nix ./swaylock.nix
./theme.nix ./theme.nix
./powerplay-led-idle.nix
]; ];
config = lib.mkIf (config.my.desktop == "sway") { config = lib.mkIf (config.my.desktop == "sway") {
services.mako.enable = true; services.mako.enable = true;

View 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" ];
};
};
}

View file

@ -3,7 +3,7 @@
programs.vscode = { programs.vscode = {
enable = true; enable = true;
package = pkgs.vscodium-fhs; package = pkgs.vscodium;
extensions = with pkgs.vscode-extensions; [ extensions = with pkgs.vscode-extensions; [
jnoortheen.nix-ide jnoortheen.nix-ide
github.github-vscode-theme github.github-vscode-theme