feat(binto): move to new logitech mouse

This commit is contained in:
matt1432 2024-05-01 10:21:28 -04:00
parent 2caeb6f438
commit 585d764720
11 changed files with 68 additions and 193 deletions

View file

@ -11,7 +11,6 @@ in {
../../modules/kmscon.nix
../../modules/printer.nix
../../modules/ratbag-mice.nix
../../modules/razer.nix
../../modules/sshd.nix
../../modules/tailscale.nix

View file

@ -789,6 +789,22 @@
"type": "github"
}
},
"libratbag-src": {
"flake": false,
"locked": {
"lastModified": 1709658456,
"narHash": "sha256-9rlnGQ7kcXqX+8mFb0imnzLo0X6Nuca6fcMv+H6ZwEw=",
"owner": "libratbag",
"repo": "libratbag",
"rev": "8444ceb638b19c3fbeb073a5cd29f17c6d34dd07",
"type": "github"
},
"original": {
"owner": "libratbag",
"repo": "libratbag",
"type": "github"
}
},
"modernx-src": {
"flake": false,
"locked": {
@ -1566,6 +1582,22 @@
"type": "github"
}
},
"piper-src": {
"flake": false,
"locked": {
"lastModified": 1708275645,
"narHash": "sha256-ar1f0d2dzgUCL9F/AI1la26i/4Ab6SgxmeTjiI1J4z0=",
"owner": "libratbag",
"repo": "piper",
"rev": "66c1897540d107e48227ce05c5ac51ea41454feb",
"type": "github"
},
"original": {
"owner": "libratbag",
"repo": "piper",
"type": "github"
}
},
"plymouth-theme-src": {
"flake": false,
"locked": {
@ -1670,6 +1702,7 @@
"hyprland": "hyprland",
"jellyfin-flake": "jellyfin-flake",
"jellyfin-ultrachromic-src": "jellyfin-ultrachromic-src",
"libratbag-src": "libratbag-src",
"modernx-src": "modernx-src",
"nh": "nh",
"nix-eval-jobs": "nix-eval-jobs",
@ -1688,6 +1721,7 @@
"pam-fprint-grosshack-src": "pam-fprint-grosshack-src",
"pcsd": "pcsd",
"persist-properties-src": "persist-properties-src",
"piper-src": "piper-src",
"plymouth-theme-src": "plymouth-theme-src",
"pointer-event-src": "pointer-event-src",
"pokemon-colorscripts-src": "pokemon-colorscripts-src",

View file

@ -426,6 +426,20 @@
url = "https://repo.dec05eba.com/gpu-screen-recorder";
flake = false;
};
libratbag-src = {
type = "github";
owner = "libratbag";
repo = "libratbag";
flake = false;
};
piper-src = {
type = "github";
owner = "libratbag";
repo = "piper";
flake = false;
};
##
## MPV scripts

View file

@ -25,26 +25,3 @@
background-color: $bgfull;
}
}
.razer {
padding: 0 5px;
background: $bgfull;
.low {
color: $red;
}
.medium {
color: $yellow;
}
.high {
color: $green;
}
image {
padding-right: 5px;
font-size: 22px;
color: white;
}
}

View file

@ -7,7 +7,6 @@ import BarRevealer from './fullscreen.ts';
import Clock from './items/clock.ts';
import CurrentWindow from './items/current-window';
import NotifButton from './items/notif-button.ts';
import RazerStats from './items/razer-stats.ts';
import SysTray from './items/systray.ts';
const PADDING = 20;
@ -29,10 +28,6 @@ export default () => BarRevealer({
Separator(PADDING),
SysTray(),
Separator(PADDING / 2 / 2),
RazerStats(),
],
}),

View file

@ -1,93 +0,0 @@
import { execAsync, interval } from 'resource:///com/github/Aylur/ags/utils.js';
const { Box, Icon, Label } = Widget;
const RAZER_POLL = 10000;
const LOW_BATT = 20;
const RazerBat = Variable({
battery: 0,
charging: false,
sleeping: false,
disconnected: true,
});
const fetchInfo = () => {
execAsync([
'bash',
'-c',
"polychromatic-cli -n 'Razer Naga Pro (Wired)' -k" +
' || ' +
"polychromatic-cli -n 'Razer Naga Pro (Wireless)' -k",
]).then((out) => {
const batteryMatches = out.split('\n')
.filter((i) => i.includes('Battery'))[0]
.match(/[0-9]+/);
let sleeping = false;
let battery = batteryMatches !== null ?
parseInt(batteryMatches[0]) :
0;
// Don't set to zero when in sleep mode
if (battery === 0 && RazerBat.value.battery > 10) {
battery = RazerBat.value.battery;
sleeping = true;
}
// If 'Wireless' isn't in the logs it means the cmd found 'Wired'
const charging = !out.includes('Wireless');
RazerBat.value = {
battery,
charging,
sleeping,
disconnected: false,
};
}).catch(() => {
RazerBat.value.disconnected = true;
});
};
interval(RAZER_POLL, fetchInfo);
export default () => {
const percentage = Label({ vpack: 'center' });
const icon = Icon({ hpack: 'start' })
.hook(RazerBat, (self) => {
const v = RazerBat.value;
percentage.visible = !(v.disconnected || v.charging);
percentage.label = `${v.battery}%`;
self.icon = v.disconnected ?
'content-loading-symbolic' :
'mouse-razer-symbolic';
self.setCss(
v.disconnected || v.charging ?
'margin-right: -5px;' :
'',
);
self.toggleClassName(
'high',
v.battery > 66,
);
self.toggleClassName(
'medium',
v.battery > LOW_BATT && v.battery <= 66,
);
self.toggleClassName(
'low',
v.battery <= LOW_BATT,
);
});
return Box({
class_name: 'razer',
children: [icon, percentage],
});
};

View file

@ -176,7 +176,6 @@ export const Notification = ({
const BlockedApps = [
'Spotify',
'OpenRazer',
];
if (BlockedApps.find((app) => app === notif.app_name)) {

View file

@ -3,11 +3,6 @@
pkgs,
...
}: {
"${agsConfigDir}/config/icons/mouse-razer-symbolic.svg".source = pkgs.fetchurl {
url = "https://raw.githubusercontent.com/bithatch/razer-icon-font/main/src/devices/mouse.svg";
hash = "sha256-A1+eIp2VEFDyY23GIHKhbnByHXrnVS3QgIJ9sjjtuZw=";
};
"${agsConfigDir}/config/icons/down-large-symbolic.svg".source = pkgs.fetchurl {
url = "https://www.svgrepo.com/download/158537/down-chevron.svg";
hash = "sha256-mOfNjgZh0rt6XosKA2kpLY22lJldSS1XCphgrnvZH1s=";

View file

@ -8,15 +8,7 @@
inherit (osConfig.vars) mainMonitor;
miceNames = [
# Wireless
"razer-razer-naga-pro"
# Wired (it always changes)
"razer-razer-naga-pro-1"
"razer-naga-pro"
"razer-naga-pro-1"
"razer-naga-pro-2"
"razer-naga-pro-3"
"logitech-g502-x"
"logitech-g502-hero-gaming-mouse"
];
nagaConf = name: {

View file

@ -1,28 +1,26 @@
{
config,
lib,
libratbag-src,
pkgs,
piper-src,
...
}: let
inherit (config.vars) mainUser;
inherit (lib) mkIf;
cfgHypr =
config
.home-manager
.users
.${mainUser}
.wayland
.windowManager
.hyprland;
in {
services.ratbagd.enable = true;
}: {
services.ratbagd = {
enable = true;
# HOME-MANAGER CONFIG
home-manager.users.${mainUser} = {
home.packages = with pkgs; [piper];
wayland.windowManager.hyprland = mkIf (cfgHypr.enable) {
# settings.exec-once = [""];
package = pkgs.libratbag.overrideAttrs {
version = libratbag-src.shortRev;
src = libratbag-src;
};
};
environment.systemPackages = with pkgs; [
(piper.overrideAttrs {
name = "piper-${piper-src.shortRev}";
src = piper-src;
mesonFlags = [
"-Druntime-dependency-checks=false"
];
})
];
}

View file

@ -1,35 +0,0 @@
{
config,
lib,
pkgs,
...
}: let
inherit (config.vars) mainUser;
inherit (lib) mkIf;
cfgHypr =
config
.home-manager
.users
.${mainUser}
.wayland
.windowManager
.hyprland;
in {
hardware.openrazer = {
enable = true;
users = [mainUser];
};
environment.systemPackages = with pkgs; [
openrazer-daemon
polychromatic
];
# HOME-MANAGER CONFIG
home-manager.users.${mainUser} = {
wayland.windowManager.hyprland = mkIf (cfgHypr.enable) {
settings.exec-once = ["polychromatic-tray-applet"];
};
};
}