Refactor codebase to use nix modules

This commit is contained in:
Julia Lange 2024-04-14 05:40:02 -07:00
parent a4735423b4
commit ffada2703c
114 changed files with 1018 additions and 744 deletions

View file

@ -0,0 +1,50 @@
{ config, inputs, pkgs, lib, ... }:
let rootPath = ./.; in
{
options.hypr = {
enable = lib.mkEnableOption "Enables hyprland";
};
imports = [ inputs.hyprland.homeManagerModules.default ];
config = lib.mkIf config.hypr.enable {
wayland.windowManager.hyprland = {
enable = true;
extraConfig = ''
${builtins.readFile ./window_rules.conf}
${builtins.readFile ./league_rules.conf}
${builtins.readFile ./settings.conf}
${builtins.readFile ./nvidia.conf}
${builtins.readFile ./keybinds.conf}
${builtins.readFile ./xwaylandvideobridge.conf}
exec-once=${pkgs.polkit-kde-agent}/libexec/polkit-kde-authentication-agent-1
env = HYPRCURSOR_THEME,miku
env = HYPRCURSOR_SIZE,64
'';
};
home.packages = with pkgs; [
socat # For hyprland scripts
swww # Wallpaper engine
wlr-randr # Xrandr for wayland
wl-clipboard # Clipboard manager for wayland
xdg-desktop-portal-hyprland # XDP for hyprland
hyprpicker # Colorpicker, needed for screenshot tool
hyprcursor # Hyprland cursor
inputs.hyprland-contrib.packages.${pkgs.system}.grimblast # Screenshot tool
polkit-kde-agent # Polkit handler
];
# Hyprland screenshot tool
xdg.configFile."hypr-scripts" = {
source = rootPath + "/scripts";
target = "hypr/scripts";
executable = true;
};
xdg.dataFile."hypr-icons" = {
source = rootPath + "/icons";
target = "icons/";
recursive = true;
};
};
}

View file

@ -0,0 +1,48 @@
$mainMod = SUPER
# Exec programs
bind = $mainMod, return, exec, kitty
bind = $mainMod SHIFT, return, exec, rofi -show run
bind = $mainMod, P, exec, grimblast --freeze copy area
bind = $mainMod SHIFT, P, exec, grimblast --freeze copysave area
# Hyprland Management
bind = $mainMod SHIFT, Q, exit,
# Workspace / Monitor Management
bind = $mainMod, h, focusmonitor, l
bind = $mainMod, l, focusmonitor, r
bind = $mainMod, j, cyclenext,
bind = $mainMod, k, cyclenext, prev
bind = $mainMod SHIFT, j, swapnext,
bind = $mainMod SHIFT, k, swapnext, prev
bind = $mainMod SHIFT, h, movecurrentworkspacetomonitor, -1
bind = $mainMod SHIFT, l, movecurrentworkspacetomonitor, +1
bind = $mainMod, 1, exec, $XDG_CONFIG_HOME/hypr/scripts/changeprimary.xsh home
bind = $mainMod, 2, exec, $XDG_CONFIG_HOME/hypr/scripts/changeprimary.xsh web
bind = $mainMod, 3, exec, $XDG_CONFIG_HOME/hypr/scripts/changeprimary.xsh med
bind = $mainMod, 4, exec, $XDG_CONFIG_HOME/hypr/scripts/changeprimary.xsh game
binde = $mainMod, 5, exec, $XDG_CONFIG_HOME/hypr/scripts/changeprimary.xsh etc
binde = $mainMod, _, exec, $XDG_CONFIG_HOME/hypr/scripts/changeprimary.xsh hell
binde = $mainMod, TAB, exec, $XDG_CONFIG_HOME/hypr/scripts/changesecondary.xsh
bind = $mainMod, m, togglespecialworkspace, mus
bind = $mainMod, i, togglespecialworkspace, scratch
# Window Management
bind = $mainMod, C, killactive,
bind = $mainMod, F, togglefloating,
bind = $mainMod SHIFT, F, fullscreen,
bind = $mainMod SHIFT, 1, movetoworkspacesilent, name:home
bind = $mainMod SHIFT, 2, movetoworkspacesilent, name:web
bind = $mainMod SHIFT, 3, movetoworkspacesilent, name:med
bind = $mainMod SHIFT, 4, movetoworkspacesilent, name:misc
bind = $mainMod SHIFT, _, movetoworkspacesilent, name:hell
bind = $mainMod SHIFT, TAB, movetoworkspacesilent, r-1
# Move/resize windows with mainMod + LMB/RMB and dragging
bindm = $mainMod, mouse:272, movewindow
bindm = $mainMod, mouse:273, resizewindow

View file

@ -0,0 +1,25 @@
# no opacity
windowrulev2 = opacity 1 1, class:^(league of legends.exe)$ # loading text
windowrulev2 = opacity 1 override, class:^(leagueclientux.exe)$ # client
windowrulev2 = opacity 1 override, class:^(leagueclient.exe)$ # game
# nice loading text
windowrulev2 = noblur, class:^(leagueclient.exe)$
windowrulev2 = noborder, class:^(leagueclient.exe)$
windowrulev2 = nofocus, class:^(leagueclient.exe)$
windowrulev2 = noshadow, class:^(leagueclient.exe)$
# windowrulev2 = immediate, class:^(league of legends.exe)$
# windowrulev2 = immediate, class:^(overwatch.exe)$
# windowrulev2 = immediate, class:^(steam_app_1384160)$
windowrulev2 = fullscreen, class:^(overwatch.exe)$
windowrulev2 = fullscreen, class:^(steam_app_1384160)$
windowrulev2 = fullscreen, class:^(league of legends.exe)$
# workspaces
windowrule = workspace name:game, leagueclient.exe
windowrule = workspace name:game, leagueclientux.exe
windowrule = workspace name:game, league of legends.exe
windowrule = workspace name:game, overwatch.exe
windowrule = workspace name:game, 東方紅魔郷.exe
windowrule = workspace name:game, steam_app_1384160

View file

@ -0,0 +1,6 @@
# Nivida Settings
env = LIBVA_DRIVER_NAME,nvidia
env = XDG_SESSION_TYPE,wayland
env = GBM_BACKEND,nvidia-drm
env = __GLX_VENDOR_LIBRARY_NAME,nvidia
env = WLR_NO_HARDWARE_CURSORS,1

View file

@ -0,0 +1,27 @@
#!/usr/bin/env xonsh
import shelve
# Usage:
# ./changeprimary.xsh workspace
# changes to that workspace
# if workspace is "etc" then changes to etcN where N is a number
workspace=$ARG1
monitor=$HYPR_MON_PRIMARY
current_workspace = "home"
with shelve.open($HYPR_WORK_DB) as db:
current_workspace = db.get("primary")
if workspace == "etc":
if current_workspace.startswith("etc"):
current = current_workspace[3:] % db.get("primary_extras")
current_workspace = "etc" + str(current)
else:
current_workspace = "etc0"
else:
current_workspace = workspace
db["primary"] = current_workspace
hyprctl dispatch moveworkspacetomonitor name:@(current_workspace) $HYPR_MON_PRIMARY >> /dev/null
hyprctl dispatch workspace name:@(current_workspace) >> /dev/null

View file

@ -0,0 +1,27 @@
#!/usr/bin/env xonsh
import shelve
import copy
# Usage:
# ./changesecondary.xsh
# cycles through the secondary workspaces
current_secondary = "chat"
with shelve.open($HYPR_WORK_DB) as db:
workspaces = db.get("secondaries").copy()
current_primary = db.get("primary")
current_secondary = db.get("secondary")
#extras = db.get("secondary_extras")
if current_primary in workspaces:
workspaces.remove(current_primary)
current_secondary = workspaces[
(workspaces.index(current_secondary)+1) % len(workspaces)
]
db["secondary"] = current_secondary
# Change primary to bind
hyprctl dispatch moveworkspacetomonitor name:@(current_secondary) $HYPR_MON_SECONDARY
hyprctl dispatch workspace name:@(current_secondary)

View file

@ -0,0 +1,13 @@
#!/usr/bin/env xonsh
import shelve
# Usage:
# ./initdb.xsh
# initialize a db for use hypr workspace scripts
with shelve.open($HYPR_WORK_DB) as db:
db["primary"] = "home"
db["secondary"] = "chat"
db["secondaries"] = ["chat", "web", "med"]
db["secondary_extras"] = 1
db["primary_extras"] = 1

View file

@ -0,0 +1,62 @@
# Monitor Settings
monitor=DP-2,2560x1440@60,0x0,1
monitor=DP-1,2560x1440@144,-2560x0,1
monitor=HDMI-A-1,disable
# Inits
exec-once = swww init
exec-once = swww img $HOME/med/pix/bg.png
exec-once = ags
# Settings
input {
kb_layout = us
follow_mouse = 1
accel_profile = flat
sensitivity = -0.52
#sensitivity = 0.2 # -1.0 - 1.0, 0 means no modification.
}
general {
gaps_in = 3
gaps_out = 3
border_size = 2
col.active_border = rgb(F5C2E7)
col.inactive_border = rgb(1E1D2F)
layout = master
}
decoration {
rounding = 2
blur {
enabled = true
size = 12
passes = 2
special = true
}
dim_special = 0.2
}
animations {
enabled = yes
animation = windows, 1, 4, default, popin 50%
animation = windowsOut, 1, 4, default, popin 50%
animation = windowsMove, 1, 3, default
animation = border, 1, 3, default
animation = fade, 1, 3, default
animation = workspaces, 1, 3, default
}
master {
no_gaps_when_only = true
new_is_master = false
mfact = 0.53
}
misc {
focus_on_activate = true
enable_swallow = false
swallow_regex = ^(Alacritty)$
}

View file

@ -0,0 +1,40 @@
env = HYPR_MON_PRIMARY, DP-2
env = HYPR_MON_SECONDARY, DP-1
# Primaries
workspace=name:home, monitor:DP-2, persistent:true, default:true
workspace=name:game, monitor:DP-2, persistent:true
workspace=name:etc0, monitor:DP-2, persistent:true
workspace=name:hell, monitor:DP-2, persistent:true
# Secondaries
workspace=name:chat, monitor:DP-1, persistent:true, default:true
workspace=name:misc0, monitor:DP-1, persistent:true
# Switches
workspace=name:web , monitor:DP-1, persistent:true
workspace=name:med , monitor:DP-1, persistent:true
# Pseudo
workspace=special:mus, persistent:true
workspace=special:scratch, on-created-empty: [float; size 50% 50%; center] kitty
windowrule = workspace name:web, librewolf
windowrulev2 = workspace name:med, librewolf,title:Picture-in-Picture
windowrule = workspace name:chat, discord
windowrule = workspace name:chat, Beeper
windowrule = workspace name:game, lutris
windowrule = workspace name:game, explorer.exe
windowrulev2 = opacity 0.94 fullscreen:0
windowrulev2 = opacity 0.79 override, class:^(Alacritty)$
windowrulev2 = opacity 0.79 override, class:^(kitty)$
windowrulev2 = opacity 1 override, initialTitle:^(Discord Popout)$
windowrulev2 = opacity 1 override, class:^(firefox)$
windowrulev2 = opacity 1 override, class:^(Gimp)$
windowrulev2 = opacity 1 override, class:^(feh)$
windowrulev2 = opacity 1 override, class:^(mpv)$
env = HYPR_WORK_DB,$XDG_CACHE_HOME/hypr/workspace.db
# exec-once = [workspace special:mus silent;float;size 70% 70%;center] mus client
exec-once = [workspace name:chat silent] vesktop
exec-once = [workspace name:chat silent] beeper

View file

@ -0,0 +1,5 @@
windowrulev2 = opacity 0.0 override 0.0 override,class:^(xwaylandvideobridge)$
windowrulev2 = noanim,class:^(xwaylandvideobridge)$
windowrulev2 = noinitialfocus,class:^(xwaylandvideobridge)$
windowrulev2 = maxsize 1 1,class:^(xwaylandvideobridge)$
windowrulev2 = noblur,class:^(xwaylandvideobridge)$