commit f5f1a2b69c64e09cc3ee1133766860b25dedd4b9 Author: Dakedres Date: Thu Jan 25 00:55:35 2024 -0700 Many changes diff --git a/colors/kaolin-dark/default.nix b/colors/kaolin-dark/default.nix new file mode 100644 index 0000000..85b1efd --- /dev/null +++ b/colors/kaolin-dark/default.nix @@ -0,0 +1,93 @@ +# Kaolin-dark scheme by alternateved (http://github.com/alternateved) +# Inspired by (https://github.com/ogdenwebb/emacs-kaolin-themes) + +{ config, ... }: { + custom.colors = { + base00 = "#18181B"; + base01 = "#222225"; + base02 = "#4B5254"; + base03 = "#545C5E"; + base04 = "#879193"; + base05 = "#9ba5a7"; + base06 = "#d0d0d4"; + base07 = "#E4E4E8"; + base08 = "#CD5C60"; + base09 = "#DBAC66"; + base0A = "#F2C866"; + base0B = "#6FB593"; + base0C = "#4D9391"; + base0D = "#91B9C7"; + base0E = "#845A84"; + base0F = "#E36D5B"; + }; + + custom.colors.kitty.enable = false; + programs.kitty.settings = with config.custom.colors; { + ## name: Kaolin Dark + ## author: Ogden Webb + ## license: GNU GPLv3 + ## blurb: Dark jade theme inspired by Sierra.vim. + + # The basic colors + foreground = base07; + background = "#000000"; +# background = base00; + + selection_foreground = base00; + selection_background = base07; + + # Cursor colors + cursor = base07; + cursor_text_color = "#ffffff"; + + # kitty window border colors + active_border_color = base0C; + inactive_border_color = base02; + + # Tab bar colors + active_tab_background = base07; + active_tab_foreground = base00; + inactive_tab_background = base04; + inactive_tab_foreground = base00; + + # black + color0 = base02; + color8 = base04; + + # red + color1 = base08; + color9 = base0F; + + # green + color2 = base0B; + color10 = "#72CCBA"; + + # yellow + color3 = base09; + color11 = base0A; + + # blue + color4 = base0D; + color12 = "#97B8DE"; + + # magenta + color5 = base0E; + color13 = "#8C629C"; + + # cyan + color6 = base0C; + color14 = "#5096AB"; + + # white + color7 = base07; + color15 = "#EFEFF1"; + + # other + color16 = base09; + color17 = base0F; + color18 = base01; + color19 = base02; + color20 = base04; + color21 = base06; + }; +} diff --git a/colors/monokai-dark/default.nix b/colors/monokai-dark/default.nix new file mode 100644 index 0000000..06595fa --- /dev/null +++ b/colors/monokai-dark/default.nix @@ -0,0 +1,20 @@ +{ ... }: { + custom.colors = { + base00 = "#272822"; + base01 = "#383830"; + base02 = "#49483e"; + base03 = "#75715e"; + base04 = "#a59f85"; + base05 = "#f8f8f2"; + base06 = "#f5f4f1"; + base07 = "#f9f8f5"; + base08 = "#f92672"; + base09 = "#fd971f"; + base0A = "#f4bf75"; + base0B = "#a6e22e"; + base0C = "#a1efe4"; + base0D = "#66d9ef"; + base0E = "#ae81ff"; + base0F = "#cc6633"; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..65385a5 --- /dev/null +++ b/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1705708511, + "narHash": "sha256-3f4BkRY70Fj7yvuo87c4QQPAjnt571g2wJ50jY7hnYc=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "ce4b88c465d928f4f8b75d0920f1788d5b65ca94", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1705496572, + "narHash": "sha256-rPIe9G5EBLXdBdn9ilGc0nq082lzQd0xGGe092R/5QE=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "842d9d80cfd4560648c785f8a4e6f3b096790e19", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..3f7a500 --- /dev/null +++ b/flake.nix @@ -0,0 +1,36 @@ +{ + description = "Nixos config flake"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + # newmpkgs = { + # url = "github:EpsilonKu/newm-atha"; + # inputs.nixpkgs.follows = "nixpkgs"; + # }; + }; + + outputs = { self, nixpkgs, ... }@inputs: + let + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + in + { + + nixosConfigurations.default = nixpkgs.lib.nixosSystem { + specialArgs = { + inherit inputs; + }; + modules = [ + ./host/configuration.nix + inputs.home-manager.nixosModules.default + ]; + }; + + }; +} diff --git a/home/default.nix b/home/default.nix new file mode 100644 index 0000000..6a29352 --- /dev/null +++ b/home/default.nix @@ -0,0 +1,103 @@ +{ config, pkgs, inputs, ... }: + +{ + # Home Manager needs a bit of information about you and the paths it should + # manage. + home.username = "dakedres"; + home.homeDirectory = "/home/dakedres"; + + # This value determines the Home Manager release that your configuration is + # compatible with. This helps avoid breakage when a new Home Manager release + # introduces backwards incompatible changes. + # + # You should not change this value, even if you update Home Manager. If you do + # want to update the value, then make sure to first check the Home Manager + # release notes. + home.stateVersion = "23.11"; # Please read the comment before changing. + + nixpkgs.config.allowUnfree = true; + # The home.packages option allows you to install Nix packages into your + # environment. + home.packages = with pkgs; [ + # # It is sometimes useful to fine-tune packages, for example, by applying + # # overrides. You can do that directly here, just don't forget the + # # parentheses. Maybe you want to install Nerd Fonts with a limited number of + # # fonts? + # (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; }) + + # # You can also create simple shell scripts directly inside your + # # configuration. For example, this adds a command 'my-hello' to your + # # environment: + # (pkgs.writeShellScriptBin "my-hello" '' + # echo "Hello, ${config.home.username}!" + # '') + + # Util + neofetch + bitwarden + qutebrowser + discord + + # Visual + imagemagick + kate + + # Audio + ncspot + + # Environment + fishPlugins.grc + ]; + + # Home Manager is pretty good at managing dotfiles. The primary way to manage + # plain files is through 'home.file'. + home.file = { + # # Building this configuration will create a copy of 'dotfiles/screenrc' in + # # the Nix store. Activating the configuration will then make '~/.screenrc' a + # # symlink to the Nix store copy. + # ".screenrc".source = dotfiles/screenrc; + + # # You can also set the file content immediately. + # ".gradle/gradle.properties".text = '' + # org.gradle.console=verbose + # org.gradle.daemon.idletimeout=3600000 + # ''; + }; + + # Home Manager can also manage your environment variables through + # 'home.sessionVariables'. If you don't want to manage your shell through Home + # Manager then you have to manually source 'hm-session-vars.sh' located at + # either + # + # ~/.nix-profile/etc/profile.d/hm-session-vars.sh + # + # or + # + # ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh + # + # or + # + # /etc/profiles/per-user/dakedres/etc/profile.d/hm-session-vars.sh + # + home.sessionVariables = { + # EDITOR = "emacs"; + }; + + programs.fish = { + enable = true; + interactiveShellInit = '' + set fish_greeting # Disable greeting + ''; + shellAliases = { + ll = "ls -lh"; + }; + }; + + programs.kitty = { + enable = true; + shellIntegration.enableFishIntegration = true; + }; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; +} diff --git a/home/newm.nix b/home/newm.nix new file mode 100644 index 0000000..7ad3bc2 --- /dev/null +++ b/home/newm.nix @@ -0,0 +1,7 @@ +{ config, pkgs, inputs, ... }: + +{ + homeManager.home.file = { + "testFile".text = "test"; + }; +} diff --git a/host/configuration.nix b/host/configuration.nix new file mode 100644 index 0000000..d91e819 --- /dev/null +++ b/host/configuration.nix @@ -0,0 +1,144 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page +# and in the NixOS manual (accessible by running ‘nixos-help’). + +{ config, pkgs, inputs, ... }: + +let + username = "dakedres"; +in { + custom.username = username; + + imports = [ + # Include the results of the hardware scan. + ./hardware-configuration.nix + inputs.home-manager.nixosModules.default + ./user.nix + ]; + + users.users.${username} = { + isNormalUser = true; + description = "Dakedres"; + extraGroups = [ "networkmanager" "wheel" ]; + shell = pkgs.fish; + }; + + # We live in a society + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + # That's what it's called + networking.hostName = "vulpes"; + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # I don't need no fig leaves + security.sudo.wheelNeedsPassword = false; + + # Configure network proxy if necessary + # networking.proxy.default = "http://user:password@proxy:port/"; + # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + + # Enable networking + networking.networkmanager.enable = true; + + # Set your time zone. + time.timeZone = "America/Boise"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + i18n.extraLocaleSettings = { + LC_ADDRESS = "en_US.UTF-8"; + LC_IDENTIFICATION = "en_US.UTF-8"; + LC_MEASUREMENT = "en_US.UTF-8"; + LC_MONETARY = "en_US.UTF-8"; + LC_NAME = "en_US.UTF-8"; + LC_NUMERIC = "en_US.UTF-8"; + LC_PAPER = "en_US.UTF-8"; + LC_TELEPHONE = "en_US.UTF-8"; + LC_TIME = "en_US.UTF-8"; + }; + + # Enable the X11 windowing system. + services.xserver.enable = true; + + # Enable the KDE Plasma Desktop Environment. + services.xserver.displayManager.sddm.enable = true; + services.xserver.desktopManager.plasma5.enable = true; + + # Configure keymap in X11 + services.xserver = { + layout = "us"; + xkb.options = "caps:swapescape,altwin:swap_alt_win"; + }; + + # Enable CUPS to print documents. + services.printing.enable = true; + + # Enable bluetooth + hardware.bluetooth.enable = true; + hardware.bluetooth.powerOnBoot = true; + + # Enable sound with pipewire. + sound.enable = true; + hardware.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + # If you want to use JACK applications, uncomment this + #jack.enable = true; + + # use the example session manager (no others are packaged yet so this is enabled by default, + # no need to redefine it in your config for now) + #media-session.enable = true; + }; + + # Enable touchpad support (enabled default in most desktopManager). + # services.xserver.libinput.enable = true; + + services.flatpak.enable = true; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + # vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. + git + wget + micro + openconnect + btop + ]; + + # Some programs need SUID wrappers, can be configured further or are + # started in user sessions. + # programs.mtr.enable = true; + # programs.gnupg.agent = { + # enable = true; + # enableSSHSupport = true; + # }; + + # List services that you want to enable: + + # Enable the OpenSSH daemon. + # services.openssh.enable = true; + + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "23.11"; # Did you read the comment? + +} diff --git a/host/hardware-configuration.nix b/host/hardware-configuration.nix new file mode 100644 index 0000000..6c6d5cc --- /dev/null +++ b/host/hardware-configuration.nix @@ -0,0 +1,39 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/81248e4c-95cf-4427-9df1-57f39b62a5a3"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/E50D-8471"; + fsType = "vfat"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/25b9170e-c60a-49c1-929a-0fe6fc1e15ea"; } + ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp2s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/host/home.nix b/host/home.nix new file mode 100644 index 0000000..f218d42 --- /dev/null +++ b/host/home.nix @@ -0,0 +1,112 @@ +{ pkgs, lib, ... }: + +let + +terminal = "kitty"; +# newm = inputs.newmpkgs.packages.${system}.newm-atha; + +packages = [ + # Utility + pkgs.bitwarden + pkgs.vimiv-qt + + # Visual + pkgs.imagemagick + pkgs.kate + + #Games + pkgs.prismlauncher-qt5 + + # Env + pkgs.eww-wayland + pkgs.socat + pkgs.jq +]; + +nonFreePackages = [ + "discord" +]; + +in { + imports = [ ../colors/monokai-dark ]; + custom.wallpaper = ../wallpapers/blip-blip-blip-blip.jpg; + + home = { + sessionVariables = { + EDITOR = "kate"; + BROWSER = "qutebrowser"; + TERMINAL = "kitty"; + TERM = "kitty"; + FILEMANAGER = "kitty lf"; + + # Tell Electron apps it's wayland + NIXOS_OZONE_WL = 1; + }; + + sessionPath = [ + "$HOME/.local/bin" + ]; + + stateVersion = "23.11"; + }; + + # Add packages + nixpkgs.config.allowUnfreePredicate = pkg: + builtins.elem (lib.getName pkg) nonFreePackages; + + home.packages = + map (name: pkgs.${name}) nonFreePackages + ++ packages; + + xdg.mimeApps = { + enable = true; + }; + + # Directories + xdg.userDirs = { + createDirectories = false; + download = "$HOME/downloads"; + music = "$HOME/music"; + }; + + # Openers + xdg.mimeApps.defaultApplications = { + "inode/directory" = [ + # "lf.desktop" + "kitty-open.desktop" + ]; + }; + + # Standard programs + programs.bat = { + enable = true; + config = { + paging = "never"; + }; + }; + + # lf + programs.lf = { + enable = true; + commands = { + q = "quit"; # Why didn't they do this btw + }; + keybindings = { + "" = "$$OPENER $f"; + }; + }; + + xdg.desktopEntries.lf = { + name = "LF"; + genericName = "File browser"; + exec = "lf %U"; + terminal = true; + mimeType = [ "inode/directory" ]; + }; + + # Take over my xsession + xsession.enable = true; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; +} diff --git a/host/homeOptions.nix b/host/homeOptions.nix new file mode 100644 index 0000000..2005e50 --- /dev/null +++ b/host/homeOptions.nix @@ -0,0 +1,33 @@ +{ lib, ... }: { + options.custom = { + wallpaper = lib.mkOption { + type = lib.types.path; + }; + + colors = + let + colorOption = lib.mkOption { + type = lib.types.str; + default = "#000000"; + }; + in + { + base00 = colorOption; + base01 = colorOption; + base02 = colorOption; + base03 = colorOption; + base04 = colorOption; + base05 = colorOption; + base06 = colorOption; + base07 = colorOption; + base08 = colorOption; + base09 = colorOption; + base0A = colorOption; + base0B = colorOption; + base0C = colorOption; + base0D = colorOption; + base0E = colorOption; + base0F = colorOption; + }; + }; +} diff --git a/host/modules.nix b/host/modules.nix new file mode 100644 index 0000000..c6ca234 --- /dev/null +++ b/host/modules.nix @@ -0,0 +1,10 @@ +[ + ../modules/fish + ../modules/qutebrowser + ../modules/kitty + + ../modules/ncspot + + ../modules/bspwm + ../modules/blueman +] diff --git a/host/swhkdrc b/host/swhkdrc new file mode 100644 index 0000000..6a8094f --- /dev/null +++ b/host/swhkdrc @@ -0,0 +1,176 @@ +# +# wm independent hotkeys +# + +# Open kitty +alt + Return + kitty + +# Open floating kitty +alt + shift + Return + bsp-float kitty + +# launch program +alt + @space + rofi -show run + +# launch program as root +alt + shift + @space + rofi-ask rofi -show drun -run-command "sudo -A {cmd}" + +# make sxhkd reload its configuration files: +alt + Escape + pkill -USR1 -x sxhkd; notify-send 'Key daemon reloaded' + +# Start a qutebrowser search +alt + o + qutesearch + +# Show keybinds +alt + slash + sxhkd-help + +# Show clipmenu +alt + v + rofi -modi "clipboard:greenclip print" -show clipboard -run-command '{cmd}' + +alt + shift + v + greenclip clear + +# +# bspwm hotkeys +# + +# quit/restart bspwm +alt + shift + {q,r} + bspc {quit,wm -r} + +# close and kill +alt + {_,shift + }w + bspc node -{c,k} + +alt + q + bspc node -c + +# alternate between the tiled and monocle layout +alt + m + bspc desktop -l next + +# send the newest marked node to the newest preselected node +alt + y + bspc node newest.marked.local -n newest.!automatic.local + +# swap the current node and the biggest window +alt + g + bspc node -s biggest.window + +# Reveal hidden kitty (scratchpad) +alt + super + Return + bsp-toggle-visibility KittyScratch "kitty --class KittyScratch" + +# flameshot +alt + Print + flameshot gui + +# +# state/flags +# + +# set the window state +alt + {z,shift + z,x,f} + bspc node -t {tiled,pseudo_tiled,floating,fullscreen} + +# set the node flags +alt + ctrl + {m,x,y,z} + bspc node -g {marked,locked,sticky,private} + +# +# focus/swap +# + +# focus the node in the given direction +alt + {h,j,k,l,Left,Down,Up,Right} + bspc node -{f} {west,south,north,east,west,south,north,east} + +# focus the node for the given path jump +alt + {p,b,comma,period} + bspc node -f @{parent,brother,first,second} + +# focus the next/previous window in the current desktop +alt + {a,d} + bspc node -f {next,prev}.local.!hidden.window + +# focus the next/previous desktop in the current monitor +alt + bracket{left,right} + bspc desktop -f {prev,next}.local + +# focus the last node/desktop +alt + {grave,Tab} + bspc {node,desktop} -f last + +# focus the older or newer node in the focus history +alt + {o,i} + bspc wm -h off; \ + bspc node {older,newer} -f; \ + bspc wm -h on + +# focus or send to the given desktop +alt + {_,shift + }{1-9,0} + bspc {desktop -f,node -d} '^{1-9,10}' + +# +# preselect +# + +# preselect the direction +alt + ctrl + shift {h,j,k,l,Left,Down,Up,Right} + bspc node -p {west,south,north,east,west,south,north,east} + +# preselect the ratio +alt + ctrl + {1-9} + bspc node -o 0.{1-9} + +# cancel the preselection for the focused node +alt + ctrl + space + bspc node -p cancel + +# cancel the preselection for the focused desktop +alt + ctrl + shift + space + bspc query -N -d | xargs -I id -n 1 bspc node id -p cancel + +# +# move/resize +# + +# Resize a window by moving one of its side outward/inward +alt + s ; {h,j,k,l,Left,Down,Up,Right} + STEP=20; SELECTION={1,2,3,4,1,2,3,4}; \ + bspc node -z $(echo "left -$STEP 0,bottom 0 $STEP,top 0 -$STEP,right $STEP 0" | cut -d',' -f$SELECTION) || \ + bspc node -z $(echo "right -$STEP 0,top 0 $STEP,bottom 0 -$STEP,left $STEP 0" | cut -d',' -f$SELECTION) + +# move a floating window +alt + {h,j,k,l} + bspc node -v {-30 0,0 20,0 -30,20 0} + +# move a not-floating window +alt + shift + {h,j,k,l,Left,Down,Up,Right} + bsp-smove {west,south,north,east,west,south,north,east} + +# +# tabs +# + +# move in/out of tabbed container +alt + ctrl + {h,j,k,l,Left,Down,Up,Right} + tabc-smart-detach {west,south,north,east,west,south,north,east} + +# tab/untab window +alt + t + id=$(bspc query -N -n); \ + [[ "$(tabc printclass $id)" == "tabbed" ]] \ + && tabc detach $id \ + || tabc create $id + +# toggle autoattach in tabbed container +alt + shift + t + tabc autoattach $(bspc query -N -n) diff --git a/host/user.nix b/host/user.nix new file mode 100644 index 0000000..9a2ce0c --- /dev/null +++ b/host/user.nix @@ -0,0 +1,41 @@ +{ config, lib, inputs, ... }: + +let + modules = import ./modules.nix; + username = config.custom.username; +in { + options.custom = { + username = lib.mkOption { + type = lib.types.str; + default = "dakedres"; + }; + }; + + config.home-manager.users."${username}" = { + imports = + (builtins.filter + (path: builtins.pathExists path) + (builtins.map + (path: path + "/home.nix") + modules + ) + ) ++ [ + ./home.nix + ./homeOptions.nix + ]; + + config.home = { + username = username; + homeDirectory = "/home/${username}"; + }; + }; + + imports = + (builtins.filter + (path: builtins.pathExists path) + (builtins.map + (path: path + "/default.nix") + modules + ) + ); +} diff --git a/modules/blueman/default.nix b/modules/blueman/default.nix new file mode 100644 index 0000000..e09abc7 --- /dev/null +++ b/modules/blueman/default.nix @@ -0,0 +1,3 @@ +{ ... }: { + services.blueman.enable = true; +} diff --git a/modules/blueman/home.nix b/modules/blueman/home.nix new file mode 100644 index 0000000..ca8f48e --- /dev/null +++ b/modules/blueman/home.nix @@ -0,0 +1,3 @@ +{ ... }: { + services.blueman-applet.enable = true; +} diff --git a/modules/bspwm/default.nix b/modules/bspwm/default.nix new file mode 100644 index 0000000..01150ea --- /dev/null +++ b/modules/bspwm/default.nix @@ -0,0 +1,3 @@ +{ ... }: { + services.xserver.windowManager.bspwm.enable = true; +} diff --git a/modules/bspwm/home.nix b/modules/bspwm/home.nix new file mode 100644 index 0000000..7e22cf0 --- /dev/null +++ b/modules/bspwm/home.nix @@ -0,0 +1,77 @@ +{ pkgs, lib, config, ... }: { + imports = [ + ../qutesearch/home.nix + ../tint2/home.nix + ../rofi/home.nix + ]; + + home.packages = [ + pkgs.feh + pkgs.flameshot + ]; + + services.network-manager-applet.enable = true; + + xdg.portal = { + enable = true; + extraPortals = [ + pkgs.xdg-desktop-portal-kde + ]; + configPackages = [ + pkgs.xdg-desktop-portal-kde + ]; + }; + + # handled by home manager + # home.sessionVariables = { + # # Tell java it's in no-reparenting land + # "_JAVA_AWT_WM_NONREPARENTING" = 1; + # }; + + services.sxhkd.enable = true; + xdg.configFile."sxhkd/sxhkdrc" = { + source = ./sxhkdrc; + executable = true; + }; + + home.file.".local/bin" = { + source = ./scripts; + recursive = true; + executable = true; + }; + + xsession.windowManager.bspwm = { + enable = true; + + monitors = { + "eDP-1" = [ "I" "II" "III" "IV" "V" ]; + }; + + settings = { + border_width = 1; + window_gap = 4; + split_ratio = 0.52; + + pointer_modifier = "super"; + pointer_action1 = "move"; + pointer_action2 = "resize_corner"; + + focus_follows_pointer = true; + pointer_follows_focus = true; + }; + + rules = { + Gimp = { + state = "floating"; + }; + }; + + startupPrograms = [ + # "pgrep -x sxhkd > /dev/null || sxhkd &" + "wmname LG3D" + # "xsetroot -cursor_name left_ptr &" + "tint2" + "feh --bg-scale ${config.custom.wallpaper}" + ]; + }; +} diff --git a/modules/bspwm/scripts/bsp-float b/modules/bspwm/scripts/bsp-float new file mode 100755 index 0000000..cab6adf --- /dev/null +++ b/modules/bspwm/scripts/bsp-float @@ -0,0 +1,3 @@ +#!/bin/sh +# Open an app in float mode +bspc rule -a \* -o state=floating && $@ diff --git a/modules/bspwm/scripts/bsp-floating-only b/modules/bspwm/scripts/bsp-floating-only new file mode 100755 index 0000000..026d07f --- /dev/null +++ b/modules/bspwm/scripts/bsp-floating-only @@ -0,0 +1,14 @@ +#!/bin/sh + +if [ ! -z $1 ]; then +# FLOATING_DESKTOP_ID=$(bspc query -D -d '^3') + FLOATING_DESKTOP_ID=$1 + + bspc subscribe node_add | while read -a msg ; do + desk_id=${msg[2]} + wid=${msg[4]} + [ "$FLOATING_DESKTOP_ID" = "$desk_id" ] && bspc node "$wid" -t floating + done +else + echo "No desktop provided" +fi diff --git a/modules/bspwm/scripts/bsp-smove b/modules/bspwm/scripts/bsp-smove new file mode 100755 index 0000000..a05fc00 --- /dev/null +++ b/modules/bspwm/scripts/bsp-smove @@ -0,0 +1,60 @@ +#!/bin/sh + +# A more fluid way of moving windows with BSPWM, which is meant to be +# implemented in SXHKD. If there is a window in the given direction, +# swap places with it. Else if there is a receptacle move to it +# ("consume" its place). Otherwise create a receptacle in the given +# direction by splitting the entire viewport (circumvents the tiling +# scheme while respecting the current split ratio configuration). In +# the latter scenario, inputting the direction twice will thus move the +# focused window out of its current layout and into the receptacle. +# +# Part of my dotfiles: https://gitlab.com/protesilaos/dotfiles +# +# Copyright (c) 2019 Protesilaos Stavrou +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +[ "$#" -eq 1 ] || { echo "Pass only one argument: north,east,south,west"; exit 1; } + +# Check if argument is a valid direction. +case "$1" in + north|east|south|west) + dir="$1" + ;; + *) + echo "Not a valid argument." + echo "Use one of: north,east,south,west" + exit 1 + ;; +esac + +_query_nodes() { + bspc query -N -n "$@" +} + +# Do not operate on floating windows! +[ -z "$(_query_nodes focused.floating)" ] || { echo "Only move tiled windows."; exit 1; } + +receptacle="$(_query_nodes 'any.leaf.!window')" + +# This regulates the behaviour documented in the description. +if [ -n "$(_query_nodes "${dir}.!floating")" ]; then + bspc node -s "$dir" +elif [ -n "$receptacle" ]; then + bspc node focused -n "$receptacle" --follow +else + bspc node @/ -p "$dir" -i && bspc node -n "$receptacle" --follow +fi diff --git a/modules/bspwm/scripts/bsp-status b/modules/bspwm/scripts/bsp-status new file mode 100755 index 0000000..de0dbd3 --- /dev/null +++ b/modules/bspwm/scripts/bsp-status @@ -0,0 +1,17 @@ +#!/bin/sh + +declare -A layout_symbols + +layout_symbols[monocle]="mono" +layout_symbols[tiled]="tiled" + +send_symbol() { + echo ${layout_symbols[$1]} +} + +# Optional, sends first output. This requires jq +send_symbol $(bspc query -T --desktop focused | jq -r '.layout') + +bspc subscribe desktop_layout | while read -a msg ; do + send_symbol ${msg[3]} +done diff --git a/modules/bspwm/scripts/bsp-toggle-visibility b/modules/bspwm/scripts/bsp-toggle-visibility new file mode 100755 index 0000000..1fba993 --- /dev/null +++ b/modules/bspwm/scripts/bsp-toggle-visibility @@ -0,0 +1,37 @@ +#!/bin/bash + +if [ $# = 0 ]; then + cat <