From ce9124c7edca2f52c128cc27ff7ef619fe03cb1a Mon Sep 17 00:00:00 2001 From: JuliaLange Date: Sat, 20 Jan 2024 14:03:54 -0800 Subject: [PATCH] Move to Xonsh, add hypr scripts --- flake.lock | 61 ++++++++++++++++------- home.nix | 9 ++++ programs/git/default.nix | 4 +- programs/hypr/default.conf | 32 +++++++++++- programs/hypr/default.nix | 9 +++- programs/hypr/keybinds.conf | 39 ++++++--------- programs/hypr/scripts/changeprimary.xsh | 27 ++++++++++ programs/hypr/scripts/changesecondary.xsh | 27 ++++++++++ programs/hypr/scripts/initdb.xsh | 13 +++++ programs/lutris/default.nix | 16 ++++++ programs/spotify/default.nix | 18 +++++++ programs/xdg/default.nix | 2 + programs/xonsh/default.nix | 15 ++++++ 13 files changed, 224 insertions(+), 48 deletions(-) create mode 100755 programs/hypr/scripts/changeprimary.xsh create mode 100755 programs/hypr/scripts/changesecondary.xsh create mode 100755 programs/hypr/scripts/initdb.xsh create mode 100644 programs/lutris/default.nix create mode 100644 programs/spotify/default.nix create mode 100644 programs/xonsh/default.nix diff --git a/flake.lock b/flake.lock index 4336bb3..d1e7624 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1700013383, - "narHash": "sha256-ZBhrew3BrUEv48i+3Mp2pDjLU6dcue8BKMz6tCDSyfc=", + "lastModified": 1701728041, + "narHash": "sha256-x0pyrI1vC8evVDxCxyO6olOyr4wlFg9+VS3C3p4xFYQ=", "owner": "langedev", "repo": "home-manager", - "rev": "6498661f3856a685c4fa7a19d0f8cbe17c08d8bd", + "rev": "ac7216918cd65f3824ba7817dea8f22e61221eaf", "type": "github" }, "original": { @@ -29,11 +29,11 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1700397206, - "narHash": "sha256-ityVJcy3I/E8soXctwWveg58+cXOSQXhDIcU6YR2gjI=", + "lastModified": 1705782792, + "narHash": "sha256-AnNvfQK3BQtri7JUmTsaAWAOBzCxEf5t3VaGm0Kezjk=", "owner": "hyprwm", "repo": "Hyprland", - "rev": "646f4bc63861e03b01fed3833bb65d1d014e1bf3", + "rev": "4d403dac3244aab217fb9bf17a68e9a009fcadd8", "type": "github" }, "original": { @@ -67,13 +67,35 @@ "type": "github" } }, + "hyprlang": { + "inputs": { + "nixpkgs": [ + "hyprland", + "xdph", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1704287638, + "narHash": "sha256-TuRXJGwtK440AXQNl5eiqmQqY4LZ/9+z/R7xC0ie3iA=", + "owner": "hyprwm", + "repo": "hyprlang", + "rev": "6624f2bb66d4d27975766e81f77174adbe58ec97", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprlang", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1698134075, - "narHash": "sha256-foCD+nuKzfh49bIoiCBur4+Fx1nozo+4C/6k8BYk4sg=", + "lastModified": 1705133751, + "narHash": "sha256-rCIsyE80jgiOU78gCWN3A0wE0tR2GI5nH6MlS+HaaSQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "8efd5d1e283604f75a808a20e6cde0ef313d07d4", + "rev": "9b19f5e77dd906cb52dade0b7bd280339d2a1f3d", "type": "github" }, "original": { @@ -85,11 +107,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1699825797, - "narHash": "sha256-W2m42mVt4/O6CJFbECPfLApmi8bO+qscbmSeEKrSHEg=", + "lastModified": 1701902328, + "narHash": "sha256-3tiiSEgQRPps0aV40belvLk1k4Max7oRh/+hZGLtfGc=", "owner": "langedev", "repo": "nixpkgs", - "rev": "a69768a1c385042d46ff57396c49d26df5ac035c", + "rev": "162f092c27afe0949253753f088c2babfba5b902", "type": "github" }, "original": { @@ -125,18 +147,18 @@ "flake": false, "locked": { "host": "gitlab.freedesktop.org", - "lastModified": 1699292815, - "narHash": "sha256-HXu98PyBMKEWLqiTb8viuLDznud/SdkdJsx5A5CWx7I=", + "lastModified": 1703963193, + "narHash": "sha256-ke8drv6PTrdQDruWbajrRJffP9A9PU6FRyjJGNZRTs4=", "owner": "wlroots", "repo": "wlroots", - "rev": "5de9e1a99d6642c2d09d589aa37ff0a8945dcee1", + "rev": "f81c3d93cd6f61b20ae784297679283438def8df", "type": "gitlab" }, "original": { "host": "gitlab.freedesktop.org", "owner": "wlroots", "repo": "wlroots", - "rev": "5de9e1a99d6642c2d09d589aa37ff0a8945dcee1", + "rev": "f81c3d93cd6f61b20ae784297679283438def8df", "type": "gitlab" } }, @@ -146,6 +168,7 @@ "hyprland", "hyprland-protocols" ], + "hyprlang": "hyprlang", "nixpkgs": [ "hyprland", "nixpkgs" @@ -156,11 +179,11 @@ ] }, "locked": { - "lastModified": 1697981233, - "narHash": "sha256-y8q4XUwx+gVK7i2eLjfR32lVo7TYvEslyzrmzYEaPZU=", + "lastModified": 1704659450, + "narHash": "sha256-3lyoUVtUWz1LuxbltAtkJSK2IlVXmKhxCRU2/0PYCms=", "owner": "hyprwm", "repo": "xdg-desktop-portal-hyprland", - "rev": "22e7a65ff9633e1dedfa5317fdffc49f68de2ff2", + "rev": "6a5de92769d5b7038134044053f90e7458f6a197", "type": "github" }, "original": { diff --git a/home.nix b/home.nix index 11310c2..254d4fb 100644 --- a/home.nix +++ b/home.nix @@ -12,11 +12,13 @@ ./programs/fish ./programs/git ./programs/hypr + ./programs/lutris ./programs/mpv ./programs/nnn ./programs/nvim ./programs/pywal ./programs/rofi + ./programs/spotify ./programs/ssh ./programs/xdg ]; @@ -32,6 +34,9 @@ appimage-run # Lets you run app images zathura # PDF viewer ani-cli # Easy anime player + lutgen # LUT generator + + texlive.combined.scheme-full # Latex # Development stuff nodejs # For compiling JS stuff @@ -45,6 +50,10 @@ BROWSER = "librewolf"; }; + home.sessionPath = [ + "$HOME/prog/scripts" + ]; + # Enable man pages, but ensure ~/.manpage isn't created programs.man.enable = true; programs.man.generateCaches = false; diff --git a/programs/git/default.nix b/programs/git/default.nix index 107376d..9f134ee 100644 --- a/programs/git/default.nix +++ b/programs/git/default.nix @@ -2,8 +2,8 @@ { programs.git.enable = true; - programs.git.userName = "langedev"; - programs.git.userEmail = "public@daltonlange.com"; + programs.git.userName = "JuliaLange"; + programs.git.userEmail = "git@julialange.com"; programs.git.extraConfig = { safe = { directory = "/etc/nixos"; diff --git a/programs/hypr/default.conf b/programs/hypr/default.conf index 4b1dc22..d92465d 100644 --- a/programs/hypr/default.conf +++ b/programs/hypr/default.conf @@ -1,5 +1,32 @@ -monitor=,preferred,auto,1 +monitor=DP-2,2560x1440@144,0x0,1 +monitor=DP-1,2560x1440@144,-2560x0,1 monitor=HDMI-A-1,disable +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 +# 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 + +windowrule = workspace name:web, librewolf +windowrulev2 = workspace name:med, librewolf,title:Picture-in-Picture +windowrule = workspace name:chat, discord + +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 + +env = HYPR_WORK_DB,$XDG_CACHE_HOME/hypr/workspace.db +exec-once = $XDG_CONFIG_HOME/hypr/scripts/changesecondary.xsh exec-once = swww init exec-once = swww img $HOME/med/pix/bg.png @@ -8,7 +35,8 @@ input { kb_layout = us follow_mouse = 1 accel_profile = flat - sensitivity = 0.2 # -1.0 - 1.0, 0 means no modification. + sensitivity = -0.52 + #sensitivity = 0.2 # -1.0 - 1.0, 0 means no modification. } general { diff --git a/programs/hypr/default.nix b/programs/hypr/default.nix index 8fc5589..e1234a3 100644 --- a/programs/hypr/default.nix +++ b/programs/hypr/default.nix @@ -1,14 +1,21 @@ { config, pkgs, ... }: - +let rootPath = ./.; in { wayland.windowManager.hyprland.enable = true; wayland.windowManager.hyprland.extraConfig = '' ${builtins.readFile ./default.conf} ${builtins.readFile ./keybinds.conf} ''; + # wayland.windowManager.hyprland.enableNvidiaPatches = true; home.packages = with pkgs; [ socat # For hyprland scripts swww # Wallpaper engine wlr-randr # Xrandr for wayland + xdg-desktop-portal-hyprland # XDP for hyprland ]; + xdg.configFile."hypr-scripts" = { + source = rootPath + "/scripts"; + target = "hypr/scripts"; + executable = true; + }; } diff --git a/programs/hypr/keybinds.conf b/programs/hypr/keybinds.conf index 4ed1c58..ab4d5a0 100644 --- a/programs/hypr/keybinds.conf +++ b/programs/hypr/keybinds.conf @@ -3,30 +3,26 @@ $mainMod = SUPER # Exec programs bind = $mainMod, return, exec, alacritty bind = $mainMod SHIFT, return, exec, rofi -show run -# bind = $mainMod SHIFT, P, exec, screenshot # Hyprland Management bind = $mainMod SHIFT, Q, exit, -# Bars stuff -bind = $mainMod, TAB, exec, eww open --toggle - # 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, workspace, 1 -bind = $mainMod, 2, workspace, 2 -bind = $mainMod, 3, workspace, 3 -bind = $mainMod, 4, workspace, 4 -bind = $mainMod, 5, workspace, 5 -bind = $mainMod, 6, workspace, 6 -bind = $mainMod, 7, workspace, 7 -bind = $mainMod, 8, workspace, 8 -bind = $mainMod, 9, workspace, 9 -bind = $mainMod, 0, workspace, 10 +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, TAB, exec, $XDG_CONFIG_HOME/hypr/scripts/changesecondary.xsh # Window Management bind = $mainMod, C, killactive, @@ -34,16 +30,11 @@ bind = $mainMod, C, killactive, bind = $mainMod, F, togglefloating, bind = $mainMod SHIFT, F, fullscreen, -bind = $mainMod SHIFT, 1, movetoworkspacesilent, 1 -bind = $mainMod SHIFT, 2, movetoworkspacesilent, 2 -bind = $mainMod SHIFT, 3, movetoworkspacesilent, 3 -bind = $mainMod SHIFT, 4, movetoworkspacesilent, 4 -bind = $mainMod SHIFT, 5, movetoworkspacesilent, 5 -bind = $mainMod SHIFT, 6, movetoworkspacesilent, 6 -bind = $mainMod SHIFT, 7, movetoworkspacesilent, 7 -bind = $mainMod SHIFT, 8, movetoworkspacesilent, 8 -bind = $mainMod SHIFT, 9, movetoworkspacesilent, 9 -bind = $mainMod SHIFT, 0, movetoworkspacesilent, 10 +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, TAB, movetoworkspacesilent, r-1 # Move/resize windows with mainMod + LMB/RMB and dragging bindm = $mainMod, mouse:272, movewindow diff --git a/programs/hypr/scripts/changeprimary.xsh b/programs/hypr/scripts/changeprimary.xsh new file mode 100755 index 0000000..9b7e0e7 --- /dev/null +++ b/programs/hypr/scripts/changeprimary.xsh @@ -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 diff --git a/programs/hypr/scripts/changesecondary.xsh b/programs/hypr/scripts/changesecondary.xsh new file mode 100755 index 0000000..b4cfdf9 --- /dev/null +++ b/programs/hypr/scripts/changesecondary.xsh @@ -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) diff --git a/programs/hypr/scripts/initdb.xsh b/programs/hypr/scripts/initdb.xsh new file mode 100755 index 0000000..8e7af93 --- /dev/null +++ b/programs/hypr/scripts/initdb.xsh @@ -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"] + db["secondary_extras"] = 1 + db["primary_extras"] = 1 diff --git a/programs/lutris/default.nix b/programs/lutris/default.nix new file mode 100644 index 0000000..05993cd --- /dev/null +++ b/programs/lutris/default.nix @@ -0,0 +1,16 @@ +{ config, pkgs, ... }: + +{ + home.packages = with pkgs; [ + lutris + wineWowPackages.stable + # (lutris.override { + # extraLibraries = pkgs: [ + # # List library dependencies here + # ]; + # extraPkgs = pkgs: [ + # # List package dependencies here + # ]; + # }) + ]; +} diff --git a/programs/spotify/default.nix b/programs/spotify/default.nix new file mode 100644 index 0000000..7510db3 --- /dev/null +++ b/programs/spotify/default.nix @@ -0,0 +1,18 @@ +{ config, pkgs, ... }: + +{ + services.spotifyd.enable = true; + services.spotifyd.settings = { + global = { + username = "me@daltonlange.com"; + password = "5ThM^G3!FTfH6rH#cJEx"; + backend = "pulseaudio"; + device_name = "onizuka"; + bitrate = 320; + }; + }; + + home.packages = with pkgs; [ + spotify-tui # Spotify TUI player + ]; +} diff --git a/programs/xdg/default.nix b/programs/xdg/default.nix index 835b5fa..81a7a84 100644 --- a/programs/xdg/default.nix +++ b/programs/xdg/default.nix @@ -13,4 +13,6 @@ pictures = "${config.home.homeDirectory}/med/pix"; videos = "${config.home.homeDirectory}/med/vid"; }; + + xdg.mimeApps.enable = true; } diff --git a/programs/xonsh/default.nix b/programs/xonsh/default.nix new file mode 100644 index 0000000..3dd83ce --- /dev/null +++ b/programs/xonsh/default.nix @@ -0,0 +1,15 @@ +{ config, pkgs, ... }: + +{ + programs.xonsh.enable = true; + + programs.xonsh.interactiveShellInit = '' + cat ~/.cache/wal/sequences + ''; + + home.sessionVariables = { + PROMPT = "τ "; + RIGHT_PROMPT = "{YELLOW}{gitstatus: {} }{BLUE}{short_cwd}{DEFAULT}"; + VI_MODE = 1; + }; +}