dotfiles

My PC Dotfiles & Website
commit f32fbc0ef2284def6b4c9ca706b6821b546def63
parent e7351b1b8683495e767e4e4490ee60b83680c69e
Author: maydayv7 <maydayv7@gmail.com>
Date:   Fri, 29 Nov 2024 16:23:33 +0530

feat: More Hyprland Refinements

+ Add `dim` shader and activate with timeout
+ Use Pyprland as a service

Diffstat:

Mfiles/hyprland/pypr.toml | 4++--
Mmodules/gui/desktop/hyprland/apps/default.nix | 18++++++++++++++++++
Mmodules/gui/desktop/hyprland/apps/security.nix | 26++++++++++++++++----------
Mmodules/gui/desktop/hyprland/default.nix | 11++++++++++-
Mmodules/gui/desktop/hyprland/settings/plugins.nix | 27++++++++++++++++++++++++---
Dpackages/hyprland-shaders.nix | 30------------------------------
Apackages/hyprshaders/default.nix | 41+++++++++++++++++++++++++++++++++++++++++
Apackages/hyprshaders/dim.frag | 6++++++
8 files changed, 117 insertions(+), 46 deletions(-)

diff --git a/files/hyprland/pypr.toml b/files/hyprland/pypr.toml @@ -40,8 +40,8 @@ use = "right" excludes = ["bluetooth", "network", "volume"] [scratchpads.network] -command = "kitty --class kitty-nm nmtui" -class = "kitty-nm" +command = "sh -c 'env XDG_CURRENT_DESKTOP=GNOME gnome-control-center wifi'" +class = "org.gnome.Settings" use = "right" excludes = ["bluetooth", "displays", "volume"] diff --git a/modules/gui/desktop/hyprland/apps/default.nix b/modules/gui/desktop/hyprland/apps/default.nix @@ -64,6 +64,24 @@ in { wl-screenrec wlr-randr xfce.exo + + # Network Settings + (gnome-control-center.overrideAttrs (old: { + postInstall = + old.postInstall + + '' + dir=$out/share/applications + for panel in $dir/* + do + [ "$panel" = "$dir/gnome-network-panel.desktop" ] && continue + [ "$panel" = "$dir/gnome-wifi-panel.desktop" ] && continue + [ "$panel" = "$dir/gnome-wwan-panel.desktop" ] && continue + [ "$panel" = "$dir/gnome-sharing-panel.desktop" ] && continue + [ "$panel" = "$dir/gnome-wacom-panel.desktop" ] && continue + rm "$panel" + done + ''; + })) ]; user = { diff --git a/modules/gui/desktop/hyprland/apps/security.nix b/modules/gui/desktop/hyprland/apps/security.nix @@ -26,21 +26,21 @@ in { }; # Idle Daemon - services.swayidle = { + services.swayidle = let + lock = pre: post: "sh -c 'if ! ${getExe' pkgs.procps "pgrep"} -x swaylock; then ${pre}; ${getExe locker} -f ${post}; fi'"; + in { enable = true; extraArgs = ["-w"]; systemdTarget = "hyprland-session.target"; - events = let - lock = pre: post: "sh -c 'if ! ${getExe' pkgs.procps "pgrep"} -x swaylock; then ${pre}; ${getExe locker} -f ${post}; fi'"; - in [ + events = [ { event = "before-sleep"; command = lock "" ""; } { event = "lock"; - command = lock "${getExe pkgs.playerctl} pause -a" "--grace 15 --grace-no-mouse"; + command = lock "${getExe pkgs.playerctl} pause -a" "--fade-in 0.2 --grace 15 --grace-no-mouse"; } ]; @@ -49,16 +49,22 @@ in { ${getExe' pkgs.pipewire "pw-cli"} info all | ${getExe pkgs.gnugrep} running if [ $? == 1 ]; then ${command}; fi ''}"; # Check if audio is playing - hyprctl = getExe' sys.programs.hyprland.package "hyprctl"; + shader = getExe pkgs.hyprshade; + dpms = "${getExe' sys.programs.hyprland.package "hyprctl"} dispatch dpms"; in [ { + timeout = 240; # Dim display + command = audio "${shader} on dim"; + resumeCommand = "${shader} off"; + } + { timeout = 300; # Turn off display - command = audio "${hyprctl} dispatch dpms off"; - resumeCommand = "${hyprctl} dispatch dpms on"; + command = audio "${dpms} off"; + resumeCommand = "${dpms} on"; } { - timeout = 600; # Suspend then Hibernate device - command = audio "${hyprctl} dispatch dpms on && ${getExe' pkgs.systemd "systemctl"} suspend-then-hibernate"; + timeout = 500; # Suspend then Hibernate device + command = audio "${dpms} on && ${lock "" ""} && ${getExe' pkgs.systemd "systemctl"} suspend-then-hibernate "; } ]; }; diff --git a/modules/gui/desktop/hyprland/default.nix b/modules/gui/desktop/hyprland/default.nix @@ -24,6 +24,7 @@ in { }; # Session + services.displayManager.defaultSession = "Desktop"; services.xserver.displayManager.session = [ { name = "Desktop"; @@ -124,8 +125,16 @@ in { # Security security.pam.services = { - greetd.enableGnomeKeyring = true; swaylock.text = "auth include login"; + greetd = { + enableGnomeKeyring = true; + text = '' + auth substack login + account include login + password substack login + session include login + ''; + }; }; } diff --git a/modules/gui/desktop/hyprland/settings/plugins.nix b/modules/gui/desktop/hyprland/settings/plugins.nix @@ -1,18 +1,18 @@ { sys, config, + lib, pkgs, files, ... }: { ## Plugin Settings - # Pyprland home = { packages = with pkgs; [hyprshade pyprland]; file = { ".config/hypr/pyprland.toml".text = files.hyprland.pypr; ".config/hypr/shaders" = { - source = "${pkgs.custom.hyprland-shaders}/share/hypr/shaders"; + source = "${pkgs.custom.hyprshaders}/share/hypr/shaders"; recursive = true; }; }; @@ -21,7 +21,6 @@ wayland.windowManager.hyprland = { plugins = with pkgs.hyprworld; [hycov hyprexpo Hypr-DarkWindow Hyprspace hyprsplit]; settings = { - exec-once = ["pypr"]; plugin = with sys.lib.stylix.colors; let gaps = builtins.toString @@ -95,4 +94,26 @@ ]; }; }; + + # Pyprland + systemd.user.services.pyprland = { + Install.WantedBy = ["graphical-session.target"]; + Unit = { + Description = "Hyprland Goodies"; + PartOf = ["graphical-session.target"]; + }; + + Service = let + pypr = lib.getExe pkgs.pyprland; + in { + Restart = "on-failure"; + ExecStop = "${pypr} exit"; + ExecStart = pkgs.writeShellScript "pypr-wrapper.sh" '' + ${files.path.systemd} + ${pypr} exit || true + rm "$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.pyprland.sock" || true + ${pypr} + ''; + }; + }; } diff --git a/packages/hyprland-shaders.nix b/packages/hyprland-shaders.nix @@ -1,30 +0,0 @@ -{ - lib, - pkgs, - ... -}: -with pkgs; - stdenv.mkDerivation { - pname = "hyprland-shaders"; - version = "v1"; - - src = fetchFromGitHub { - owner = "hyprland-community"; - repo = "awesome-hyprland"; - rev = "9978013d307fd205c6d61296bda3dfdb7e8282f1"; - sha256 = "sha256-giMv5+1WfEFc5jfwPSNxu6V+puWOyTfVpNVrd2aQvKE="; - }; - - dontBuild = true; - installPhase = '' - mkdir -p $out/share/hypr/shaders/ - find . -name \*.frag -exec cp {} $out/share/hypr/shaders/ \; - ''; - - meta = with lib; { - description = "Shaders for Hyprland"; - homepage = "https://github.com/hyprland-community/awesome-hyprland"; - license = licenses.cc0; - maintainers = ["maydayv7"]; - }; - } diff --git a/packages/hyprshaders/default.nix b/packages/hyprshaders/default.nix @@ -0,0 +1,41 @@ +{ + lib, + pkgs, + ... +}: +with pkgs; + stdenv.mkDerivation { + pname = "hyprshaders"; + version = "v2"; + + srcs = [ + ./dim.frag + (fetchFromGitHub { + owner = "hyprland-community"; + repo = "awesome-hyprland"; + rev = "9978013d307fd205c6d61296bda3dfdb7e8282f1"; + sha256 = "sha256-giMv5+1WfEFc5jfwPSNxu6V+puWOyTfVpNVrd2aQvKE="; + }) + ]; + + dontBuild = true; + unpackPhase = '' + for src in $srcs + do + cp -r $src $(stripHash $src) + done + ''; + + installPhase = '' + mkdir -p $out/share/hypr/shaders/ + find . -name '*.frag' ! -name 'blue*' ! -name 'vibrance*' \ + -exec cp {} $out/share/hypr/shaders/ \; + ''; + + meta = with lib; { + description = "Shaders for Hyprland"; + homepage = "https://github.com/hyprland-community/awesome-hyprland"; + license = licenses.cc0; + maintainers = ["maydayv7"]; + }; + } diff --git a/packages/hyprshaders/dim.frag b/packages/hyprshaders/dim.frag @@ -0,0 +1,6 @@ +precision highp float; +varying vec2 v_texcoord; +uniform sampler2D tex; +void main() { + gl_FragColor = texture2D(tex, v_texcoord) * 0.3; +}