From 26ff5436291b54a89d9a7781828eae5ea8beb5f4 Mon Sep 17 00:00:00 2001 From: Tigor Hutasuhut Date: Wed, 16 Oct 2024 09:54:46 +0700 Subject: [PATCH] hyprland: moved from grimblast to hyprshot and sway-notification-center --- home/modules/default.nix | 1 - home/modules/hyprland/default.nix | 7 ++-- home/modules/hyprland/dunst.nix | 3 ++ home/modules/hyprland/hyprland.nix | 9 ------ home/modules/hyprland/hyprshot.nix | 32 +++++++++++++++++++ .../hyprland/sway-notification-center.nix | 16 ++++++++++ home/modules/hyprland/swayosd.nix | 20 ++++++++++++ 7 files changed, 76 insertions(+), 12 deletions(-) create mode 100644 home/modules/hyprland/hyprshot.nix create mode 100644 home/modules/hyprland/sway-notification-center.nix create mode 100644 home/modules/hyprland/swayosd.nix diff --git a/home/modules/default.nix b/home/modules/default.nix index 0c064b2..0ecf3b6 100644 --- a/home/modules/default.nix +++ b/home/modules/default.nix @@ -2,7 +2,6 @@ { imports = [ ./gnome - ./sway ./hyprland ./syncthing.nix ./obs.nix diff --git a/home/modules/hyprland/default.nix b/home/modules/hyprland/default.nix index 047927e..db6a97a 100644 --- a/home/modules/hyprland/default.nix +++ b/home/modules/hyprland/default.nix @@ -4,10 +4,11 @@ let in { imports = [ - ./dunst.nix + # ./dunst.nix ./hypridle.nix ./hyprland.nix ./hyprlock.nix + ./hyprshot.nix # hyprpaper seems to be broken with out of memory and failure to swap wallpapers correctly. # Use swww for now until the application is stable. # ./hyprpaper.nix @@ -16,8 +17,10 @@ in ./wallust.nix ./waybar.nix ./wlogout.nix - ./swappy.nix + # ./swappy.nix ./alacritty.nix + ./swayosd.nix + ./sway-notification-center.nix ]; config = lib.mkIf cfg.enable { home.packages = with pkgs; [ diff --git a/home/modules/hyprland/dunst.nix b/home/modules/hyprland/dunst.nix index dfdce4e..dc5cdd3 100644 --- a/home/modules/hyprland/dunst.nix +++ b/home/modules/hyprland/dunst.nix @@ -8,6 +8,9 @@ in home.packages = [ pkgs.dunst ]; + wayland.windowManager.hyprland.settings.exec-once = [ + "dunst" + ]; home.file.".config/dunst/dunstrc".text = generators.toINI { } { global = { # Which monitor should the notifications be displayed on. diff --git a/home/modules/hyprland/hyprland.nix b/home/modules/hyprland/hyprland.nix index 3609afd..91bf1d3 100644 --- a/home/modules/hyprland/hyprland.nix +++ b/home/modules/hyprland/hyprland.nix @@ -22,7 +22,6 @@ in profile.home.programs.foot.enable = lib.mkForce true; home.packages = [ - inputs.hyprland-contrib.packages.${pkgs.system}.grimblast pkgs.wl-clipboard pkgs.kcalc ]; @@ -138,11 +137,6 @@ in # Language Input "$mod, I, exec, fcitx5-remote -t" - "$mod, PRINT, exec, grimblast --notify copysave output" - "$mod SHIFT, PRINT, exec, grimblast --notify save output - | swappy -f -" - ", PRINT, exec, grimblast --notify copysave area" - "SHIFT, PRINT, exec, grimblast --notify save area - | swappy -f -" - "ALT, PRINT, exec, grimblast --wait 1 --notify save area - | swappy -f -" ]; binde = [ @@ -236,15 +230,12 @@ in exec-once=${init-wallpaper.path} ${./wallpaper.jpeg} exec-once=wallust run ${config.home.homeDirectory}/.cache/wallpaper/current - exec-once=swayosd-libinput-backend - exec-once=swayosd-server exec-once=swww-daemon exec-once=bash -c "sleep 10; hypridle" exec-once=waybar exec-once=nm-applet exec-once=pasystray exec-once=pypr - exec-once=dunst source=${config.home.homeDirectory}/.cache/wallust/hyprland.conf exec-once=sleep 0.2 && swww img ${config.home.homeDirectory}/.cache/wallpaper/current diff --git a/home/modules/hyprland/hyprshot.nix b/home/modules/hyprland/hyprshot.nix new file mode 100644 index 0000000..93a7b26 --- /dev/null +++ b/home/modules/hyprland/hyprshot.nix @@ -0,0 +1,32 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.profile.hyprland; + saveDir = "${config.home.homeDirectory}/Pictures/screenshots"; +in +{ + config = lib.mkIf cfg.enable { + home.packages = with pkgs; [ + hyprshot + satty + ]; + + home.activation.sattyDirCreate = lib.hm.dag.entryAfter [ "writeBoundary" ] /*sh*/ '' + mkdir -p "${saveDir}" + chown ${config.home.username} "${saveDir}" + ''; + + wayland.windowManager.hyprland.settings.bind = + let + saveFilename = "${saveDir}/$(date +%Y-%m-%d_%H%M%S).png"; + sattySaveCommand = ''satty --save-after-copy --filename - --fullscreen --output-filename ${saveFilename}''; + in + [ + "$mod, PRINT, exec, hyprshot -m window --filename ${saveFilename}" + "$mod SHIFT, PRINT, exec, hyprshot -m window --raw | ${sattySaveCommand}" + ", PRINT, exec, hyprshot -m region --filename ${saveFilename}" + "SHIFT, PRINT, exec, hyprshot -m region --raw | ${sattySaveCommand}" + "ALT, PRINT, exec, hyprshot -m output --filename ${saveFilename}" + "ALT SHIFT, PRINT, exec, hyprshot -m output --raw | ${sattySaveCommand}" + ]; + }; +} diff --git a/home/modules/hyprland/sway-notification-center.nix b/home/modules/hyprland/sway-notification-center.nix new file mode 100644 index 0000000..22b6fb5 --- /dev/null +++ b/home/modules/hyprland/sway-notification-center.nix @@ -0,0 +1,16 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.profile.hyprland; +in +{ + config = lib.mkIf cfg.enable { + home.packages = with pkgs; [ + swaynotificationcenter + libnotify + ]; + + wayland.windowManager.hyprland.settings.exec-once = [ + "swaync" + ]; + }; +} diff --git a/home/modules/hyprland/swayosd.nix b/home/modules/hyprland/swayosd.nix new file mode 100644 index 0000000..576a9e2 --- /dev/null +++ b/home/modules/hyprland/swayosd.nix @@ -0,0 +1,20 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.profile.hyprland; +in +{ + config = lib.mkIf cfg.enable { + # services.swayosd = { + # enable = true; + # display = config.profile.hyprland.swayosd.display; + # }; + home.packages = with pkgs; [ + swayosd + ]; + + wayland.windowManager.hyprland.settings.exec-once = [ + "swayosd-libinput-backend" + "swayosd-server" + ]; + }; +}