Joystickwake + background

This commit is contained in:
Filippo Berto 2021-06-22 11:22:21 +02:00
parent e080d5b9b8
commit 8acab53e36
10 changed files with 135 additions and 35 deletions

View file

@ -6,7 +6,9 @@ let
callPackage = pkgs.lib.callPackageWith (pkgs // self); callPackage = pkgs.lib.callPackageWith (pkgs // self);
self = { self = {
gallery-tagger = callPackage ./gallery-tagger {}; gallery-tagger = callPackage ./gallery-tagger {};
lockscreen = callPackage ./lockscreen pkgs.extra.colorPalette // {}; lockscreen = callPackage ./lockscreen {};
update-background = callPackage ./update-background {};
joystickwake = callPackage ./joystickwake {};
}; };
in in
(self) (self)

View file

@ -0,0 +1,36 @@
{ lib, python3, fetchFromGitHub }:
python3.pkgs.buildPythonApplication rec {
pname = "joystickwake";
version = "0.2.4";
src = fetchFromGitHub {
owner = "foresto";
repo = pname;
rev = "v${version}";
sha256 = "0j8xwfmzzmc9s88zvzc3lv67821r6x28vy6vli3srvx859wprppd";
};
buildInputs = with python3.pkgs; [
pyudev
xlib
];
propagatedBuildInputs = with python3.pkgs; [
pyudev
xlib
];
doCheck = false;
meta = with lib; {
description = "A joystick-aware screen waker";
longDescription = ''
Linux gamers often find themselves unexpectedly staring at a blank screen, because their display server fails to recognize game controllers as input devices, allowing the screen blanker to activate during gameplay.
This program works around the problem by temporarily disabling screen blankers when joystick activity is detected.
'';
homepage = "https://github.com/foresto/joystickwake";
license = licenses.mit;
platforms = platforms.linux;
};
}

View file

@ -0,0 +1,12 @@
{ lib, stdenv, feh, findutils, gnugrep, coreutils, writeScript, backgrounds_directory ? "$HOME/Immagini/Sfondi" }:
let
find = "${findutils}/bin/find";
grep = "${gnugrep}/bin/grep";
shuf = "${coreutils}/bin/shuf";
in
writeScript "update-background.sh" ''
#!/bin/sh
image=`${find} ${backgrounds_directory} -type f | ${grep} -v "/\." | ${shuf} -n 1`
echo "image: $image"
${feh}/bin/feh --bg-fill --no-fehbg "$image"
''

View file

@ -108,6 +108,7 @@ in
xclip xclip
zoom-us zoom-us
zotero zotero
] ++ [ ] ++ [
( (
pkgs.dwarf-fortress-packages.dwarf-fortress-full.override { pkgs.dwarf-fortress-packages.dwarf-fortress-full.override {
@ -129,6 +130,7 @@ in
./modules/bat.nix ./modules/bat.nix
./modules/bottom.nix ./modules/bottom.nix
./modules/broot.nix ./modules/broot.nix
./modules/bspwm.nix
./modules/dircolors.nix ./modules/dircolors.nix
./modules/direnv.nix ./modules/direnv.nix
./modules/dunst.nix ./modules/dunst.nix
@ -138,6 +140,7 @@ in
./modules/gpg.nix ./modules/gpg.nix
./modules/grobi.nix ./modules/grobi.nix
./modules/info.nix ./modules/info.nix
./modules/joystickwake.nix
./modules/jq.nix ./modules/jq.nix
./modules/kakoune.nix ./modules/kakoune.nix
./modules/keepassxc.nix ./modules/keepassxc.nix
@ -155,28 +158,19 @@ in
./modules/qogir_theme.nix ./modules/qogir_theme.nix
./modules/rofi.nix ./modules/rofi.nix
./modules/screen_locker.nix ./modules/screen_locker.nix
# ./modules/xidelhook.nix
./modules/ssh.nix ./modules/ssh.nix
./modules/sxhkd.nix ./modules/sxhkd.nix
./modules/syncthing.nix ./modules/syncthing.nix
./modules/terminator.nix ./modules/terminator.nix
./modules/tmux.nix ./modules/tmux.nix
./modules/update_background.nix ./modules/update_background.nix
# ./modules/xidelhook.nix
./modules/zoxide.nix ./modules/zoxide.nix
./modules/zsh.nix ./modules/zsh.nix
]; ];
# Autolock services: xss-lock.service xautolock-session.service programs.home-manager.enable = true;
programs = {
# command-not-found.enable = true;
home-manager.enable = true;
# info.enable = true;
# kakoune = import ./modules/kakoune.nix pkgs;
# zsh = {
# enableVteIntegration = true;
# };
};
services = { services = {
blueman-applet.enable = true; blueman-applet.enable = true;
@ -187,5 +181,15 @@ in
playerctld.enable = true; playerctld.enable = true;
# poweralertd.enable = true; # poweralertd.enable = true;
}; };
xsession.numlock.enable = true;
xsession = {
enable = true;
numlock.enable = true;
initExtra = ''
## Touchpad
${pkgs.xorg.xinput}/bin/xinput set-prop 'DELL0824:00 06CB:7E92 Touchpad' 'libinput Natural Scrolling Enabled' 1
${pkgs.xorg.xinput}/bin/xinput set-prop 'DELL0824:00 06CB:7E92 Touchpad' 'libinput Tapping Enabled' 1
'';
};
} }

32
modules/bspwm.nix Normal file
View file

@ -0,0 +1,32 @@
{ pkgs, ... }:
let
monitorPages = [ "I" "II" "III" "IV" "V" "VI" "VII" "VIII" "IX" "X" ];
strPalette = pkgs.extra.palette.toRGBHex pkgs.extra.colorPalette;
in
{
xsession.windowManager.bspwm = {
enable = true;
settings = {
border_width = 2;
border_radius = 8;
window_gap = 4;
split_ratio = 0.5;
top_padding = 0;
borderless_monocle = true;
gapless_monocle = false;
normal_border_color = strPalette.normal.blue;
focused_border_color = strPalette.bright.blue;
};
monitors = {
"eDP1-1" = monitorPages;
"eDP1" = monitorPages;
"HDMI-0" = monitorPages;
};
extraConfig = ''
sleep 2
polybar-msg cmd restart
'';
startupPrograms = [];
};
}

View file

@ -3,6 +3,6 @@
enable = true; enable = true;
enableBashIntegration = true; enableBashIntegration = true;
enableZshIntegration = true; enableZshIntegration = true;
enableNixDirenvIntegration = true; nix-direnv.enable = true;
}; };
} }

20
modules/joystickwake.nix Normal file
View file

@ -0,0 +1,20 @@
{ pkgs, config, ... }:
let
joystickwakeCmd = "${pkgs.joystickwake}/bin/joystickwake";
in
{
systemd.user.services."joystickwake" = {
Unit = {
Description = "Keep lockscreen from activating";
After = [ "graphical-session.pre.target" ];
PartOf = [ "graphical-session.target" ];
};
Install = {
WantedBy = [ "graphical-session.target" ];
};
Service = {
Type = "simple";
ExecStart = joystickwakeCmd;
};
};
}

View file

@ -238,7 +238,7 @@ in
}; };
volume = colors.normal // { volume = colors.normal // {
padding = 1; padding = 1;
text = "VOL <bar-volume> <label-volume> <ramp-volume>"; text = "VOL <label-volume> <ramp-volume>";
}; };
}; };
label.muted = { label.muted = {
@ -294,18 +294,22 @@ in
}; };
menu = [ menu = [
[ [
({ text = "Reboot"; exec = "#powermenu.open.1"; }) ({ text = "Logout"; exec = "#powermenu.open.1"; })
({ text = "Hibernate"; exec = "#powermenu.open.2"; }) ({ text = "Reboot"; exec = "#powermenu.open.2"; })
({ text = "Power off"; exec = "#powermenu.open.3"; }) ({ text = "Hibernate"; exec = "#powermenu.open.3"; })
({ text = "Power off"; exec = "#powermenu.open.4"; })
] ]
[ [
({ text = "Reboot"; exec = "reboot"; }) ({ text = "Logout"; exec = "${pkgs.systemd}/bin/loginctl terminate-session self"; })
] ]
[ [
({ text = "Hibernate"; exec = "systemctl hibernate"; }) ({ text = "Reboot"; exec = "${pkgs.systemd}/bin/systemctl reboot"; })
] ]
[ [
({ text = "Power off"; exec = "shutdown now"; }) ({ text = "Hibernate"; exec = "${pkgs.systemd}/bin/systemctl hibernate"; })
]
[
({ text = "Power off"; exec = "${pkgs.systemd}/bin/shutdown now"; })
] ]
]; ];
}; };

View file

@ -9,10 +9,12 @@
rofi = "${pkgs.rofi}/bin/rofi"; rofi = "${pkgs.rofi}/bin/rofi";
terminator = "${pkgs.terminator}/bin/terminator"; terminator = "${pkgs.terminator}/bin/terminator";
nautilus = "${pkgs.gnome.nautilus}/bin/nautilus"; nautilus = "${pkgs.gnome.nautilus}/bin/nautilus";
update-backgroundCmd = "${pkgs.update-background}";
in in
{ {
enable = true; enable = true;
keybindings = { keybindings = {
"super + b" = update-backgroundCmd;
"super + alt + {h,j,k,l}" = "${bspc} node -z {left -20 0,bottom 0 20,top 0 -20,right 20 0}"; "super + alt + {h,j,k,l}" = "${bspc} node -z {left -20 0,bottom 0 20,top 0 -20,right 20 0}";
"super + alt + {q,r}" = "${bspc} {quit,wm -r}"; "super + alt + {q,r}" = "${bspc} {quit,wm -r}";
"super + alt + shift + {h,j,k,l}" = "${bspc} node -z {right -20 0,top 0 20,bottom 0 -20,left 20 0}"; "super + alt + shift + {h,j,k,l}" = "${bspc} node -z {right -20 0,top 0 20,bottom 0 -20,left 20 0}";
@ -34,10 +36,8 @@
"super + {_,shift + } Return" = "{${alacritty} , ${terminator}}"; "super + {_,shift + } Return" = "{${alacritty} , ${terminator}}";
"super + {_,shift + }{1-9,0}" = "${bspc} {desktop -f,node -d} 'focused:^{1-9,10}'"; "super + {_,shift + }{1-9,0}" = "${bspc} {desktop -f,node -d} 'focused:^{1-9,10}'";
"super + {_,shift + }c" = "${bspc} node -f {next,prev}.local"; "super + {_,shift + }c" = "${bspc} node -f {next,prev}.local";
# "super + {_,shift + }{h,j,k,l}" = "${bspc} node -{f,s} {west,south,north,east}";
"super + {h,j,k,l}" = "${bspc} node -f {west,south,north,east}"; "super + {h,j,k,l}" = "${bspc} node -f {west,south,north,east}";
"super + shift + {h,j,k,l}" = ''dir={west,south,north,east}; bspc node -s "$dir.local" --follow || bspc node -m "$dir" --follow''; "super + shift + {h,j,k,l}" = ''dir={west,south,north,east}; bspc node -s "$dir.local" --follow || bspc node -m "$dir" --follow'';
"super + {_,shift + }w" = "${bspc} node -{c,k}"; "super + {_,shift + }w" = "${bspc} node -{c,k}";
"super + @space" = "rofi -show drun"; "super + @space" = "rofi -show drun";
"super + {t,shift + t,s,f}" = "${bspc} node -t {tiled,pseudo_tiled,floating,fullscreen}"; "super + {t,shift + t,s,f}" = "${bspc} node -t {tiled,pseudo_tiled,floating,fullscreen}";

View file

@ -5,16 +5,6 @@ let
update_time = "10m"; update_time = "10m";
in in
{ {
home.file.".local/bin/update_background.sh" = {
text = ''
#!${pkgs.bash}/bin/bash
image=`find ${backgrounds_directory} -type f | grep -v "/\." | shuf -n 1`
${fehCmd} --bg-fill --no-fehbg "$image"
'';
target = ".local/bin/update_background.sh";
executable = true;
};
systemd.user.services."update-background" = { systemd.user.services."update-background" = {
Unit = { Unit = {
Description = "Set random desktop background using feh"; Description = "Set random desktop background using feh";
@ -28,7 +18,7 @@ in
Service = { Service = {
Type = "oneshot"; Type = "oneshot";
IOSchedulingClass = "idle"; IOSchedulingClass = "idle";
ExecStart = "${config.home.homeDirectory}/${config.home.file.".local/bin/update_background.sh".target}"; ExecStart = "${pkgs.update-background}";
}; };
}; };