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

View file

@ -1,37 +1,47 @@
{ lib, pkgs, unstable, config, ... }:
let
cfg = config.profile.hyprland;
draw-wallpaper = rec {
filename = "select-wallpaper.sh";
script = pkgs.writeScriptBin filename (builtins.readFile ./scripts/draw-wallpaper.sh);
path = "${script}/bin/${filename}";
};
inherit (lib.meta) getExe;
wallpaperDir = "${config.home.homeDirectory}/.cache/wallpaper";
draw-wallpaper = pkgs.writeShellScriptBin "draw-wallpaper.sh" /*sh*/ ''
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
{
config = lib.mkIf cfg.enable {
home.packages = [ unstable.pyprland unstable.swww ];
home.packages = [
unstable.pyprland
unstable.swww
];
home.file.".config/hypr/pyprland.toml".source =
let
tomlFormat = pkgs.formats.toml { };
in
tomlFormat.generate "pyprland.toml" {
# https://github.com/hyprland-community/pyprland/wiki/Getting-started#configuring
pyprland.plugins = [
# "scratchpads"
# "fetch_client_menu"
"wallpapers"
];
# scratchpads.term = {
# animation = "fromTop";
# command = "foot --app-id foot-scratchpad";
# class = "foot-scratchpad";
# size = "75% 75%";
# };
wallpapers = {
path = cfg.pyprland.wallpaper-dirs;
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"