Add Hyprland and Greetd configurations; update desktop settings and user examples

This commit is contained in:
2025-08-10 22:39:39 -03:00
parent 87a2314170
commit 8224513e07
13 changed files with 347 additions and 51 deletions

View File

@@ -10,7 +10,8 @@
#
# FIXME(starter): add or remove any optional config directories or files ehre
common/optional/browsers
common/optional/desktops
common/optional/desktops/hyprland
common/optional/desktops/hyprland/zenbook-screen.nix
common/optional/comms
common/optional/media
common/optional/coding

View File

@@ -37,10 +37,6 @@ in {
sessionPath = [
"$HOME/.local/bin"
];
sessionVariables = {
FLAKE = "$HOME/src/nix/nix-config";
SHELL = "bash";
};
};
home.packages = with pkgs; [

View File

@@ -0,0 +1,6 @@
{pkgs, ...}: {
programs.nushell = {
enable = true;
configFile.source = null; # Use default config, or set to a custom file if desired
};
}

View File

@@ -0,0 +1,19 @@
{pkgs, ...}: {
programs.zsh = {
enable = true;
enableCompletion = true;
syntaxHighlighting.enable = true;
autosuggestions.enable = true;
history = {
save = 10000;
share = true;
};
plugins = [
{
name = "zsh-autopair";
src = pkgs.zsh-autopair;
}
# Add more plugins here as needed
];
};
}

View File

@@ -0,0 +1,48 @@
{
config,
lib,
pkgs,
...
}: {
imports = [
./hyprlock.nix
./hypridle.nix
];
# Misc settingsmanager configuration
wayland.windowManager.hyprland = {
enable = true;
plugins = with pkgs.hyprlandPlugins; [
# Add any additional Hyprland plugins here
hyprspace
];
settings = {
# Set mod key
"$mod" = "SUPER";
# Enable inverted (natural) scrolling on touchpad
"input:touchpad:natural_scroll" = true;
# Disable middle click on touchpad
"input:touchpad:clickfinger_behavior" = false;
"input:touchpad:middle_button_emulation" = false;
# Enable 3-finger swipe to change workspaces
"gestures:workspace_swipe" = true;
"gestures:workspace_swipe_fingers" = 3;
"plugin:overview:reverseSwipe" = true;
# Keybinds
bind = [
# Launch terminal (kitty)
"$mod,RETURN,exec,kitty"
# Launch browser (zen)
"$mod,B,exec,zen"
# Close window
"$mod,Q,killactive"
# Logout
"$mod SHIFT,E,exit"
# Overview
"$mod,TAB,overview:toggle"
];
};
};
}

View File

@@ -0,0 +1,37 @@
{pkgs, ...}: {
services.hypridle = {
enable = true;
settings = {
general = {
lock_cmd = "pidof hyprlock || hyprlock";
before_sleep_cmd = "loginctl lock-session";
after_sleep_cmd = "hyprctl dispatch dpms on";
};
listener = [
{
timeout = 150;
on-timeout = "brightnessctl -s set 10";
on-resume = "brightnessctl -r";
}
{
timeout = 300;
on-timeout = "loginctl lock-session";
}
{
timeout = 330;
on-timeout = "hyprctl dispatch dpms off";
on-resume = "hyprctl dispatch dpms on";
}
{
timeout = 1800;
on-timeout = "systemctl suspend";
}
];
};
};
home.packages = with pkgs; [
hypridle
];
}

View File

@@ -0,0 +1,13 @@
{pkgs, ...}: {
programs.hyprlock = {
enable = true;
};
wayland.windowManager.hyprland.keybinds = [
"$mod,L,exec,hyprlock"
];
home.packages = with pkgs; [
hyprlock
];
}

View File

@@ -0,0 +1,140 @@
{pkgs, ...}: let
# Configuration variables from your script
preferred_resolution = "2880x1800";
refresh_rate = "120";
ui_scale = "1.5";
y_offset = "1200";
vrr_mode = "1"; # 0 = off, 1 = on, 2 = fullscreen only
# Inline scripts adapted from your bash script
zenbook-top = pkgs.writeShellScriptBin "zenbook-top" ''
echo "Setting to top screen only"
${pkgs.hyprland}/bin/hyprctl keyword monitor "eDP-1,${preferred_resolution}@${refresh_rate},0x0,${ui_scale},vrr,${vrr_mode}"
${pkgs.hyprland}/bin/hyprctl keyword monitor "eDP-2,disable"
'';
zenbook-bottom = pkgs.writeShellScriptBin "zenbook-bottom" ''
echo "Setting to bottom screen only"
${pkgs.hyprland}/bin/hyprctl keyword monitor "eDP-2,${preferred_resolution}@${refresh_rate},0x0,${ui_scale},vrr,${vrr_mode}"
${pkgs.hyprland}/bin/hyprctl keyword monitor "eDP-1,disable"
'';
zenbook-both = pkgs.writeShellScriptBin "zenbook-both" ''
echo "Setting to both screens"
${pkgs.hyprland}/bin/hyprctl keyword monitor "eDP-1,${preferred_resolution}@${refresh_rate},0x0,${ui_scale},vrr,${vrr_mode}"
${pkgs.hyprland}/bin/hyprctl keyword monitor "eDP-2,${preferred_resolution}@${refresh_rate},0x${y_offset},${ui_scale},vrr,${vrr_mode}"
'';
zenbook-left-up = pkgs.writeShellScriptBin "zenbook-left-up" ''
echo "Setting to left-right layout"
${pkgs.hyprland}/bin/hyprctl keyword monitor "eDP-2,${preferred_resolution}@${refresh_rate},0x0,${ui_scale},vrr,${vrr_mode}"
${pkgs.hyprland}/bin/hyprctl keyword monitor "eDP-1,${preferred_resolution}@${refresh_rate},${y_offset}x0,${ui_scale},vrr,${vrr_mode}"
'';
zenbook-right-up = pkgs.writeShellScriptBin "zenbook-right-up" ''
echo "Setting to right-left layout"
${pkgs.hyprland}/bin/hyprctl keyword monitor "eDP-1,${preferred_resolution}@${refresh_rate},0x0,${ui_scale},vrr,${vrr_mode}"
${pkgs.hyprland}/bin/hyprctl keyword monitor "eDP-2,${preferred_resolution}@${refresh_rate},${y_offset}x0,${ui_scale},vrr,${vrr_mode}"
'';
zenbook-normal = pkgs.writeShellScriptBin "zenbook-normal" ''
# Check if lid is closed
lid_closed=false
if grep -q closed /proc/acpi/button/lid/*/state 2>/dev/null; then
lid_closed=true
fi
# Check if keyboard is attached (USB dock detection)
keyboard_attached=false
if ${pkgs.usbutils}/bin/lsusb | grep 0b05:1b2c; then
keyboard_attached=true
fi
if [ "$lid_closed" = true ] && [ "$keyboard_attached" = true ]; then
echo "Lid closed and keyboard attached disabling both screens"
${pkgs.hyprland}/bin/hyprctl keyword monitor "eDP-1,disable"
${pkgs.hyprland}/bin/hyprctl keyword monitor "eDP-2,disable"
elif [ "$lid_closed" = true ]; then
echo "Lid closed disabling top screen"
${pkgs.hyprland}/bin/hyprctl keyword monitor "eDP-1,disable"
${pkgs.hyprland}/bin/hyprctl keyword monitor "eDP-2,${preferred_resolution}@${refresh_rate},0x0,${ui_scale},vrr,${vrr_mode}"
elif [ "$keyboard_attached" = true ]; then
echo "Keyboard attached disabling bottom screen"
${pkgs.hyprland}/bin/hyprctl keyword monitor "eDP-1,${preferred_resolution}@${refresh_rate},0x0,${ui_scale},vrr,${vrr_mode}"
${pkgs.hyprland}/bin/hyprctl keyword monitor "eDP-2,disable"
else
echo "Normal mode enabling both screens"
${zenbook-both}/bin/zenbook-both
fi
'';
zenbook-toggle = pkgs.writeShellScriptBin "zenbook-toggle" ''
# Check current state and toggle
enabled_count=$(${pkgs.hyprland}/bin/hyprctl monitors | grep -c "eDP.*" || echo "0")
if [ "$enabled_count" -eq 1 ]; then
${zenbook-both}/bin/zenbook-both
else
${zenbook-top}/bin/zenbook-top
fi
'';
# Event-driven display management (from your original script)
zenbook-watch-displays = pkgs.writeShellScriptBin "zenbook-watch-displays" ''
${zenbook-normal}/bin/zenbook-normal
while ${pkgs.inotify-tools}/bin/inotifywait -e attrib /dev/bus/usb/*/; do
${zenbook-normal}/bin/zenbook-normal
done
'';
zenbook-set-displays = pkgs.writeShellScriptBin "zenbook-set-displays" ''
sleep 1
${zenbook-normal}/bin/zenbook-normal
'';
# Auto-run display setup on startup
zenbook-autostart = pkgs.writeShellScriptBin "zenbook-autostart" ''
# Initial display setup
${zenbook-normal}/bin/zenbook-normal
# Start USB monitoring in background
${zenbook-watch-displays}/bin/zenbook-watch-displays &
'';
in {
# Zenbook dual-screen display configuration
wayland.windowManager.hyprland.settings = {
# Monitor configuration for Zenbook dual screens
monitor = [
# Primary display (eDP-1) - top screen
"eDP-1,${preferred_resolution}@${refresh_rate},0x0,${ui_scale},vrr,${vrr_mode}"
# Secondary display (eDP-2) - bottom screen positioned below primary
"eDP-2,${preferred_resolution}@${refresh_rate},0x${y_offset},${ui_scale},vrr,${vrr_mode}"
# Fallback for any other monitors
",preferred,auto,1"
];
# VRR and performance optimizations
misc = {
# Enable Variable Frame Rate to save power when screen is static
vfr = true;
};
# Auto-start the event-driven display management
exec-once = [
"${zenbook-autostart}/bin/zenbook-autostart"
];
};
# Add the scripts to home packages
home.packages = [
zenbook-top
zenbook-bottom
zenbook-both
zenbook-left-up
zenbook-right-up
zenbook-normal
zenbook-toggle
zenbook-watch-displays
zenbook-set-displays
zenbook-autostart
];
}