Hyprpaper module
This commit is contained in:
parent
8e2bbdcca5
commit
2533fa1c43
21 changed files with 363 additions and 107 deletions
modules/home-manager
|
@ -2,9 +2,17 @@
|
|||
|
||||
{
|
||||
# example = import ./example.nix;
|
||||
discord = import ./discord.nix;
|
||||
|
||||
# Personal things
|
||||
firefox = import ./firefox;
|
||||
satellite-dev = import ./satellite-dev.nix;
|
||||
satellite-persistence = import ./persistence.nix;
|
||||
monitors = import ./monitors.nix;
|
||||
|
||||
# Should upstream
|
||||
discord = import ./discord.nix;
|
||||
hyprpaper = import ./hyprpaper.nix;
|
||||
|
||||
# Temporary
|
||||
wofi = import ./wofi.nix;
|
||||
}
|
||||
|
|
106
modules/home-manager/hyprpaper.nix
Normal file
106
modules/home-manager/hyprpaper.nix
Normal file
|
@ -0,0 +1,106 @@
|
|||
# TODO: add maintainers and upstream into home-manager
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.hyprpaper;
|
||||
mkWallpaper = { mode, image, monitor, ... }:
|
||||
let
|
||||
monitorString = lib.optionalString (monitor != null) monitor;
|
||||
modeString = lib.optionalString (mode == "contain") "contain:";
|
||||
in
|
||||
"wallpaper=${monitorString},${modeString}${image}";
|
||||
in
|
||||
{
|
||||
options.services.hyprpaper = {
|
||||
enable = mkEnableOption "hyprpaper";
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.hyprpaper;
|
||||
defaultText = "pkgs.hyprpaper";
|
||||
description = ''
|
||||
hyprpaper derivation to use.
|
||||
'';
|
||||
};
|
||||
|
||||
systemdTarget = mkOption {
|
||||
type = types.str;
|
||||
default = "graphical-session.target";
|
||||
description = ''
|
||||
Systemd target to bind to.
|
||||
'';
|
||||
};
|
||||
|
||||
preload = mkOption {
|
||||
type = types.listOf (types.oneOf [ types.str types.path ]);
|
||||
default = [ ];
|
||||
example = [ "~/background.png" ];
|
||||
description = "List of images to preload";
|
||||
};
|
||||
|
||||
wallpapers = mkOption {
|
||||
type = types.listOf (types.submodule (_: {
|
||||
options = {
|
||||
monitor = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
example = "eDP-1";
|
||||
description = ''
|
||||
Monitor to use for the wallpaper.
|
||||
Either leave empty as a wildcard,
|
||||
type the name of the monitor, or
|
||||
include the monitor's description
|
||||
prefixed with `desc:`.
|
||||
'';
|
||||
};
|
||||
|
||||
image = mkOption {
|
||||
type = types.oneOf [ types.str types.path ];
|
||||
default = null;
|
||||
example = "~/background.png";
|
||||
description = "Image to use as wallpaper";
|
||||
};
|
||||
|
||||
mode = mkOption {
|
||||
type = lib.types.enum [ "cover" "contain" ];
|
||||
default = "cover";
|
||||
example = "contain";
|
||||
description = "The way to display the wallpaper";
|
||||
};
|
||||
};
|
||||
}));
|
||||
|
||||
default = [ ];
|
||||
description = "List of wallpapers to set";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
assertions = [
|
||||
(lib.hm.assertions.assertPlatform "services.hyprpaper" pkgs
|
||||
lib.platforms.linux)
|
||||
];
|
||||
|
||||
xdg.configFile."hypr/hyprpaper.conf".text = ''
|
||||
${lib.concatStringsSep "\n" (lib.forEach cfg.preload (image: "preload=${image}"))}
|
||||
${lib.concatStringsSep "\n" (lib.forEach cfg.wallpapers mkWallpaper)}
|
||||
'';
|
||||
|
||||
systemd.user.services.hyprpaper = {
|
||||
Unit = {
|
||||
Description = "Wayland wallpaper service";
|
||||
PartOf = [ "graphical-session.target" ];
|
||||
};
|
||||
|
||||
Service = {
|
||||
ExecStart = "${cfg.package}/bin/hyprpaper";
|
||||
};
|
||||
|
||||
Install = {
|
||||
WantedBy = [ cfg.systemdTarget ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
50
modules/home-manager/monitors.nix
Normal file
50
modules/home-manager/monitors.nix
Normal file
|
@ -0,0 +1,50 @@
|
|||
# Taken from [misterio's config](https://github.com/Misterio77/nix-config/blob/main/modules/home-manager/monitors.nix)
|
||||
# This is meant to provide a wm-independent way of specifying the monitor configuration of each machine.
|
||||
{ lib, ... }:
|
||||
{
|
||||
options.monitors = lib.mkOption {
|
||||
type = lib.types.listOf (lib.types.submodule {
|
||||
options = {
|
||||
name = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
example = "DP-1";
|
||||
};
|
||||
|
||||
width = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
example = 1920;
|
||||
};
|
||||
|
||||
height = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
example = 1080;
|
||||
};
|
||||
|
||||
refreshRate = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = 60;
|
||||
};
|
||||
|
||||
x = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = 0;
|
||||
};
|
||||
|
||||
y = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = 0;
|
||||
};
|
||||
|
||||
enabled = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
};
|
||||
|
||||
workspace = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
|
@ -18,11 +18,29 @@ in
|
|||
description = "The location to store the files described in this record";
|
||||
};
|
||||
|
||||
prefixDirectories = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
example = false;
|
||||
description = "Whether to enable gnu/stow type prefix directories";
|
||||
};
|
||||
|
||||
apps = lib.mkOption {
|
||||
default = { };
|
||||
description = "The apps to be stores in this persistent location";
|
||||
type = lib.types.attrsOf (lib.types.submodule (_: {
|
||||
options = {
|
||||
files = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
default = [ ];
|
||||
example = [ ".screenrc" ];
|
||||
description = ''
|
||||
A list of files in your home directory you want to
|
||||
link to persistent storage. Allows both absolute paths
|
||||
and paths relative to the home directory. .
|
||||
'';
|
||||
};
|
||||
|
||||
directories = lib.mkOption {
|
||||
default = [ ];
|
||||
description = "Modified version of home.persistence.*.directories which takes in absolute paths";
|
||||
|
@ -36,7 +54,7 @@ in
|
|||
|
||||
method = lib.mkOption {
|
||||
type = lib.types.enum [ "bindfs" "symlink" ];
|
||||
default = "bindfs";
|
||||
default = "symlink";
|
||||
description = ''
|
||||
The linking method that should be used for this
|
||||
directory. bindfs is the default and works for most use
|
||||
|
@ -60,7 +78,12 @@ in
|
|||
makeLocation = location:
|
||||
let
|
||||
processPath = appName: value:
|
||||
"${appName}/${lib.strings.removePrefix config.home.homeDirectory (builtins.toString value)}";
|
||||
let
|
||||
suffix = "${lib.strings.removePrefix "${config.home.homeDirectory}/" (builtins.toString value)}";
|
||||
prefix = if location.prefixDirectories then "${appName}/" else "";
|
||||
in
|
||||
# lib.debug.traceSeq "\nProcessing path at location ${location.path} and app ${appName} from original path ${value} to ${prefix + suffix}"
|
||||
(prefix + suffix);
|
||||
|
||||
mkDirectory = appName: directory:
|
||||
if builtins.isAttrs directory then {
|
||||
|
@ -70,12 +93,16 @@ in
|
|||
else processPath appName directory;
|
||||
|
||||
mkAppDirectory = appName: app: builtins.map (mkDirectory appName) app.directories;
|
||||
mkAppFiles = appName: app: builtins.map (processPath appName) app.files;
|
||||
in
|
||||
lib.attrsets.nameValuePair (location.path + config.home.homeDirectory) {
|
||||
removePrefixDirectory = true;
|
||||
removePrefixDirectory = location.prefixDirectories;
|
||||
allowOther = true;
|
||||
directories = lib.lists.flatten
|
||||
(lib.attrsets.mapAttrsToList mkAppDirectory location.apps);
|
||||
|
||||
files = lib.lists.flatten
|
||||
(lib.attrsets.mapAttrsToList mkAppFiles location.apps);
|
||||
};
|
||||
in
|
||||
lib.mkIf cfg.enable {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue