remove hyprland from config

This commit is contained in:
Noa Aarts 2024-11-19 22:49:29 +01:00
parent c3a4fc2bb2
commit 3c0896e976
Signed by: noa
GPG key ID: 1850932741EFF672
24 changed files with 235 additions and 1134 deletions

View file

@ -0,0 +1,28 @@
{
writeTextFile,
display,
init-shader,
state-shader,
display-shader,
horizontal,
vertical,
tps ? 30,
cycles ? horizontal,
frames_per_tick ? 1,
}:
writeTextFile {
name = "automapaper-config-${display}";
text = ''
[display]
name="${display}"
horizontal=${builtins.toString horizontal}
vertical=${builtins.toString vertical}
tps=${builtins.toString tps}
state_frag="${state-shader}"
init_frag="${init-shader}"
display_frag="${display-shader}"
cycles=${builtins.toString cycles}
frames_per_tick=${builtins.toString frames_per_tick}
'';
destination = "/config.toml";
}

View file

@ -1,193 +0,0 @@
{
lib,
config,
pkgs,
inputs,
nix-colors,
...
}:
let
cfg = config.modules.automapaper;
in
{
options.modules.automapaper = {
enable = lib.mkEnableOption "enable automapaper";
hyprland = lib.mkEnableOption "enable hyprland exec-once integration";
startStrings = lib.mkOption {
type = lib.types.listOf lib.types.str;
};
default-configuration = {
init = lib.mkOption {
type = lib.types.str;
description = "the shader executed to get the state for the initialisation, and re-initialisation steps";
default = ''
#version 310 es
precision highp float;
uniform float time;
uniform vec2 resolution;
out vec4 stateColor;
float PHI = 1.61803398874989484820459; // Φ = Golden Ratio
float gold_noise(in vec2 xy, in float seed){
return fract(tan(distance(xy*PHI, xy)*seed)*xy.x);
}
void main( void ) {
vec2 position = gl_FragCoord.xy;
float color = gold_noise(position.xy, fract(time));
stateColor = vec4(step(0.3, color), 0,0,step(0.3, color));
}'';
};
state = lib.mkOption {
type = lib.types.str;
description = "the shader executed to increment the state to the next generation";
default = ''
#version 310 es
precision highp float;
uniform sampler2D state;
uniform vec2 scale;
out vec4 stateColor;
vec4 get(int x, int y) {
return texture(state, (gl_FragCoord.xy + vec2(x, y)) / scale);
}
void main() {
int sum = int(get(-1, -1).r +
get(-1, 0).r +
get(-1, 1).r +
get( 0, -1).r +
get( 0, 1).r +
get( 1, -1).r +
get( 1, 0).r +
get( 1, 1).r);
vec4 current = get(0,0);
if (sum == 3) {
stateColor.r = 1.0;
stateColor.g = 1.0;
} else if (sum == 2) {
stateColor = current;
if (current.r == 0.0) {
stateColor.g = max(current.g - 0.01, 0.0);
}
} else {
stateColor = vec4(0.0, max(current.g - 0.01, 0.0), 0.0, 1.0);
}
}'';
};
display = lib.mkOption {
type = lib.types.str;
description = "the shader executed to display the state to the monitor";
default = ''
#version 310 es
precision
highp
float;
uniform sampler2D tex2D;
uniform sampler2D old2D;
uniform ivec2 resolution;
uniform float frame_part;
in highp vec2 texCoords;
out vec4 stateColor;
const vec4 bgColor = ${nix-colors.lib.conversions.hexToGLSLVec config.colorScheme.palette.background_paper};
const vec4 fgColor = ${nix-colors.lib.conversions.hexToGLSLVec config.colorScheme.palette.foreground_paper};
void main() {
vec2 canvasSize = vec2 (textureSize (tex2D, 0));
vec4 state = texture (tex2D, texCoords);
vec4 ostate = texture (old2D, texCoords);
vec2 localCoords = fract (gl_FragCoord.xy / vec2 (resolution) * canvasSize);
localCoords = localCoords - 0.5;
float dist = sqrt (dot (localCoords, localCoords));
float size = smoothstep (0.0, 1.0, pow(mix(ostate.g,state.g, frame_part), 3.0)) * 0.35;
float mask = 1.0 - step (size, dist);
float brightness = mix (ostate.r, state.r, frame_part) + 0.2 * pow(mix(ostate.g,state.g, frame_part), 3.0);
stateColor = mix (bgColor, fgColor, brightness * mask);
} '';
};
horizontal = lib.mkOption {
type = lib.types.int;
default = 10;
};
vertical = lib.mkOption {
type = lib.types.int;
default = 10;
};
tps = lib.mkOption {
type = lib.types.int;
description = "the target amount of ticks to simulate each second";
default = 30;
};
cycles = lib.mkOption {
type = lib.types.int;
description = "the amount of state increments before the init shader is called again";
default = 2500;
};
frames_per_tick = lib.mkOption {
type = lib.types.int;
description = "the amount of times to call the display shader for each iteration of the state shader";
default = 1;
};
};
};
config =
let
mkDisplayConfig =
conf:
let
init = builtins.toFile "init.frag" conf.init;
state = builtins.toFile "state.frag" conf.state;
display = builtins.toFile "display.frag" conf.display;
in
''
[display]
name="${conf.name}"
horizontal=${builtins.toString conf.horizontal}
vertical=${builtins.toString conf.vertical}
tps=${builtins.toString conf.tps}
state_frag="${state}"
init_frag="${init}"
display_frag="${display}"
cycles=${builtins.toString conf.cycles}
frames_per_tick=${builtins.toString conf.frames_per_tick}
'';
confFile =
let
def = config.modules.automapaper.default-configuration;
in
conf:
builtins.toFile "${conf.name}.toml" (mkDisplayConfig {
name = conf.name;
horizontal = builtins.div conf.horizontal def.horizontal;
vertical = builtins.div conf.vertical def.vertical;
tps = def.tps;
state = def.state;
init = def.init;
display = def.display;
cycles = def.cycles;
frames_per_tick = def.frames_per_tick;
});
in
lib.mkIf cfg.enable rec {
modules.automapaper.startStrings = builtins.map (
conf: "${inputs.automapaper.packages.${pkgs.system}.default}/bin/automapaper -C ${confFile conf}"
) config.modules.hyprland.displays;
wayland.windowManager.hyprland.settings.exec-once = lib.mkIf cfg.hyprland modules.automapaper.startStrings;
};
}

View file

@ -0,0 +1,31 @@
#version 310 es
precision
highp
float;
uniform sampler2D tex2D;
uniform sampler2D old2D;
uniform ivec2 resolution;
uniform float frame_part;
in highp vec2 texCoords;
out vec4 stateColor;
const vec4 bgColor = @background@ ;
const vec4 fgColor = @foreground@ ;
void main() {
vec2 canvasSize = vec2(textureSize(tex2D, 0));
vec4 state = texture(tex2D, texCoords);
vec4 ostate = texture(old2D, texCoords);
vec2 localCoords = fract(gl_FragCoord.xy / vec2(resolution) * canvasSize);
localCoords = localCoords - 0.5;
float dist = sqrt(dot(localCoords, localCoords));
float size = smoothstep(0.0, 1.0, pow(mix(ostate.g, state.g, frame_part), 3.0)) * 0.35;
float mask = 1.0 - step(size, dist);
float brightness = mix(ostate.r, state.r, frame_part) + 0.2 * pow(mix(ostate.g, state.g, frame_part), 3.0);
stateColor = mix(bgColor, fgColor, brightness * mask);
}

View file

@ -0,0 +1,26 @@
#version 310 es
precision highp float;
uniform float time;
uniform vec2 resolution;
out vec4 stateColor;
uint xxhash32(uvec2 p)
{
const uint PRIME32_2 = 2246822519U, PRIME32_3 = 3266489917U;
const uint PRIME32_4 = 668265263U, PRIME32_5 = 374761393U;
uint h32 = p.y + PRIME32_5 + p.x * PRIME32_3;
h32 = PRIME32_4 * ((h32 << 17) | (h32 >> (32 - 17)));
h32 = PRIME32_2 * (h32 ^ (h32 >> 15));
h32 = PRIME32_3 * (h32 ^ (h32 >> 13));
return h32 ^ (h32 >> 16);
}
void main(void) {
vec2 position = gl_FragCoord.xy;
position += 100.0 * time;
uint hash = xxhash32(uvec2(position.x, position.y));
float value = float(hash) * (1.0 / float(0xffffffffu));
stateColor = vec4(step(0.3, value), 0, 0, step(0.3, value));
}

View file

@ -0,0 +1,34 @@
#version 310 es
precision highp float;
uniform sampler2D state;
uniform vec2 scale;
out vec4 stateColor;
vec4 get(int x, int y) {
return texture(state, (gl_FragCoord.xy + vec2(x, y)) / scale);
}
void main() {
int sum = int(get(-1, -1).r +
get(-1, 0).r +
get(-1, 1).r +
get(0, -1).r +
get(0, 1).r +
get(1, -1).r +
get(1, 0).r +
get(1, 1).r);
vec4 current = get(0, 0);
if (sum == 3) {
stateColor.r = 1.0;
stateColor.g = 1.0;
} else if (sum == 2) {
stateColor = current;
if (current.r == 0.0) {
stateColor.g = max(current.g - 0.01, 0.0);
}
} else {
stateColor = vec4(0.0, max(current.g - 0.01, 0.0), 0.0, 1.0);
}
}

View file

@ -1,6 +1,9 @@
{ ... }:
{
imports = [
./hyprland.nix
./waybar
./applications
./games
./dunst.nix
];
}

View file

@ -1,253 +0,0 @@
{
config,
lib,
pkgs,
inputs,
...
}:
let
cfg = config.modules.hyprland;
in
{
options.modules.hyprland = {
enable = lib.mkEnableOption "enable hyprland";
package = lib.mkOption {
type = lib.types.package;
default = pkgs.hyprland;
example = lib.literalExpression ''inputs.hyprland.packages.${pkgs.system}.hyprland'';
};
terminal = lib.mkOption {
type = lib.types.package;
default = pkgs.kitty;
description = "What terminal emulator should be used in hyprland";
};
wallpapers.automapaper = {
enable = lib.mkEnableOption "enable automapaper";
};
portalPackage = lib.mkOption {
type = lib.types.package;
default = pkgs.xdg-desktop-portal-hyprland;
};
displays = lib.mkOption {
type = lib.types.listOf (
lib.types.submodule {
options = {
name = lib.mkOption {
type = lib.types.str;
description = "the display identifier";
example = "DP-2";
};
horizontal = lib.mkOption {
type = lib.types.ints.positive;
description = "the horizontal resolution";
example = 1920;
};
vertical = lib.mkOption {
type = lib.types.ints.positive;
description = "the vertical resolution";
example = 1080;
};
horizontal-offset = lib.mkOption {
type = lib.types.ints.unsigned;
description = "the horizontal resolution";
example = 1920;
};
vertical-offset = lib.mkOption {
type = lib.types.ints.unsigned;
description = "the vertical resolution";
example = 0;
};
refresh-rate = lib.mkOption {
type = lib.types.ints.unsigned;
description = "the refresh rate of the monitor";
example = 60;
};
scale = lib.mkOption {
type = lib.types.str;
description = "the scale of the monitor";
default = "1";
example = "1.5";
};
};
}
);
description = "the display layout to use";
};
};
imports = [
./waybar/default.nix
./wofi.nix
./dunst.nix
./automapaper
];
config = lib.mkIf cfg.enable {
modules = {
automapaper = {
enable = lib.mkDefault true;
hyprland = cfg.enable;
};
waybar = {
modules = {
left = [
"hyprland/workspaces"
"tray"
"hyprland/window"
];
center = [
"clock"
"custom/spotify"
];
right = [
"custom/vpn"
"wireplumber"
"network"
"cpu"
"memory"
"custom/poweroff"
];
};
enable = lib.mkDefault true;
};
wofi.enable = lib.mkDefault true;
dunst.enable = lib.mkDefault true;
};
# these are necessary for the config to function correctly
home.packages = with pkgs; [
# I always want these with hyprland anyways
libnotify # to enable the notify-send command
wl-clipboard # wl-copy and wl-paste
playerctl
];
xdg.portal = {
extraPortals = [ cfg.portalPackage ];
config.common.default = "*";
};
services = {
hypridle = {
enable = true;
settings.listener = [
{
timeout = 330;
on-timeout = "hyprctl dispatch dpms off"; # screen off when timeout has passed
on-resume = "hyprctl dispatch dpms on"; # screen on when activity is detected after timeout has fired.
}
];
};
playerctld.enable = true;
};
wayland.windowManager.hyprland = {
enable = true;
package = cfg.package;
settings =
let
make-display-string =
display:
"${display.name}, ${builtins.toString display.horizontal}x${builtins.toString display.vertical}@${builtins.toString display.refresh-rate}, ${builtins.toString display.horizontal-offset}x${builtins.toString display.vertical-offset}, ${display.scale}";
in
{
monitor = builtins.map make-display-string cfg.displays;
windowrulev2 = [
"opacity 1.0 0.6,class:^(kitty)$"
"stayfocused,class:^(wofi)$"
];
env = [
"WLR_NO_HARDWARE_CURSORS,1"
];
exec-once = [
"${pkgs.waybar}/bin/waybar"
"${pkgs.dunst}/bin/dunst"
"${cfg.package}/bin/hyprctl dispatcher focusmonitor 1"
];
general = {
gaps_in = "2";
gaps_out = "3";
border_size = "3";
"col.active_border" = "0xff${config.colorScheme.palette.base01}";
"col.inactive_border" = "0xff${config.colorScheme.palette.base00}";
};
input = {
touchpad = {
clickfinger_behavior = 1;
disable_while_typing = 1;
natural_scroll = 1;
tap-to-click = 1;
scroll_factor = 0.3;
};
};
misc = {
key_press_enables_dpms = true;
};
decoration = {
rounding = "6";
active_opacity = "1";
inactive_opacity = "1";
};
animations = {
enabled = "1";
animation = [
"windows,1,2,default"
"border,1,10,default"
"fade,0,5,default"
"workspaces,1,4,default"
];
};
"$mod" = "SUPER";
bind =
let
wpkgs = inputs.self.packages.${pkgs.system};
in
[
"$mod,Return,exec,${cfg.terminal}/bin/${cfg.terminal.pname}"
"$mod,tab,cyclenext"
"SUPERSHIFT,Q,killactive"
"$mod,SPACE,exec,${wpkgs.wofi-launch}/bin/wofi-launch"
"$mod,P,exec,${wpkgs.wofi-power}/bin/wofi-power"
"SUPERSHIFT,m,exit"
"$mod,H,movefocus,l"
"$mod,J,movefocus,u"
"$mod,K,movefocus,d"
"$mod,L,movefocus,r"
"SUPERSHIFT,H,movewindow,l"
"SUPERSHIFT,J,movewindow,u"
"SUPERSHIFT,K,movewindow,d"
"SUPERSHIFT,L,movewindow,r"
"$mod,F,togglefloating"
"$mod,X,togglespecialworkspace"
"SUPERSHIFT,X,movetoworkspace,special"
"SUPERSHIFT,S,exec,${pkgs.hyprshot}/bin/hyprshot -m region --clipboard-only"
"$mod,f11,fullscreen,0"
",XF86AudioLowerVolume,exec,${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_SINK@ 1%-"
",XF86AudioRaiseVolume,exec,${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_SINK@ 1%+"
",XF86AudioMute,exec,${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_SINK@ toggle"
",XF86AudioPlay,exec,${pkgs.playerctl}/bin/playerctl play-pause"
",XF86AudioPrev,exec,${pkgs.playerctl}/bin/playerctl previous"
",XF86AudioNext,exec,${pkgs.playerctl}/bin/playerctl next"
"$mod,mouse_up,workspace,r-1"
"$mod,mouse_down,workspace,r+1"
]
++ (builtins.concatLists (
builtins.genList (
x:
let
ws = builtins.toString (x);
in
[
"$mod,${ws},workspace,${ws}"
"ALT,${ws},movetoworkspace,${ws}"
]
) 10
));
bindm = [
"$mod,mouse:272,movewindow"
"$mod,mouse:273,resizewindow"
];
};
};
};
}

View file

@ -16,7 +16,7 @@ in
config = lib.mkIf cfg.enable {
services = {
desktopManager.plasma6.enable = true;
displayManager.defaultSession = "hyprland";
displayManager.defaultSession = "niri";
};
xdg.portal.config.common.default = "*";

View file

@ -76,7 +76,8 @@ in
margin-top = 8;
margin-left = 10;
margin-right = 10;
output = builtins.map (display: display.name) config.modules.hyprland.displays;
# TODO: find a new way to do outputs nicely
# output = builtins.map (display: display.name) config.modules.hyprland.displays;
modules-left = cfg.modules.left;
modules-center = cfg.modules.center;
modules-right = cfg.modules.right;

View file

@ -1,4 +1,10 @@
{ lib, config, ... }:
{
lib,
config,
pkgs,
inputs,
...
}:
let
name = "custom/poweroff";
in
@ -9,16 +15,12 @@ in
enable = lib.mkEnableOption "enable ${name} waybar module";
};
};
imports = [
../wofi.nix
];
config = lib.mkIf config.modules.waybar.enabled.${name}.enable {
modules.wofi.enable = true;
programs.waybar = {
settings.mainBar."${name}" = {
format = "";
on-click = "wofi-power";
on-click-right = "swaylock"; # TODO: change to whatever lock screen i want
on-click = "${inputs.self.packages.${pkgs.system}.fuzzel-launch}";
on-click-right = "${pkgs.swaylock}/bin/swaylock"; # TODO: change to whatever lock screen i want
};
style = ''
#custom-poweroff {

View file

@ -1,6 +1,6 @@
{ lib, config, ... }:
let
name = "hyprland/window";
name = "niri/window";
in
{
options.modules.waybar = {

View file

@ -1,6 +1,6 @@
{ lib, config, ... }:
let
name = "hyprland/workspaces";
name = "niri/workspaces";
in
{
options.modules.waybar = {

View file

@ -1,105 +0,0 @@
{
lib,
config,
pkgs,
inputs,
...
}:
let
cfg = config.modules.wofi;
in
{
options.modules.wofi = {
enable = lib.mkEnableOption "enable wofi app launcher";
};
imports = [
../common/colors.nix
];
config = lib.mkIf cfg.enable {
home.packages =
let
wpkgs = inputs.self.packages.${pkgs.system};
in
[
wpkgs.wofi-launch
wpkgs.wofi-power
];
programs.wofi = {
enable = true;
settings = { };
style = ''
* {
outline: none;
outline-style: none;
}
#window {
margin: 10px;
border: none;
background-color: #${config.colorScheme.palette.base01};
border-radius: 10px;
font-family:
JetBrains Mono NF,
monospace;
font-weight: bold;
font-size: 14px;
}
#outer-box {
margin: 10px;
border: 2px #${config.colorScheme.palette.base00};
border-radius: 10px;
background-color: transparent;
}
#input {
border: none;
border-radius: 10px;
margin-left: 2px;
color: #${config.colorScheme.palette.base05};
outline-style: none;
background-color: #${config.colorScheme.palette.base03};
}
#scroll {
border: 5px solid #${config.colorScheme.palette.base02};
border-radius: 10px;
/*padding-right: 10px;*/
outline: none;
background-color: #${config.colorScheme.palette.base00};
}
#inner-box {
border: none;
border-radius: 10px;
background-color: transparent;
}
#entry {
border: none;
border-radius: 10px;
margin-right: 15px;
margin-left: 15px;
padding-right: 10px;
padding-left: 10px;
color: #${config.colorScheme.palette.base05};
background-color: #${config.colorScheme.palette.base00};
}
#entry:selected {
border: none;
background-color: #${config.colorScheme.palette.base02};
}
#text:selected {
border: none;
color: #${config.colorScheme.palette.base05};
}
#img {
background-color: transparent;
margin-right: 6px;
}
'';
};
};
}