From 8acab53e3683210f8d8aaf32ab2725794b2c338c Mon Sep 17 00:00:00 2001 From: Filippo Berto Date: Tue, 22 Jun 2021 11:22:21 +0200 Subject: [PATCH] Joystickwake + background --- custom/default.nix | 4 +++- custom/joystickwake/default.nix | 36 ++++++++++++++++++++++++++++ custom/update-background/default.nix | 12 ++++++++++ home.nix | 30 +++++++++++++---------- modules/bspwm.nix | 32 +++++++++++++++++++++++++ modules/direnv.nix | 2 +- modules/joystickwake.nix | 20 ++++++++++++++++ modules/polybar.nix | 18 ++++++++------ modules/sxhkd.nix | 4 ++-- modules/update_background.nix | 12 +--------- 10 files changed, 135 insertions(+), 35 deletions(-) create mode 100644 custom/joystickwake/default.nix create mode 100644 custom/update-background/default.nix create mode 100644 modules/bspwm.nix create mode 100644 modules/joystickwake.nix diff --git a/custom/default.nix b/custom/default.nix index e13383e..896be75 100644 --- a/custom/default.nix +++ b/custom/default.nix @@ -6,7 +6,9 @@ let callPackage = pkgs.lib.callPackageWith (pkgs // self); self = { gallery-tagger = callPackage ./gallery-tagger {}; - lockscreen = callPackage ./lockscreen pkgs.extra.colorPalette // {}; + lockscreen = callPackage ./lockscreen {}; + update-background = callPackage ./update-background {}; + joystickwake = callPackage ./joystickwake {}; }; in (self) diff --git a/custom/joystickwake/default.nix b/custom/joystickwake/default.nix new file mode 100644 index 0000000..514ce4a --- /dev/null +++ b/custom/joystickwake/default.nix @@ -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; + }; + +} diff --git a/custom/update-background/default.nix b/custom/update-background/default.nix new file mode 100644 index 0000000..8ecf888 --- /dev/null +++ b/custom/update-background/default.nix @@ -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" +'' diff --git a/home.nix b/home.nix index caf086b..55b33e0 100644 --- a/home.nix +++ b/home.nix @@ -108,6 +108,7 @@ in xclip zoom-us zotero + ] ++ [ ( pkgs.dwarf-fortress-packages.dwarf-fortress-full.override { @@ -129,6 +130,7 @@ in ./modules/bat.nix ./modules/bottom.nix ./modules/broot.nix + ./modules/bspwm.nix ./modules/dircolors.nix ./modules/direnv.nix ./modules/dunst.nix @@ -138,6 +140,7 @@ in ./modules/gpg.nix ./modules/grobi.nix ./modules/info.nix + ./modules/joystickwake.nix ./modules/jq.nix ./modules/kakoune.nix ./modules/keepassxc.nix @@ -155,28 +158,19 @@ in ./modules/qogir_theme.nix ./modules/rofi.nix ./modules/screen_locker.nix - # ./modules/xidelhook.nix ./modules/ssh.nix ./modules/sxhkd.nix ./modules/syncthing.nix ./modules/terminator.nix ./modules/tmux.nix ./modules/update_background.nix + # ./modules/xidelhook.nix ./modules/zoxide.nix ./modules/zsh.nix + ]; - # Autolock services: xss-lock.service xautolock-session.service - - programs = { - # command-not-found.enable = true; - home-manager.enable = true; - # info.enable = true; - # kakoune = import ./modules/kakoune.nix pkgs; - # zsh = { - # enableVteIntegration = true; - # }; - }; + programs.home-manager.enable = true; services = { blueman-applet.enable = true; @@ -187,5 +181,15 @@ in playerctld.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 + ''; + }; + } diff --git a/modules/bspwm.nix b/modules/bspwm.nix new file mode 100644 index 0000000..d5a634f --- /dev/null +++ b/modules/bspwm.nix @@ -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 = []; + }; +} diff --git a/modules/direnv.nix b/modules/direnv.nix index 7b7ea65..3a8a7cc 100644 --- a/modules/direnv.nix +++ b/modules/direnv.nix @@ -3,6 +3,6 @@ enable = true; enableBashIntegration = true; enableZshIntegration = true; - enableNixDirenvIntegration = true; + nix-direnv.enable = true; }; } diff --git a/modules/joystickwake.nix b/modules/joystickwake.nix new file mode 100644 index 0000000..40e3a73 --- /dev/null +++ b/modules/joystickwake.nix @@ -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; + }; + }; +} diff --git a/modules/polybar.nix b/modules/polybar.nix index 31161f1..b02fee7 100644 --- a/modules/polybar.nix +++ b/modules/polybar.nix @@ -238,7 +238,7 @@ in }; volume = colors.normal // { padding = 1; - text = "VOL "; + text = "VOL "; }; }; label.muted = { @@ -294,18 +294,22 @@ in }; menu = [ [ - ({ text = "Reboot"; exec = "#powermenu.open.1"; }) - ({ text = "Hibernate"; exec = "#powermenu.open.2"; }) - ({ text = "Power off"; exec = "#powermenu.open.3"; }) + ({ text = "Logout"; exec = "#powermenu.open.1"; }) + ({ text = "Reboot"; exec = "#powermenu.open.2"; }) + ({ 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"; }) ] ]; }; diff --git a/modules/sxhkd.nix b/modules/sxhkd.nix index 343fc6c..fa470a0 100644 --- a/modules/sxhkd.nix +++ b/modules/sxhkd.nix @@ -9,10 +9,12 @@ rofi = "${pkgs.rofi}/bin/rofi"; terminator = "${pkgs.terminator}/bin/terminator"; nautilus = "${pkgs.gnome.nautilus}/bin/nautilus"; + update-backgroundCmd = "${pkgs.update-background}"; in { enable = true; 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 + {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}"; @@ -34,10 +36,8 @@ "super + {_,shift + } Return" = "{${alacritty} , ${terminator}}"; "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 + }{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 + 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 + @space" = "rofi -show drun"; "super + {t,shift + t,s,f}" = "${bspc} node -t {tiled,pseudo_tiled,floating,fullscreen}"; diff --git a/modules/update_background.nix b/modules/update_background.nix index fe15dbe..e392660 100644 --- a/modules/update_background.nix +++ b/modules/update_background.nix @@ -5,16 +5,6 @@ let update_time = "10m"; 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" = { Unit = { Description = "Set random desktop background using feh"; @@ -28,7 +18,7 @@ in Service = { Type = "oneshot"; IOSchedulingClass = "idle"; - ExecStart = "${config.home.homeDirectory}/${config.home.file.".local/bin/update_background.sh".target}"; + ExecStart = "${pkgs.update-background}"; }; };