diff --git a/home/hyprland/hypridle.conf b/home/hyprland/hypridle.conf new file mode 100644 index 0000000..f41c1ed --- /dev/null +++ b/home/hyprland/hypridle.conf @@ -0,0 +1,19 @@ +general { + lock_cmd = hyprlock # dbus/sysd lock command (loginctl lock-session) + # unlock_cmd = notify-send "unlock!" # same as above, but unlock + before_sleep_cmd = hyprlock # command ran before sleep + # after_sleep_cmd = # command ran after sleep + ignore_dbus_inhibit = false # whether to ignore dbus-sent idle-inhibit requests (used by e.g. firefox or steam) +} + +listener { + timeout = 240 # in seconds + on-timeout = hyprlock # command to run when timeout has passed + # on-resume = notify-send "Welcome back!" # command to run when activity is detected after timeout has fired. +} + +listener { + timeout = 900 + on-timeout = systemctl suspend # command to run when timeout has passed + # on-resume = notify-send "Welcome back!" # command to run when activity is detected after timeout has fired. +} diff --git a/home/hyprland/hypridle.nix b/home/hyprland/hypridle.nix new file mode 100644 index 0000000..307f589 --- /dev/null +++ b/home/hyprland/hypridle.nix @@ -0,0 +1,12 @@ +{ config, pkgs, ... }: { + + home.packages = with pkgs; [ + unstable.hypridle + ]; + xdg.configFile = { + "hypr/hypridle.conf" = { + source = config.lib.file.mkOutOfStoreSymlink ./. + "/hypridle.conf"; + target = "hypr/hypridle.conf"; + }; + }; +} diff --git a/home/hyprland/hyprland_magicman.nix b/home/hyprland/hyprland_magicman.nix index 51c3ae1..020144f 100644 --- a/home/hyprland/hyprland_magicman.nix +++ b/home/hyprland/hyprland_magicman.nix @@ -1,4 +1,8 @@ { inputs, pkgs, lib, config, ... }: { + imports = [ + ./hyprlock.nix + ./hypridle.nix + ]; options.hyprland.enable = lib.mkEnableOption "Hyprland"; config = { home.packages = with pkgs; [ @@ -104,6 +108,9 @@ "$mainMod,D,exec,rofi-launcher" "$mainMod,P,exec,rofi-rbw" + # hyprlock + "$shiftMainMod,l,exec,hyprlock" + # hyprland "$mainMod,Q,killactive," "CTRLALT,Delete,exit," @@ -129,11 +136,11 @@ # ",code:202,exec,mumble rpc starttalking" #",code:202,pass,^(info\.mumble\.Mumble)$" # ",code:202,exec,pamixer --default-source -u" - ",code:202,pass,^discord$" + # ",code:202,pass,^discord$" # worspace switching - "$mainMod,1,workspace,name:main 1" - "$mainMod,2,workspace,name:main 2" + "$mainMod,1,workspace,1" + "$mainMod,2,workspace,2" "$mainMod,3,workspace,3" "$mainMod,4,workspace,4" "$mainMod,5,workspace,5" @@ -143,7 +150,7 @@ exec-once = [ "waybar" "hyprpaper & sleep 2 && randomwp" - "easyeffects --gapplication-service" + "hypridle" # "dunst" ]; }; diff --git a/home/hyprland/hyprlock.conf b/home/hyprland/hyprlock.conf new file mode 100644 index 0000000..9a31858 --- /dev/null +++ b/home/hyprland/hyprlock.conf @@ -0,0 +1,78 @@ +source = ~/.cache/wal/colors-hyprland.conf +# BACKGROUND +background { + monitor = + path = ~/wallpapers/current + blur_passes = 3 + contrast = 0.8916 + brightness = 0.8172 + vibrancy = 0.1696 + vibrancy_darkness = 0.0 +} + +# GENERAL +general { + no_fade_in = false + grace = 0 + disable_loading_bar = true +} + +# INPUT FIELD +input-field { + monitor = + size = 250, 60 + outline_thickness = 2 + dots_size = 0.2 # Scale of input-field height, 0.2 - 0.8 + dots_spacing = 0.2 # Scale of dots' absolute size, 0.0 - 1.0 + dots_center = true + outer_color = rgba(0, 0, 0, 0) + inner_color = rgba(0, 0, 0, 0.5) + font_color = rgb(200, 200, 200) + fade_on_empty = false + font_family = JetBrains Mono Nerd Font Mono + placeholder_text = Input Password... + hide_input = false + position = 0, -120 + halign = center + valign = center +} + +# TIME +label { + monitor = + text = cmd[update:1000] echo "$(date +"%b %d %H:%M")" + color = $foreground + #color = rgba(255, 255, 255, 0.6) + font_size = 120 + font_family = JetBrains Mono Nerd Font Mono ExtraBold + position = 0, -300 + halign = center + valign = top +} + +## USER +#label { +# monitor = +# text = Hi there, $USER +# color = $foreground +# #color = rgba(255, 255, 255, 0.6) +# font_size = 25 +# font_family = JetBrains Mono Nerd Font Mono +# position = 0, -40 +# halign = center +# valign = center +#} + +# Battery level +label { + monitor = + text = cmd[update:1000] echo "$(batlvl)" + color = $foreground + #color = rgba(255, 255, 255, 0.6) + font_size = 18 + # font_family = JetBrainsMono, Font Awesome 6 Free Solid + font_family = JetBrains Mono Nerd Font Mono + position = 0, -50 + halign = center + valign = bottom +} diff --git a/home/hyprland/hyprlock.nix b/home/hyprland/hyprlock.nix new file mode 100644 index 0000000..88debe4 --- /dev/null +++ b/home/hyprland/hyprlock.nix @@ -0,0 +1,12 @@ +{ config, pkgs, ... }: { + + home.packages = with pkgs; [ + unstable.hyprlock + ]; + xdg.configFile = { + "hypr/hyprlock.conf" = { + source = config.lib.file.mkOutOfStoreSymlink ./. + "/hyprlock.conf"; + target = "hypr/hyprlock.conf"; + }; + }; +} diff --git a/home/hyprland/waybar/default.nix b/home/hyprland/waybar/default.nix index 8309a5f..d00835e 100644 --- a/home/hyprland/waybar/default.nix +++ b/home/hyprland/waybar/default.nix @@ -1,4 +1,15 @@ -{ pkgs, lib, ... }: { +{ pkgs, lib, ... }: +let + flakestat = pkgs.writeShellApplication { + name = "flakestat"; + runtimeInputs = with pkgs; [ + git + jq + ]; + text = builtins.readFile ./flakestat.sh; + }; +in +{ xdg.configFile."waybar/macchiato.css" = { source = pkgs.fetchFromGitHub { @@ -96,6 +107,7 @@ #network, #battery, #custom-powermenu, + #custom-flakestat, #custom-cava-internal { padding-left: 10px; padding-right: 10px; @@ -143,7 +155,7 @@ modules-left = [ "custom/launcher" "hyprland/workspaces" ]; modules-center = [ "clock" ]; modules-right = - [ "pulseaudio" "pulseaudio#microphone" "memory" "cpu" "tray" ]; + [ "custom/flakestat" "pulseaudio" "pulseaudio#microphone" "memory" "cpu" "tray" "battery" ]; "custom/launcher" = { "format" = " "; "on-click" = "pkill rofi || ~/.config/rofi/launcher.sh"; @@ -190,6 +202,25 @@ "icon-size" = 15; "spacing" = 6; }; + "battery" = { + "interval" = 60; + "states" = { + "warning" = 20; + "critical" = 5; + }; + "format" = "{icon} {capacity}%"; + "format-icons" = [ + "" + "" + "" + "" + "" + ]; + }; + "custom/flakestat" = { + "exec" = "${flakestat}/bin/flakestat"; + "interval" = 600; + }; }]; }; } diff --git a/home/hyprland/waybar/flakestat.sh b/home/hyprland/waybar/flakestat.sh new file mode 100644 index 0000000..bf35c8f --- /dev/null +++ b/home/hyprland/waybar/flakestat.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +FLAKE_DIR="/home/torjus/nixos" +NIXPKGS_DIR="/home/torjus/git/nixpkgs" + +flake_metadata=$(nix flake metadata --json "$FLAKE_DIR" 2>/dev/null) + +stable_input=$(echo "$flake_metadata" | jq '.locks.nodes.root.inputs.nixpkgs') +stable_rev=$(echo "$flake_metadata" | jq -r ".locks.nodes.$stable_input.locked.rev") +stable_branch=$(echo "$flake_metadata" | jq -r ".locks.nodes.$stable_input.original.ref") + +unstable_input=$(echo "$flake_metadata" | jq '.locks.nodes.root.inputs."nixpkgs-unstable"') +unstable_rev=$(echo "$flake_metadata" | jq -r ".locks.nodes.$unstable_input.locked.rev") +unstable_branch=$(echo "$flake_metadata" | jq -r ".locks.nodes.$unstable_input.original.ref") + +cd "$NIXPKGS_DIR" || exit 1 +git fetch -q +git switch -q "$stable_branch" +git pull -q +stable_commit_count=$(git rev-list "$stable_rev..HEAD"|wc -l) +git switch -q "$unstable_branch" +git pull -q +unstable_commit_count=$(git rev-list "$unstable_rev..HEAD"|wc -l) + +echo "$stable_commit_count|$unstable_commit_count" diff --git a/home/hyprland/waybar/waybar.nix b/home/hyprland/waybar/waybar.nix index e72e78d..2ebfec8 100644 --- a/home/hyprland/waybar/waybar.nix +++ b/home/hyprland/waybar/waybar.nix @@ -1,4 +1,5 @@ -{ pkgs, ... }: { +{ pkgs, ... }: +{ programs.waybar = { enable = true; systemd = { @@ -133,7 +134,7 @@ modules-left = [ "custom/launcher" "hyprland/workspaces" ]; modules-center = [ "clock" ]; modules-right = - [ "pulseaudio" "pulseaudio#microphone" "memory" "cpu" "tray" ]; + [ "pulseaudio" "pulseaudio#microphone" "memory" "cpu" "tray" "battery" ]; "custom/launcher" = { "format" = " "; "on-click" = "pkill rofi || ~/.config/rofi/launcher.sh"; @@ -180,6 +181,21 @@ "icon-size" = 15; "spacing" = 6; }; + "battery" = { + "interval" = 60; + "states" = { + "warning" = 30; + "critical" = 5; + }; + "format" = "{icon} {capacity}%"; + "format-icons" = [ + "" + "" + "" + "" + "" + ]; + }; }]; }; } diff --git a/home/magicman.nix b/home/magicman.nix index cefee00..cb38818 100644 --- a/home/magicman.nix +++ b/home/magicman.nix @@ -16,7 +16,9 @@ ./programs/rofi ./programs/obs-studio ./programs/vscode + ./programs/pywal ./scripts + ./scripts/batlvl.nix ./zsh ./packages ./hyprland/magicman.nix diff --git a/home/programs/pywal/default.nix b/home/programs/pywal/default.nix new file mode 100644 index 0000000..1baac39 --- /dev/null +++ b/home/programs/pywal/default.nix @@ -0,0 +1,27 @@ +{ config, pkgs, ... }: { + programs.pywal.enable = true; + + xdg.configFile = { + "wal/templates/colors-hyprland.conf" = { + text = ''$foreground = 0xff{foreground.strip} +$background = 0xff{background.strip} +$color0 = 0xff{color0.strip} +$color1 = 0xff{color1.strip} +$color2 = 0xff{color2.strip} +$color3 = 0xff{color3.strip} +$color4 = 0xff{color4.strip} +$color5 = 0xff{color5.strip} +$color6 = 0xff{color6.strip} +$color7 = 0xff{color7.strip} +$color8 = 0xff{color8.strip} +$color9 = 0xff{color9.strip} +$color10 = 0xff{color10.strip} +$color11 = 0xff{color11.strip} +$color12 = 0xff{color12.strip} +$color13 = 0xff{color13.strip} +$color14 = 0xff{color14.strip} +$color15 = 0xff{color15.strip} + ''; + }; + }; +} diff --git a/home/scripts/batlvl.nix b/home/scripts/batlvl.nix new file mode 100644 index 0000000..c92b5e2 --- /dev/null +++ b/home/scripts/batlvl.nix @@ -0,0 +1,14 @@ +{ config, pkgs, ... }: +let + batlvl = pkgs.writeShellApplication { + name = "batlvl"; + runtimeInputs = [ + ]; + text = builtins.readFile ./batlvl.sh; + }; +in +{ + home.packages = [ + batlvl + ]; +} diff --git a/home/scripts/batlvl.sh b/home/scripts/batlvl.sh new file mode 100644 index 0000000..0d246ef --- /dev/null +++ b/home/scripts/batlvl.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +ac_status=$(cat /sys/class/power_supply/AC/online) +bat_status=$(cat /sys/class/power_supply/BAT0/status) +bat_lvl=$(cat /sys/class/power_supply/BAT0/capacity) +if (("$ac_status" == 0)); then + echo "$bat_status - $bat_lvl%" +else + if [ "$bat_lvl" -lt "90" ]; then + echo "$bat_status - $bat_lvl%" + fi +fi diff --git a/home/scripts/randomwp.sh b/home/scripts/randomwp.sh index 442a0ae..38e3905 100644 --- a/home/scripts/randomwp.sh +++ b/home/scripts/randomwp.sh @@ -10,7 +10,7 @@ if ! [ -d "$WALLPAPER_DIR" ]; then exit 1 fi -wallpaper_path=$(find "$WALLPAPER_DIR" -mindepth 1 | sort -R | tail -n 1) +wallpaper_path=$(find "$WALLPAPER_DIR" -mindepth 1 | grep png| sort -R | tail -n 1) if [ -z "$wallpaper_path" ]; then echo "Unable to find wallpaper" @@ -26,6 +26,13 @@ echo "setting $wallpaper_path as wallpaper" hyprctl hyprpaper unload all hyprctl hyprpaper preload "$wallpaper_path" +if command -v wal &> /dev/null; then + wal -i "$wallpaper_path" +fi + +unlink "$WALLPAPER_DIR/current" || true +ln -s "$wallpaper_path" "$WALLPAPER_DIR/current" + for monitor in $(hyprctl monitors | grep 'Monitor' | awk '{ print $2 }'); do hyprctl hyprpaper wallpaper "$monitor,$wallpaper_path" done diff --git a/hosts/magicman/configuration.nix b/hosts/magicman/configuration.nix index fc63072..92ab9d5 100644 --- a/hosts/magicman/configuration.nix +++ b/hosts/magicman/configuration.nix @@ -8,10 +8,28 @@ "quiet" "splash" "rd.systemd.show_status=false" + "acpi_backlight=native" + "video=efifb:nobgrt" + "loglevel=3" + "rd.udev.log_level=3" ]; + boot.kernelPackages = pkgs.linuxPackages_latest; + boot.loader.systemd-boot = { enable = true; }; boot.loader.efi = { canTouchEfiVariables = true; }; + boot.initrd.systemd.enable = true; + boot.plymouth = { + enable = true; + themePackages = with pkgs; [ + catppuccin-plymouth + ]; + theme = "catppuccin-macchiato"; + extraConfig = '' + UseFirmwareBackground=false + ''; + }; + # Networking stuff networking.hostName = "magicman"; # Define your hostname. networking.networkmanager.enable = true; @@ -27,9 +45,9 @@ hardware.opengl = { enable = true; extraPackages = with pkgs; [ - # intel-media-driver - # vaapiVdpau - # libvdpau-va-gl + intel-media-driver + vaapiVdpau + libvdpau-va-gl ]; }; @@ -45,6 +63,15 @@ portalPackage = pkgs.xdg-desktop-portal-hyprland; }; + # TRIM + services.fstrim.enable = true; + + # TLP + services.tlp.enable = true; + + # Brillo + hardware.brillo.enable = true; + # Setup common XDG env vars environment.sessionVariables = rec { XDG_CACHE_HOME = "$HOME/.cache"; @@ -65,6 +92,8 @@ ]); }; + programs.steam.enable = true; + # Enable flakes nix.settings.experimental-features = [ "nix-command" "flakes" ]; nix.settings.trusted-users = [ "root" "torjus" ]; diff --git a/hosts/magicman/hardware-configuration.nix b/hosts/magicman/hardware-configuration.nix index 364d2f3..fb02bad 100644 --- a/hosts/magicman/hardware-configuration.nix +++ b/hosts/magicman/hardware-configuration.nix @@ -5,29 +5,31 @@ { imports = - [ (modulesPath + "/installer/scan/not-detected.nix") + [ + (modulesPath + "/installer/scan/not-detected.nix") ]; boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "nvme" "usb_storage" "sd_mod" "sdhci_pci" ]; - boot.initrd.kernelModules = [ ]; + boot.initrd.kernelModules = [ "i915" ]; boot.kernelModules = [ "kvm-intel" ]; boot.extraModulePackages = [ ]; fileSystems."/" = - { device = "/dev/disk/by-uuid/31b20f4c-24bb-4fd1-9a3e-8ccc19fe3d64"; + { + device = "/dev/disk/by-uuid/31b20f4c-24bb-4fd1-9a3e-8ccc19fe3d64"; fsType = "xfs"; }; boot.initrd.luks.devices."root".device = "/dev/disk/by-uuid/4bbadd2c-94dd-4d80-94bf-9332d24b57bd"; fileSystems."/boot" = - { device = "/dev/disk/by-uuid/7FF3-B061"; + { + device = "/dev/disk/by-uuid/7FF3-B061"; fsType = "vfat"; }; swapDevices = - [ { device = "/dev/disk/by-uuid/6f2c4906-ad88-4d7e-88ec-61cdda41ce28"; } - ]; + [{ device = "/dev/disk/by-uuid/6f2c4906-ad88-4d7e-88ec-61cdda41ce28"; }]; # 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 diff --git a/system/users.nix b/system/users.nix index b3ff1ea..6f615a3 100644 --- a/system/users.nix +++ b/system/users.nix @@ -12,7 +12,7 @@ home = "/home/torjus"; description = "Torjus"; shell = pkgs.zsh; - extraGroups = [ "wheel" "input" "networkmanager" ]; + extraGroups = [ "wheel" "input" "networkmanager" "video" ]; # Install some user packages packages = with pkgs; [ ];