Testing hyprscrolling
This commit is contained in:
@@ -0,0 +1,61 @@
|
|||||||
|
# hyprscrolling.conf
|
||||||
|
# Loaded from: ./assets/conf/desktop/hypr/hyprscrolling.conf
|
||||||
|
#
|
||||||
|
# Notes:
|
||||||
|
# - These are the documented scrolling-layout knobs and defaults.
|
||||||
|
# - Keep them here; Home-Manager will source this file from ~/.config/hypr/conf.d/.
|
||||||
|
|
||||||
|
########################
|
||||||
|
# Layout selection
|
||||||
|
########################
|
||||||
|
general {
|
||||||
|
layout = scrolling
|
||||||
|
}
|
||||||
|
|
||||||
|
########################
|
||||||
|
# Scrolling layout config
|
||||||
|
########################
|
||||||
|
scrolling {
|
||||||
|
# when enabled, a single column on a workspace will always span the entire screen.
|
||||||
|
fullscreen_on_one_column = true
|
||||||
|
|
||||||
|
# the default width of a column, [0.1 - 1.0]
|
||||||
|
column_width = 0.5
|
||||||
|
|
||||||
|
# When a column is focused, what method should be used to bring it into view.
|
||||||
|
# 0 = center, 1 = fit
|
||||||
|
focus_fit_method = 0
|
||||||
|
|
||||||
|
# when a window is focused, should the layout move to bring it into view automatically
|
||||||
|
follow_focus = true
|
||||||
|
|
||||||
|
# when a window is focused, require that at least a given fraction of it is visible
|
||||||
|
# for focus to follow. Hard input (e.g. binds, clicks) will always follow. [0.0 - 1.0]
|
||||||
|
follow_min_visible = 0.4
|
||||||
|
|
||||||
|
# A comma-separated list of preconfigured widths for colresize +conf/-conf
|
||||||
|
explicit_column_widths = 0.333, 0.5, 0.667, 1.0
|
||||||
|
|
||||||
|
# Direction in which new windows appear and the layout scrolls. left/right/down/up
|
||||||
|
direction = right
|
||||||
|
}
|
||||||
|
|
||||||
|
########################
|
||||||
|
# Workspace rules (optional examples)
|
||||||
|
########################
|
||||||
|
# workspace = 2, layoutopt:direction:right
|
||||||
|
|
||||||
|
########################
|
||||||
|
# Layout messages (optional examples)
|
||||||
|
########################
|
||||||
|
# bind = $mainMod, period, layoutmsg, move +col
|
||||||
|
# bind = $mainMod, comma, layoutmsg, swapcol l
|
||||||
|
#
|
||||||
|
# Available layoutmsg params:
|
||||||
|
# - move (-200 / +200) or (+col / -col)
|
||||||
|
# - colresize (0.5 / +0.2 / -0.2 / +conf / -conf / all (number))
|
||||||
|
# - fit (active / visible / all / toend / tobeg)
|
||||||
|
# - focus (l/r/u/d) (wraps instead of moving to neighboring monitors)
|
||||||
|
# - promote (moves a window to its own new column)
|
||||||
|
# - swapcol (l or r) (wraps around)
|
||||||
|
# - togglefit (toggles focus_fit_method)
|
||||||
@@ -1,121 +1,55 @@
|
|||||||
{ config, lib, pkgs, ... }:
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
flakeRoot,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.programs.hyprscrolling;
|
cfg = config.programs.hyprscrolling;
|
||||||
|
|
||||||
# Render plugin settings into:
|
# Read configuration from your repo (as requested)
|
||||||
# plugin:hyprscrolling {
|
confSrc = flakeRoot + "/assets/conf/desktop/hypr/hyprscrolling.conf";
|
||||||
# key = value
|
|
||||||
# }
|
|
||||||
renderValue = v:
|
|
||||||
if lib.isString v then "\"${v}\""
|
|
||||||
else if lib.isBool v then (if v then "true" else "false")
|
|
||||||
else if lib.isInt v || lib.isFloat v then toString v
|
|
||||||
else if lib.isList v then
|
|
||||||
"[ " + (lib.concatStringsSep " " (map renderValue v)) + " ]"
|
|
||||||
else
|
|
||||||
throw "programs.hyprscrolling.settings: unsupported value type: ${builtins.typeOf v}";
|
|
||||||
|
|
||||||
renderSettings = settings:
|
# Where we place the generated/symlinked config inside ~/.config
|
||||||
let
|
confTarget = "hypr/conf.d/90-hyprscrolling.conf";
|
||||||
lines = lib.mapAttrsToList (k: v: " ${k} = ${renderValue v}") settings;
|
|
||||||
in
|
|
||||||
if settings == { } then ""
|
|
||||||
else ''
|
|
||||||
plugin:hyprscrolling {
|
|
||||||
${lib.concatStringsSep "\n" lines}
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
|
|
||||||
defaultPluginPkg = (pkgs.hyprlandPlugins.hyprscrolling or null);
|
|
||||||
|
|
||||||
# Stable paths (avoid pinning /nix/store/... in your hyprland.conf)
|
|
||||||
stableSoPath = "/etc/hypr/plugins/libhyprscrolling.so";
|
|
||||||
dropInConfPath = "/etc/hypr/conf.d/90-hyprscrolling.conf";
|
|
||||||
|
|
||||||
dropInConf = ''
|
|
||||||
# Managed by Nix: programs.hyprscrolling
|
|
||||||
# Load plugin shared object (.so)
|
|
||||||
plugin = ${stableSoPath}
|
|
||||||
|
|
||||||
${lib.optionalString cfg.setAsDefaultLayout ''
|
|
||||||
general {
|
|
||||||
layout = scrolling
|
|
||||||
}
|
|
||||||
''}
|
|
||||||
|
|
||||||
${renderSettings cfg.settings}
|
|
||||||
|
|
||||||
${cfg.extraConfig}
|
|
||||||
'';
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.programs.hyprscrolling = {
|
options.programs.hyprscrolling = {
|
||||||
enable = lib.mkEnableOption "Hyprland hyprscrolling (scrolling layout) plugin (NixOS-friendly)";
|
enable = lib.mkEnableOption "Hyprscrolling plugin (scrolling layout) for Hyprland";
|
||||||
|
|
||||||
pluginPackage = lib.mkOption {
|
package = lib.mkOption {
|
||||||
type = lib.types.nullOr lib.types.package;
|
type = lib.types.package;
|
||||||
default = defaultPluginPkg;
|
default = pkgs.hyprlandPlugins.hyprscrolling;
|
||||||
description = ''
|
description = "hyprscrolling plugin package to load via wayland.windowManager.hyprland.plugins.";
|
||||||
Package that provides the hyprscrolling plugin.
|
|
||||||
Defaults to pkgs.hyprlandPlugins.hyprscrolling when available.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
setAsDefaultLayout = lib.mkOption {
|
|
||||||
type = lib.types.bool;
|
|
||||||
default = true;
|
|
||||||
description = "Whether to set `general { layout = scrolling }` in the generated drop-in config.";
|
|
||||||
};
|
|
||||||
|
|
||||||
settings = lib.mkOption {
|
|
||||||
type = lib.types.attrs;
|
|
||||||
default = { };
|
|
||||||
description = ''
|
|
||||||
Attribute set rendered into a `plugin:hyprscrolling { ... }` block
|
|
||||||
in the generated drop-in config.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
extraConfig = lib.mkOption {
|
|
||||||
type = lib.types.lines;
|
|
||||||
default = "";
|
|
||||||
description = "Extra Hyprland config appended to the generated drop-in config.";
|
|
||||||
};
|
|
||||||
|
|
||||||
# Where we install the generated config snippet (so you can `source = ...` it)
|
|
||||||
dropInPath = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
default = dropInConfPath;
|
|
||||||
description = "Path to the generated Hyprland drop-in config file (needs to be sourced by your hyprland.conf).";
|
|
||||||
};
|
|
||||||
|
|
||||||
# Where we install a stable symlink to the plugin .so
|
|
||||||
stablePluginSoPath = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
default = stableSoPath;
|
|
||||||
description = "Stable path for the plugin shared object (symlinked to the Nix store).";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
assertions = [
|
assertions = [
|
||||||
{
|
{
|
||||||
assertion = cfg.pluginPackage != null;
|
assertion = config.wayland.windowManager.hyprland.enable or false;
|
||||||
message = ''
|
message = "programs.hyprscrolling.enable requires wayland.windowManager.hyprland.enable = true (Home-Manager Hyprland module).";
|
||||||
Could not find hyprscrolling plugin package in this nixpkgs.
|
}
|
||||||
Set programs.hyprscrolling.pluginPackage explicitly (e.g. pkgs.hyprlandPlugins.hyprscrolling).
|
{
|
||||||
'';
|
assertion = builtins.pathExists confSrc;
|
||||||
|
message = "Missing hyprscrolling.conf at: ${toString confSrc}";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
# Ensure the plugin is built and available.
|
# Ensure plugin is installed + loaded (HM will add the needed plugin loading lines)
|
||||||
environment.systemPackages = [ cfg.pluginPackage ];
|
wayland.windowManager.hyprland.plugins = [
|
||||||
|
cfg.package
|
||||||
|
];
|
||||||
|
|
||||||
# Provide a stable .so path under /etc (no /nix/store hardcoding in hyprland.conf)
|
# Put your config file into ~/.config/hypr/conf.d/...
|
||||||
environment.etc."hypr/plugins/libhyprscrolling.so".source =
|
xdg.configFile."${confTarget}".source = confSrc;
|
||||||
"${cfg.pluginPackage}/lib/libhyprscrolling.so";
|
|
||||||
|
|
||||||
# Provide a drop-in config file under /etc.
|
# Ensure Hyprland reads it (even if your main config doesn't source conf.d)
|
||||||
environment.etc."hypr/conf.d/90-hyprscrolling.conf".text = dropInConf;
|
wayland.windowManager.hyprland.extraConfig = ''
|
||||||
|
# Loaded by Home-Manager: hyprscrolling
|
||||||
|
source = ${config.xdg.configHome}/${confTarget}
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user