♻️ switch from sway + waybar to hyprland + eww

This commit is contained in:
Laureηt 2023-05-28 23:48:36 +02:00
parent 9b2a464a6a
commit 562dff7a7c
Signed by: Laurent
SSH key fingerprint: SHA256:kZEpW8cMJ54PDeCvOhzreNr4FSh6R13CMGH/POoO8DI
10 changed files with 467 additions and 270 deletions

View file

@ -265,6 +265,48 @@
"type": "github"
}
},
"hyprland": {
"inputs": {
"hyprland-protocols": "hyprland-protocols",
"nixpkgs": "nixpkgs",
"wlroots": "wlroots",
"xdph": "xdph"
},
"locked": {
"lastModified": 1685307013,
"narHash": "sha256-sin6htYT96qZSJKrhgBNuiBnMgem7IL/Mg9A51bqGPg=",
"owner": "hyprwm",
"repo": "Hyprland",
"rev": "438d063ec684c2194563678ace5a625e6fb56517",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "Hyprland",
"type": "github"
}
},
"hyprland-protocols": {
"inputs": {
"nixpkgs": [
"hyprland",
"nixpkgs"
]
},
"locked": {
"lastModified": 1681065697,
"narHash": "sha256-QPzwwlGKX95tl6ZEshboZbEwwAXww6lNLdVYd6T9Mrc=",
"owner": "hyprwm",
"repo": "hyprland-protocols",
"rev": "4d29e48433270a2af06b8bc711ca1fe5109746cd",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "hyprland-protocols",
"type": "github"
}
},
"lanzaboote": {
"inputs": {
"crane": "crane_2",
@ -308,11 +350,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1684570954,
"narHash": "sha256-FX5y4Sm87RWwfu9PI71XFvuRpZLowh00FQpIJ1WfXqE=",
"lastModified": 1683014792,
"narHash": "sha256-6Va9iVtmmsw4raBc3QKvQT2KT/NGRWlvUlJj46zN8B8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "3005f20ce0aaa58169cdee57c8aa12e5f1b6e1b3",
"rev": "1a411f23ba299db155a5b45d5e145b85a7aafc42",
"type": "github"
},
"original": {
@ -338,6 +380,22 @@
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1684570954,
"narHash": "sha256-FX5y4Sm87RWwfu9PI71XFvuRpZLowh00FQpIJ1WfXqE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "3005f20ce0aaa58169cdee57c8aa12e5f1b6e1b3",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit-hooks-nix": {
"inputs": {
"flake-compat": [
@ -374,9 +432,10 @@
"agenix": "agenix",
"flake-utils": "flake-utils",
"home-manager": "home-manager",
"hyprland": "hyprland",
"lanzaboote": "lanzaboote",
"nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs_2"
}
},
"rust-overlay": {
@ -458,6 +517,49 @@
"repo": "default",
"type": "github"
}
},
"wlroots": {
"flake": false,
"locked": {
"host": "gitlab.freedesktop.org",
"lastModified": 1682436395,
"narHash": "sha256-GGEjkQO9m7YLYIXIXM76HWdhjg4Ye+oafOtyaFAYKI4=",
"owner": "wlroots",
"repo": "wlroots",
"rev": "6830bfc17fd94709e2cdd4da0af989f102a26e59",
"type": "gitlab"
},
"original": {
"host": "gitlab.freedesktop.org",
"owner": "wlroots",
"repo": "wlroots",
"type": "gitlab"
}
},
"xdph": {
"inputs": {
"hyprland-protocols": [
"hyprland",
"hyprland-protocols"
],
"nixpkgs": [
"hyprland",
"nixpkgs"
]
},
"locked": {
"lastModified": 1682439384,
"narHash": "sha256-zHDa8LCZs05TZHQSIZ3ucwyMPglBGHcqTBzfkLjYXTM=",
"owner": "hyprwm",
"repo": "xdg-desktop-portal-hyprland",
"rev": "c0e233955568fbea4e859336f6d3d14d51294d7c",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "xdg-desktop-portal-hyprland",
"type": "github"
}
}
},
"root": "root",

View file

@ -24,10 +24,12 @@
};
nixos-hardware.url = "github:nixos/nixos-hardware";
hyprland.url = "github:hyprwm/Hyprland";
};
outputs = { nixpkgs, flake-utils, lanzaboote, agenix, home-manager
, nixos-hardware, ... }:
, nixos-hardware, hyprland, ... }:
(flake-utils.lib.eachDefaultSystem (system:
let pkgs = nixpkgs.legacyPackages.${system};
@ -49,6 +51,10 @@
modules = [
./hosts/neodymium/configuration.nix
home-manager.nixosModules.home-manager
{
home-manager.users.laurent.imports =
[ hyprland.homeManagerModules.default ];
}
agenix.nixosModules.default
lanzaboote.nixosModules.lanzaboote
nixos-hardware.nixosModules.common-cpu-amd

View file

@ -9,6 +9,8 @@
services.mpris-proxy.enable = true; # media keys
home.packages = with pkgs; [
socat # socket cat
jq # json utils
baobab # disk utils
borgbackup # backup
dconf # required by home-manager

View file

@ -7,276 +7,23 @@ let
sha256 = "007zr906q7s31xgn9xw3jl8zdg5wapixva01qniclna1y0yxlqr7";
};
in {
programs.eww = {
enable = true;
package = pkgs.eww-wayland;
configDir = ./eww;
};
services.mako = {
enable = true;
defaultTimeout = 5000;
extraConfig = builtins.readFile "${catppuccin-mako}/src/mocha";
};
wayland.windowManager.sway = {
wayland.windowManager.hyprland = {
enable = true;
package = (pkgs.swayfx.overrideAttrs (old: {
src = pkgs.fetchFromGitHub {
owner = "WillPower3309";
repo = "swayfx";
rev = "6e53c04abf34599a6c36d1fb57df26d641bee8a1";
sha256 = "sha256-dtAbtiRnY1GL9UuPE9iKwF2ZwxPqaOva196Pl8YARg0=";
recommendedEnvironment = true;
extraConfig = builtins.readFile ./hyprland.conf;
};
}));
extraConfig = ''
blur enable
'';
config = rec {
modifier = "Mod4";
terminal = "alacritty";
input = {
"type:touchpad" = {
dwt = "disable";
tap = "enabled";
natural_scroll = "disabled";
middle_emulation = "enabled";
};
"type:keyboard" = {
xkb_numlock = "enabled";
xkb_layout = "fr";
};
};
output = {
"*" = {
bg = "~/Pictures/wallpapers/kai-oberhauser-unsplash.jpg fill";
};
eDP-1 = {
mode = "1920x1080";
adaptive_sync = "on";
};
eDP-2 = {
mode = "1920x1080";
adaptive_sync = "on";
};
DP-1 = { disable = ""; };
};
fonts = {
names = [ "FiraCode" ];
size = 10.0;
};
bars = [{ command = "env GTK_THEME=adwaita ${pkgs.waybar}/bin/waybar"; }];
gaps = {
smartGaps = true;
inner = 5;
};
window = { border = 0; };
floating = { border = 0; };
focus = { followMouse = "no"; };
startup = [
{ command = "mako"; }
{ command = "element-desktop"; }
{ command = "thunderbird"; }
{ command = "webcord"; }
{
command = ''
swayidle -w \
timeout 100 'swaylock -f --grace 3' \
timeout 130 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"' \
timeout 300 'systemctl suspend' \
before-sleep 'swaylock -f'
'';
}
];
assigns = {
"8" = [{ class = "^WebCord$"; }];
"9" = [{ class = "^Element$"; }];
"10" = [{ app_id = "thunderbird"; }];
};
keybindings = {
# Start a terminal
"${modifier}+Return" = "exec ${terminal}";
# Kill focused window
"${modifier}+q" = "kill";
# Reload the configuration file
"${modifier}+twosuperior" = "reload";
# Exit sway (logs you out of your Wayland session)
"${modifier}+Shift+e" =
"exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' 'swaymsg exit'";
# Lock
"${modifier}+Delete" = "exec swaylock -f";
# Screenshot whole screen
"Print" = "exec grim `date +'%Y-%m-%dT%H:%M:%S'`.png";
# Screenshot whole screen to clipboard
"Shift+Print" = "exec grim - | wl-copy -t 'image/png'";
# Screenshot area
"${modifier}+Print" =
"exec slurp -d | grim -g - `date +'%Y-%m-%dT%H:%M:%S'`.png";
# Screenshot area to clipboard
"${modifier}+Shift+Print" =
"exec slurp -d | grim -g - - | wl-copy -t 'image/png'";
# backlight
"XF86MonBrightnessUp" = "exec light -A 5";
"XF86MonBrightnessDown" = "exec light -U 5";
# audio
"XF86AudioMute" = "exec pamixer --sink 0 -t";
"XF86AudioRaiseVolume" = "exec pamixer -i 5";
"XF86AudioLowerVolume" = "exec pamixer -d 5";
"XF86AudioMicMute" = "exec pamixer --source 0 -t";
# split horizontally or vertically
"${modifier}+b" = "splith";
"${modifier}+v" = "splitv";
# Make the current focus fullscreen
"${modifier}+f" = "fullscreen";
# Toggle the current focus between tiling and floating mode
"${modifier}+s" = "floating toggle";
# Move your focus around
"${modifier}+Left" = "focus left";
"${modifier}+Down" = "focus down";
"${modifier}+Up" = "focus up";
"${modifier}+Right" = "focus right";
# Move the focused window around
"${modifier}+Shift+Left" = "move left";
"${modifier}+Shift+Down" = "move down";
"${modifier}+Shift+Up" = "move up";
"${modifier}+Shift+Right" = "move right";
# Switch to workspace
"${modifier}+ampersand" = "workspace 1";
"${modifier}+eacute" = "workspace 2";
"${modifier}+quotedbl" = "workspace 3";
"${modifier}+apostrophe" = "workspace 4";
"${modifier}+parenleft" = "workspace 5";
"${modifier}+minus" = "workspace 6";
"${modifier}+egrave" = "workspace 7";
"${modifier}+underscore" = "workspace 8";
"${modifier}+ccedilla" = "workspace 9";
"${modifier}+agrave" = "workspace 10";
"${modifier}+KP_1" = "workspace 11";
"${modifier}+KP_2" = "workspace 12";
"${modifier}+KP_3" = "workspace 13";
"${modifier}+KP_4" = "workspace 14";
"${modifier}+KP_5" = "workspace 15";
"${modifier}+KP_6" = "workspace 16";
"${modifier}+KP_7" = "workspace 17";
"${modifier}+KP_8" = "workspace 18";
"${modifier}+KP_9" = "workspace 19";
"${modifier}+KP_0" = "workspace 20";
"${modifier}+KP_End" = "workspace 11";
"${modifier}+KP_Down" = "workspace 12";
"${modifier}+KP_Next" = "workspace 13";
"${modifier}+KP_Left" = "workspace 14";
"${modifier}+KP_Begin" = "workspace 15";
"${modifier}+KP_Right" = "workspace 16";
"${modifier}+KP_Home" = "workspace 17";
"${modifier}+KP_Up" = "workspace 18";
"${modifier}+KP_Prior" = "workspace 19";
"${modifier}+KP_Insert" = "workspace 20";
# Move focused container to workspace
"${modifier}+Shift+ampersand" = "move container to workspace number 1";
"${modifier}+Shift+eacute" = "move container to workspace number 2";
"${modifier}+Shift+quotedbl" = "move container to workspace number 3";
"${modifier}+Shift+apostrophe" = "move container to workspace number 4";
"${modifier}+Shift+parenleft" = "move container to workspace number 5";
"${modifier}+Shift+minus" = "move container to workspace number 6";
"${modifier}+Shift+egrave" = "move container to workspace number 7";
"${modifier}+Shift+underscore" = "move container to workspace number 8";
"${modifier}+Shift+ccedilla" = "move container to workspace number 9";
"${modifier}+Shift+agrave" = "move container to workspace number 10";
"${modifier}+Shift+KP_End" = "move container to workspace number 11";
"${modifier}+Shift+KP_Down" = "move container to workspace number 12";
"${modifier}+Shift+KP_Next" = "move container to workspace number 13";
"${modifier}+Shift+KP_Left" = "move container to workspace number 14";
"${modifier}+Shift+KP_Begin" = "move container to workspace number 15";
"${modifier}+Shift+KP_Right" = "move container to workspace number 16";
"${modifier}+Shift+KP_Home" = "move container to workspace number 17";
"${modifier}+Shift+KP_Up" = "move container to workspace number 18";
"${modifier}+Shift+KP_Prior" = "move container to workspace number 19";
"${modifier}+Shift+KP_Insert" = "move container to workspace number 20";
};
workspaceOutputAssign = [
{
workspace = "1";
output = "eDP-1 eDP-2";
}
{
workspace = "2";
output = "eDP-1 eDP-2";
}
{
workspace = "3";
output = "eDP-1 eDP-2";
}
{
workspace = "4";
output = "eDP-1 eDP-2";
}
{
workspace = "5";
output = "eDP-1 eDP-2";
}
{
workspace = "6";
output = "eDP-1 eDP-2";
}
{
workspace = "7";
output = "eDP-1 eDP-2";
}
{
workspace = "8";
output = "eDP-1 eDP-2";
}
{
workspace = "9";
output = "eDP-1 eDP-2";
}
{
workspace = "10";
output = "eDP-1 eDP-2";
}
{
workspace = "11";
output = "DP-1";
}
{
workspace = "12";
output = "DP-1";
}
{
workspace = "13";
output = "DP-1";
}
{
workspace = "14";
output = "DP-1";
}
{
workspace = "15";
output = "DP-1";
}
{
workspace = "16";
output = "DP-1";
}
{
workspace = "17";
output = "DP-1";
}
{
workspace = "18";
output = "DP-1";
}
{
workspace = "19";
output = "DP-1";
}
{
workspace = "20";
output = "DP-1";
}
];
};
};
}

View file

@ -0,0 +1,55 @@
* {
all: unset; //Unsets everything so you can style everything from scratch
}
//Global Styles
.bar {
background-color: #3a3a3a;
color: #b0b4bc;
padding: 10px;
}
// Styles on classes (see eww.yuck for more information)
.sidestuff slider {
all: unset;
color: #ffd5cd;
}
.metric scale trough highlight {
all: unset;
background-color: #D35D6E;
color: #000000;
border-radius: 10px;
}
.metric scale trough {
all: unset;
background-color: #4e4e4e;
border-radius: 50px;
min-height: 3px;
min-width: 50px;
margin-left: 10px;
margin-right: 20px;
}
.metric scale trough highlight {
all: unset;
background-color: #D35D6E;
color: #000000;
border-radius: 10px;
}
.metric scale trough {
all: unset;
background-color: #4e4e4e;
border-radius: 50px;
min-height: 3px;
min-width: 50px;
margin-left: 10px;
margin-right: 20px;
}
.workspace-entry.active {
color: #D35D6E;
}

View file

@ -0,0 +1,119 @@
(defwidget bar []
(centerbox
:orientation "h"
(workspaces)
(box)
(sidestuff)
)
)
(defwidget sidestuff []
(box
:class "sidestuff"
:orientation "h"
:space-evenly false
:halign "end"
(metric
:label "󰕾"
:value volume
:onchange "pamixer --set-volume {}"
)
(metric
:label "󱐋"
:value {EWW_BATTERY.total_avg}
:onchange ""
)
(metric
:label "󰋊"
:value {round((1 - (EWW_DISK["/"].free / EWW_DISK["/"].total)) * 100, 0)}
:onchange ""
)
(metric
:label ""
:value {EWW_RAM.used_mem_perc}
:onchange ""
)
(metric
:label "󰍛"
:value {EWW_CPU.avg}
:onchange ""
)
time
)
)
(deflisten workspaces :initial "[]" "bash ~/.config/eww/scripts/get-workspaces")
(deflisten active_workspace :initial "1" "bash ~/.config/eww/scripts/get-active-workspace")
(defwidget workspaces []
(eventbox :class "workspaces-widget"
(box
:space-evenly false
:spacing 10
(label
:text "${workspaces}${active_workspace}"
:visible false
)
(for workspace in workspaces
(eventbox
:onclick "hyprctl dispatch workspace ${workspace.id}"
(box
:class "workspace-entry ${workspace.id == active_workspace ? "active" : ""} ${workspace.windows > 0 ? "occupied" : "empty"}"
(label
:text "${workspace.id}"
)
)
)
)
)
)
)
(defwidget metric [label value onchange]
(box
:orientation "h"
:class "metric"
:space-evenly false
(box
:class "label"
label
)
(scale
:min 0
:max 100
:active {onchange != ""}
:value value
:onchange onchange
)
)
)
(defpoll volume
:interval "1s"
"pamixer --get-volume"
)
(defpoll time
:interval "1s"
"date '+%Y-%m-%d %H:%M:%S'"
)
(defwindow bar
:monitor 0
:windowtype "dock"
:exclusive true
:geometry (geometry
:x "0%"
:y "0%"
:width "100%"
:height "22px"
:anchor "top center"
)
:reserve (struts
:side "top"
:distance "4%"
)
(bar)
)

View file

@ -0,0 +1,8 @@
#!/usr/bin/env bash
# print current active workspace id
hyprctl monitors -j | jq '.[] | select(.focused) | .activeWorkspace.id'
# print current active workspace id on workspace changes
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - |
stdbuf -o0 awk -F '>>|,' -e '/^workspace>>/ {print $2}' -e '/^focusedmon>>/ {print $3}'

View file

@ -0,0 +1,15 @@
#!/bin/bash
# function to get workspaces infos and their window count
spaces (){
WORKSPACE_WINDOWS=$(hyprctl workspaces -j | jq 'map({key: .id | tostring, value: .windows}) | from_entries')
seq 1 10 | jq --argjson windows "${WORKSPACE_WINDOWS}" --slurp -Mc 'map(tostring) | map({id: ., windows: ($windows[.]//0)})'
}
# print workspaces infos
spaces
# print info on workspace changes
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | while read -r line; do
spaces
done

View file

@ -0,0 +1,143 @@
# https://wiki.hyprland.org/Configuring/Monitors/
monitor=eDP-2,1920x1080@120,0x0,1
# https://wiki.hyprland.org/Configuring/Keywords/
# Execute your favorite apps at launch
exec-once = GTK_THEME=adwaita waybar & mako & element-desktop & thunderbird & webcord & swayidle -w timeout 100 'swaylock -f --grace 3' timeout 130 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' timeout 300 'systemctl suspend' before-sleep 'swaylock -f'
# Source a file (multi-file configs)
# source = ~/.config/hypr/myColors.conf
# Some default env vars.
env = XCURSOR_SIZE,20
# https://wiki.hyprland.org/Configuring/Variables/
input {
kb_layout = fr
kb_variant =
kb_model =
kb_options =
kb_rules =
follow_mouse = 2
touchpad {
natural_scroll = no
}
sensitivity = 0 # -1.0 - 1.0, 0 means no modification.
}
# https://wiki.hyprland.org/Configuring/Variables/
general {
gaps_in = 2
gaps_out = 4
border_size = 0
col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg
col.inactive_border = rgba(595959aa)
layout = dwindle
}
# See https://wiki.hyprland.org/Configuring/Variables/
decoration {
rounding = 2
blur = yes
blur_size = 3
blur_passes = 3
blur_new_optimizations = on
drop_shadow = yes
shadow_range = 4
shadow_render_power = 3
col.shadow = rgba(1a1a1aee)
}
# Some default animations, see https://wiki.hyprland.org/Configuring/Animations/
animations {
enabled = no
}
# https://wiki.hyprland.org/Configuring/Dwindle-Layout/
dwindle {
pseudotile = yes # master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below
preserve_split = yes # you probably want this
no_gaps_when_only = true
}
# https://wiki.hyprland.org/Configuring/Master-Layout/
master {
new_is_master = false
}
# https://wiki.hyprland.org/Configuring/Variables/
gestures {
workspace_swipe = off
}
misc {
disable_hyprland_logo = true
disable_splash_rendering = true
}
# https://wiki.hyprland.org/Configuring/Window-Rules/
# None
# https://wiki.hyprland.org/Configuring/Keywords/
$mainMod = SUPER
# https://wiki.hyprland.org/Configuring/Binds/
# Main binds
bind = $mainMod, Return, exec, alacritty
bind = $mainMod, Q, killactive,
bind = $mainMod, S, togglefloating,
bind = $mainMod, Delete, exec, swaylock -f
# Screenshot
bind = , Print, exec, grim `date +'%Y-%m-%dT%H:%M:%S'`.png
bind = SHIFT, Print, exec, grim - | wl-copy -t 'image/png'
bind = $mainMod, Print, exec, slurp -d | grim -g - `date +'%Y-%m-%dT%H:%M:%S'`.png
bind = $mainMod SHIFT, Print, exec, slurp -d | grim -g - - | wl-copy -t 'image/png'
# Backlight
bind = , XF86MonBrightnessUp, exec, light -A 5
bind = , XF86MonBrightnessDown, exec, light -U 5
# Audio
bind = , XF86AudioMute, exec, pamixer --sink 0 -t
bind = , XF86AudioRaiseVolume, exec, pamixer -i 5
bind = , XF86AudioLowerVolume, exec, pamixer -d 5
bind = , XF86AudioMicMute, exec, pamixer --source 0 -t
# Switch workspaces
bind = $mainMod, ampersand, workspace, 1
bind = $mainMod, eacute, workspace, 2
bind = $mainMod, quotedbl, workspace, 3
bind = $mainMod, apostrophe, workspace, 4
bind = $mainMod, parenleft, workspace, 5
bind = $mainMod, minus, workspace, 6
bind = $mainMod, egrave, workspace, 7
bind = $mainMod, underscore, workspace, 8
bind = $mainMod, ccedilla, workspace, 9
bind = $mainMod, agrave, workspace, 10
# Switch window to workspace
bind = $mainMod SHIFT, ampersand, movetoworkspacesilent, 1
bind = $mainMod SHIFT, eacute, movetoworkspacesilent, 2
bind = $mainMod SHIFT, quotedbl, movetoworkspacesilent, 3
bind = $mainMod SHIFT, apostrophe, movetoworkspacesilent, 4
bind = $mainMod SHIFT, parenleft, movetoworkspacesilent, 5
bind = $mainMod SHIFT, minus, movetoworkspacesilent, 6
bind = $mainMod SHIFT, egrave, movetoworkspacesilent, 7
bind = $mainMod SHIFT, underscore, movetoworkspacesilent, 8
bind = $mainMod SHIFT, ccedilla, movetoworkspacesilent, 9
bind = $mainMod SHIFT, agrave, movetoworkspacesilent, 10
# Move/resize windows
bindm = $mainMod, mouse:272, movewindow
bindm = $mainMod, mouse:273, resizewindow

View file

@ -4,7 +4,7 @@
settings = {
default_session = {
command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd sway";
command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd Hyprland";
user = "greeter";
};
};