hyprland: move config to pyprland module

This commit is contained in:
Tigor Hutasuhut 2024-10-17 08:39:52 +07:00
parent ef797eb971
commit 50d83811ba
3 changed files with 26 additions and 44 deletions

View file

@ -86,7 +86,6 @@ in
"$mod, B, exec, microsoft-edge" "$mod, B, exec, microsoft-edge"
"$mod, BackSpace, exec, wlogout" "$mod, BackSpace, exec, wlogout"
''$mod, F, exec, ${select-window.path}'' ''$mod, F, exec, ${select-window.path}''
"$mod, W, exec, pypr wall next"
"$mod, S, exec, foot ssh homeserver@vpn.tigor.web.id" "$mod, S, exec, foot ssh homeserver@vpn.tigor.web.id"
# Workspaces # Workspaces
@ -210,7 +209,6 @@ in
exec-once=waybar exec-once=waybar
exec-once=nm-applet exec-once=nm-applet
exec-once=pasystray exec-once=pasystray
exec-once=pypr
source=${config.home.homeDirectory}/.cache/wallust/hyprland.conf source=${config.home.homeDirectory}/.cache/wallust/hyprland.conf
exec-once=sleep 0.2 && swww img ${config.home.homeDirectory}/.cache/wallpaper/current exec-once=sleep 0.2 && swww img ${config.home.homeDirectory}/.cache/wallpaper/current

View file

@ -1,37 +1,47 @@
{ lib, pkgs, unstable, config, ... }: { lib, pkgs, unstable, config, ... }:
let let
cfg = config.profile.hyprland; cfg = config.profile.hyprland;
draw-wallpaper = rec { inherit (lib.meta) getExe;
filename = "select-wallpaper.sh"; wallpaperDir = "${config.home.homeDirectory}/.cache/wallpaper";
script = pkgs.writeScriptBin filename (builtins.readFile ./scripts/draw-wallpaper.sh); draw-wallpaper = pkgs.writeShellScriptBin "draw-wallpaper.sh" /*sh*/ ''
path = "${script}/bin/${filename}"; image_file=$1
}; target="${wallpaperDir}/current"
blur_target="${wallpaperDir}/blurred.png"
mkdir -p "${wallpaperDir}"
echo "$image_file" > "${wallpaperDir}/origin.txt"
cp "$image_file" "$target"
swww img "$target"
${unstable.wallust}/bin/wallust run "$target"
${pkgs.imagemagick}/bin/gm convert -resize 75% -blur 50x30 "$target" "$blur_target"
'';
in in
{ {
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
home.packages = [ unstable.pyprland unstable.swww ]; home.packages = [
unstable.pyprland
unstable.swww
];
home.file.".config/hypr/pyprland.toml".source = home.file.".config/hypr/pyprland.toml".source =
let let
tomlFormat = pkgs.formats.toml { }; tomlFormat = pkgs.formats.toml { };
in in
tomlFormat.generate "pyprland.toml" { tomlFormat.generate "pyprland.toml" {
# https://github.com/hyprland-community/pyprland/wiki/Getting-started#configuring
pyprland.plugins = [ pyprland.plugins = [
# "scratchpads"
# "fetch_client_menu"
"wallpapers" "wallpapers"
]; ];
# scratchpads.term = {
# animation = "fromTop";
# command = "foot --app-id foot-scratchpad";
# class = "foot-scratchpad";
# size = "75% 75%";
# };
wallpapers = { wallpapers = {
path = cfg.pyprland.wallpaper-dirs; path = cfg.pyprland.wallpaper-dirs;
unique = false; unique = false;
command = ''${draw-wallpaper.path} [file]''; command = ''${getExe draw-wallpaper} [file]'';
}; };
}; };
wayland.windowManager.hyprland.settings = {
exec-once = [ "pypr" ];
bind = [
"$mod, W, exec, pypr wall next"
];
};
}; };
} }

View file

@ -1,26 +0,0 @@
#/usr/bin/env bash
# This is a script to draw wallpaper.
# First argument must exist and targets to image path.
#
# Requirements:
# 1. hyprland
# 2. swww
# 3. GraphicsMagick
# 4. wallust
if [ "$1" == "" ]; then
echo "Image path must be given"
exit 1
fi
image_file=$1
target="$HOME/.cache/wallpaper/current"
blur_target="$HOME/.cache/wallpaper/blurred.png"
mkdir -p "$HOME/.cache/wallpaper"
echo "$image_file" >"$HOME/.cache/wallpaper/origin.txt"
cp "$image_file" "$target"
swww img "$target"
wallust run "$target"
gm convert -resize 75% -blur 50x30 "$target" "$blur_target"