diff --git a/host/Eclipse/modules/hyprland.nix b/host/Eclipse/modules/hyprland.nix new file mode 100644 index 0000000..b67c99a --- /dev/null +++ b/host/Eclipse/modules/hyprland.nix @@ -0,0 +1,27 @@ +{ pkgs, lib, ... }: { + wayland.windowManager.hyprland = let + wallpaper = pkgs.fetchurl { + name = "miku_wallpaper.jpg"; + url = "https://c.codrs.ru/pub/miku_wallpaper.jpeg?raw"; + hash = "sha256-inK4X5KzQk5FHwDw2DYy43nm7XtXlC6I0S1PkYUv+3w="; + }; + in { + settings = { + monitor = [ + "DP-3 , 1920x1080@165, 0x0 , 1" + "HDMI-A-1, preferred , -1080x0, 1, transform, 1" + ]; + + workspace = [ + "1, monitor:DP-3, default:true" + "10, monitor:HDMI-A-1, default:true" + ]; + + exec-once = [ + "hyprctl dispatch workspace 1" + "${lib.getExe pkgs.swww} img -o HDMI-A-1 ${wallpaper}" + "${lib.getExe pkgs.linux-wallpaperengine} ~/.local/share/wpe/wallpaper --assets-dir ~/.local/share/wpe/assets --screen-root DP-3 --noautomute" + ]; + }; + }; +} \ No newline at end of file diff --git a/host/Rias/modules/hyprland.nix b/host/Rias/modules/hyprland.nix new file mode 100644 index 0000000..0f272b7 --- /dev/null +++ b/host/Rias/modules/hyprland.nix @@ -0,0 +1,44 @@ +{ pkgs, lib, ...}: { + wayland.windowManager.hyprland = let + monitor-switcher = pkgs.writers.writeBashBin "monitor_switcher" /*bash*/ '' + MODE=$1 + + case $MODE in + "tv") + hyprctl keyword monitor "DP-3, 1920x1080@60, 3840x0, 1" + hyprctl keyword monitor "HDMI-A-1, 3840x2160@60, 0x0, 1" + notify-send "TV mode" + ;; + + "mirror") + hyprctl keyword monitor "HDMI-A-1, 3840x2160@60, 0x0, 1" + hyprctl keyword monitor "DP-3, preferred, auto, 1, mirror, HDMI-A-1" + notify-send "TV-only mode" + ;; + + "display"|*) + hyprctl keyword monitor "HDMI-A-1, disable" + hyprctl keyword monitor "DP-3, 3440x1440@165, 0x0, 1" + notify-send "Display mode" + ;; + + esac + ''; + in { + settings = { + monitor = [ + "DP-3, 3440x1440@165, auto-right, 1" + # "HDMI-A-1, 3840x2160@60, auto-left, 2" + "HDMI-A-1, disabled" + ]; + + bind = [ + '', XF86Calculator, exec, ghostty --title=pulsemixer -e pulsemixer'' + + ''$mainMod, F1, exec, ${lib.getExe monitor-switcher} tv'' + ''$mainMod, F2, exec, ${lib.getExe monitor-switcher} mirror'' + ''$mainMod, F3, exec, ${lib.getExe monitor-switcher}'' + ]; + }; + }; +} \ No newline at end of file diff --git a/host/Senko/modules/hyprland.nix b/host/Senko/modules/hyprland.nix new file mode 100644 index 0000000..a74ec69 --- /dev/null +++ b/host/Senko/modules/hyprland.nix @@ -0,0 +1,9 @@ +{ + wayland.windowManager.hyprland = { + settings = { + monitor = [ + "eDP-1, 1920x1080@60, 0x0, 1" + ]; + }; + }; +} \ No newline at end of file diff --git a/modules/user.nix b/modules/user.nix index 3c7e6e1..fed3de7 100644 --- a/modules/user.nix +++ b/modules/user.nix @@ -12,6 +12,7 @@ ./user/wofi.nix ./user/mako.nix ./user/ghostty.nix + ./user/hyprland.nix ./user/packages/art.nix ./user/packages/desktop.nix ./user/packages/coding.nix diff --git a/modules/user/patterns/hyprland.nix b/modules/user/hyprland.nix similarity index 75% rename from modules/user/patterns/hyprland.nix rename to modules/user/hyprland.nix index 45d163c..5b85845 100644 --- a/modules/user/patterns/hyprland.nix +++ b/modules/user/hyprland.nix @@ -1,4 +1,11 @@ -{ pkgs, lib, config, collection, swww_flags, inputs }: { +{ pkgs, lib, config, osConfig, inputs, username, ... }: let + optImport = path: lib.optional (builtins.pathExists path) path; + hostname = osConfig.networking.hostName; +in { + imports = + optImport ../../host/${hostname}/modules/hyprland.nix ++ + optImport ../../user/${username}/modules/hyprland.nix; + home.packages = with pkgs; [ ghostty pamixer @@ -9,60 +16,12 @@ xclip ]; - wayland.windowManager.hyprland = - let + wayland.windowManager.hyprland = let colors = config.lib.stylix.colors; - - wallpaper_changer = pkgs.writers.writePython3Bin "wallpaper_changer" { - libraries = [ pkgs.python3Packages.requests ]; - flakeIgnore = [ "E501" "E111" "E701" "E241" "E731" ]; - } /*py*/ '' - import requests as requests - from random import choice - from os import system, mkdir, listdir - from os.path import exists - - notify = lambda s: system(f"notify-desktop Wallpaper '{s}'") - folder = "${config.home.homeDirectory}/Wallpapers" - url = "https://wallhaven.cc/api/v1/collections/${collection}" - with open("${config.sops.secrets."tokens/apis/wallhaven".path}") as f: - token = f.read() - - notify("Updating wallpaper!") - - try: - json = requests.get(url, params={'apikey': token}).json() - - wallpaper = choice(json['data']) - link = wallpaper['path'] - format = wallpaper['file_type'] - id = wallpaper['id'] - - if format == "image/jpeg": ext = "jpg" - else: ext = "png" - - filename = f"{id}.{ext}" - - if not exists(f"{folder}/{filename}"): - if not exists(folder): - mkdir(f"{folder}") - - notify("Downloading...") - with open(f"{folder}/{filename}", 'wb') as f: - r = requests.get(link) - f.write(r.content) - - except requests.exceptions.ConnectionError: - notify("Offline mode") - filename = choice(listdir(folder)) - - finally: - system(f"${lib.getExe pkgs.swww} img {folder}/{filename} ${swww_flags}") - ''; in { enable = true; xwayland.enable = true; - + package = inputs.hyprland.packages.${pkgs.system}.hyprland; plugins = with inputs.hyprland-plugins.packages.${pkgs.system}; [ # hyprbars # Version mismatch @@ -136,10 +95,9 @@ "size 622 652, title:(clipse)" ]; - exec-once = [ + exec-once = lib.mkBefore [ "systemctl --user start plasma-polkit-agent" "${lib.getExe' pkgs.swww "swww-daemon"}" - "${lib.getExe wallpaper_changer}" "wl-clip-persist --clipboard both" "clipse -listen" "${lib.getExe' pkgs.udiskie "udiskie"}" @@ -213,22 +171,14 @@ ", XF86AudioMute, exec, pamixer -t" ", XF86AudioMicMute, exec, pamixer --default-source -m" ", XF86AudioPlay, exec, ${lib.getExe pkgs.playerctl} play-pause" - ", XF86AudioPrev, exec, ${lib.getExe pkgs.playerctl} position 5-" - ", XF86AudioNext, exec, ${lib.getExe pkgs.playerctl} position 5+" ", XF86Explorer, exec, ghostty -e sh -c yazi" ", XF86Mail, exec, thunderbird" ", XF86WWW, exec, google-chrome-stable" # TODO: Replace hard-code to some variable - + # Brightness control ", XF86MonBrightnessDown, exec, ${lib.getExe pkgs.brightnessctl} set 5%- " ", XF86MonBrightnessUp, exec, ${lib.getExe pkgs.brightnessctl} set +5% " - - # Waybar - "$mainMod, B, exec, pkill -SIGUSR1 waybar" - #"$mainMod, W, exec, pkill -SIGUSR2 waybar" - - "$mainMod, W, exec, ${lib.getExe wallpaper_changer}" ]; binde = [ @@ -236,6 +186,11 @@ ", XF86AudioLowerVolume, exec, pamixer -d 5 " ]; + bindc = [ + ", XF86AudioPrev, exec, ${lib.getExe pkgs.playerctl} position 5-" + ", XF86AudioNext, exec, ${lib.getExe pkgs.playerctl} position 5+" + ]; + bindo = [ ", XF86AudioPrev, exec, ${lib.getExe pkgs.playerctl} previous" ", XF86AudioNext, exec, ${lib.getExe pkgs.playerctl} next" diff --git a/user/chest/modules/hyprland.nix b/user/chest/modules/hyprland.nix index de551d5..69a611e 100644 --- a/user/chest/modules/hyprland.nix +++ b/user/chest/modules/hyprland.nix @@ -1,21 +1,8 @@ { pkgs, lib, config, inputs, ... }: { - imports = [( - import ../../../modules/user/patterns/hyprland.nix { - inherit lib; - inherit pkgs; - inherit config; - inherit inputs; - collection = "cheeeest/1767552"; - swww_flags = ""; - } - )]; - wayland.windowManager.hyprland = let colors = config.lib.stylix.colors; in { settings = { - monitor = ",preferred,auto,1"; - exec-once =["${lib.getExe pkgs.linux-wallpaperengine} ~/.local/share/wpe/wallpaper --assets-dir ~/.local/share/wpe/assets --screen-root DP-3 --noautomute"]; general = { gaps_in = 5; gaps_out = 5; diff --git a/user/common.nix b/user/common.nix index f2698b4..0b5ed09 100644 --- a/user/common.nix +++ b/user/common.nix @@ -13,7 +13,6 @@ inputs.stylix.homeModules.stylix ../modules/user.nix ./${name}/modules/git.nix - ./${name}/modules/hyprland.nix ./${name}/modules/style.nix ./${name}/home.nix ]; @@ -35,6 +34,7 @@ laptop = laptop; name = config.networking.hostName; }; + username = name; }; }; } diff --git a/user/sweetbread/modules/hyprland.nix b/user/sweetbread/modules/hyprland.nix index 4ccb83e..e44dc07 100644 --- a/user/sweetbread/modules/hyprland.nix +++ b/user/sweetbread/modules/hyprland.nix @@ -1,26 +1,55 @@ { pkgs, lib, config, inputs, ... }: { - imports = [( - import ../../../modules/user/patterns/hyprland.nix { - inherit lib; - inherit pkgs; - inherit config; - inherit inputs; - collection = "sweetbread/1764377"; - swww_flags = "--transition-type center"; - } - )]; - wayland.windowManager.hyprland = let colors = config.lib.stylix.colors; + + wallpaper_changer = pkgs.writers.writePython3Bin "wallpaper_changer" { + libraries = [ pkgs.python3Packages.requests ]; + flakeIgnore = [ "E501" "E111" "E701" "E241" "E731" ]; + } /*py*/ '' + import requests as requests + from random import choice + from os import system, mkdir, listdir + from os.path import exists + + notify = lambda s: system(f"notify-desktop Wallpaper '{s}'") + folder = "${config.home.homeDirectory}/Wallpapers" + url = "https://wallhaven.cc/api/v1/collections/sweetbread/1764377" + with open("${config.sops.secrets."tokens/apis/wallhaven".path}") as f: + token = f.read() + + notify("Updating wallpaper!") + + try: + json = requests.get(url, params={'apikey': token}).json() + + wallpaper = choice(json['data']) + link = wallpaper['path'] + format = wallpaper['file_type'] + id = wallpaper['id'] + + if format == "image/jpeg": ext = "jpg" + else: ext = "png" + + filename = f"{id}.{ext}" + + if not exists(f"{folder}/{filename}"): + if not exists(folder): + mkdir(f"{folder}") + + notify("Downloading...") + with open(f"{folder}/{filename}", 'wb') as f: + r = requests.get(link) + f.write(r.content) + + except requests.exceptions.ConnectionError: + notify("Offline mode") + filename = choice(listdir(folder)) + + finally: + system(f"${lib.getExe pkgs.swww} img {folder}/{filename} --transition-type center") + ''; in { settings = { - monitor = [ - "DP-3, 3440x1440@165.00Hz, auto-right, 1" - # "HDMI-A-1, 3840x2160@60.00Hz, auto-left, 2" - "HDMI-A-1, disabled" - ",preferred,auto,1" - ]; - general = { gaps_in = 5; gaps_out = 10; @@ -76,12 +105,16 @@ enable_swallow = true; }; + exec-once = [ + "${lib.getExe wallpaper_changer}" + ]; + bind = [ " , Print, exec, ${lib.getExe pkgs.hyprshot} -z -o ~/Screenshots -m active -m output" "CTRL, Print, exec, ${lib.getExe pkgs.hyprshot} -z -o ~/Screenshots -m region" "ALT , Print, exec, ${lib.getExe pkgs.hyprshot} -z -o ~/Screenshots -m active -m window" - '', XF86Calculator, exec, ghostty --title=pulsemixer -e pulsemixer'' + "$mainMod, W, exec, ${lib.getExe wallpaper_changer}" ]; }; };