Switch from sway to hyprland

This commit is contained in:
Kiana Sheibani 2024-02-09 17:17:48 -05:00
parent 524bffc068
commit 2be0e3847b
16 changed files with 194 additions and 204 deletions

View file

@ -22,7 +22,7 @@ lib.mkIf (config.platform != "mobile")
services.xserver = {
enable = true;
displayManager.defaultSession = "sway";
displayManager.defaultSession = "hyprland";
displayManager.sddm = {
enable = true;
theme = "tokyo-night-sddm";

View file

@ -23,6 +23,8 @@
gcc
];
programs.hyprland.enable = true;
programs.fish.enable = true;
programs.sway.enable = true;
programs.sway.extraPackages = [];

View file

@ -6,8 +6,8 @@
};
imports = [
./sway.nix
./swaytools.nix
./hyprland.nix
./wltools.nix
./waybar.nix
];
}

View file

@ -0,0 +1,158 @@
{ config, pkgs, lib, ... }:
let
scripts = ../../scripts;
modifier = "SUPER";
terminal = "alacritty";
in {
home.packages = with pkgs; [
swaybg
swayidle
wl-clipboard
wtype
wlroots
grim
slurp
imv
];
wayland.windowManager.hyprland = {
enable = true;
enableNvidiaPatches = config.platform == "desktop";
systemd.enable = true;
xwayland.enable = true;
settings = {
"$mod" = modifier;
"$terminal" = terminal;
"$menu" = "rofi -show drun";
exec-once = [
"${scripts}/autostart ${../../assets/background.png}"
];
general = {
border_size = 3;
gaps_in = 8;
gaps_out = 8;
cursor_inactive_timeout = 5;
resize_on_border = true;
"col.inactive_border" = "rgb(474f6f)";
"col.active_border" = "rgb(7bc5e4)";
"col.nogroup_border" = "rgb(d5556f)";
"col.nogroup_border_active" = "rgb(d5556f)";
};
decoration = {
rounding = 10;
"col.shadow" = "rgba(1a1b26c0)";
};
group.groupbar = {
font_family = "JetBrainsMono Nerd Font";
font_size = 14;
};
animations = {
bezier = [ "overshot, 0.13, 0.99, 0.29, 1.1" ];
animation = [
"windowsMove, 1, 4, overshot, slide"
"windowsIn, 1, 2, default, popin 70%"
"windowsOut, 1, 2, default, popin 70%"
"border, 1, 8, default,"
"fade, 1, 8, default,"
"workspaces, 1, 4, overshot, slide"
];
};
misc.disable_hyprland_logo = true;
bind = [
"$mod, Return, exec, $terminal"
"$mod, D, exec, $menu"
"$mod, E, exec, ${scripts}/exit"
"$mod Shift, E, exit,"
"$mod, M, exec, swaylock"
# Emacs Everywhere
"$mod, Q, exec, $HOME/.emacs.d/bin/doom +everywhere"
# Windows
"$mod, Left, movefocus, l"
"$mod, Right, movefocus, r"
"$mod, Up, movefocus, u"
"$mod, Down, movefocus, d"
"$mod, H, movefocus, l"
"$mod, L, movefocus, r"
"$mod, K, movefocus, u"
"$mod, J, movefocus, d"
"$mod Shift, Left, movewindow, l"
"$mod Shift, Right, movewindow, r"
"$mod Shift, Up, movewindow, u"
"$mod Shift, Down, movewindow, d"
"$mod Shift, H, movewindow, l"
"$mod Shift, L, movewindow, r"
"$mod Shift, K, movewindow, u"
"$mod Shift, J, movewindow, d"
"$mod Shift, Q, killactive,"
"$mod, G, togglegroup,"
"$mod, Tab, changegroupactive, f"
"$mod Shift, Tab, changegroupactive, b"
# Workspaces
"$mod, 1, workspace, 1"
"$mod, 2, workspace, 2"
"$mod, 3, workspace, 3"
"$mod, 4, workspace, 4"
"$mod, 5, workspace, 5"
"$mod, 6, workspace, 6"
"$mod, 7, workspace, 7"
"$mod, 8, workspace, 8"
"$mod, 9, workspace, 9"
"$mod, 0, workspace, 10"
# Workspace Movement
"$mod Shift, 1, movetoworkspace, 1"
"$mod Shift, 2, movetoworkspace, 2"
"$mod Shift, 3, movetoworkspace, 3"
"$mod Shift, 4, movetoworkspace, 4"
"$mod Shift, 5, movetoworkspace, 5"
"$mod Shift, 6, movetoworkspace, 6"
"$mod Shift, 7, movetoworkspace, 7"
"$mod Shift, 8, movetoworkspace, 8"
"$mod Shift, 9, movetoworkspace, 9"
"$mod Shift, 0, movetoworkspace, 10"
];
bindl = let
# Volume using pamixer
audio-disp = "${scripts}/multimedia Volume pamixer $(pamixer --get-volume)";
audio = cmd: "pamixer ${cmd} && ${audio-disp}";
# Brightness using brightnessctl
brightness-disp = ''${scripts}/multimedia Brightness brightnessctl $(brightnessctl -e -m | cut -d "," -f4 | tr -d "%")'';
brightness = x: "brightnessctl -e set ${x} && ${brightness-disp}";
in [
# Special XF86 key bindings
", XF86AudioRaiseVolume, exec, ${audio "-i 2"}"
", XF86AudioLowerVolume, exec, ${audio "-d 2"}"
"Shift, XF86AudioRaiseVolume, exec, ${audio "-i 2 --allow-boost"}"
"Shift, XF86AudioLowerVolume, exec, ${audio "-d 2 --allow-boost"}"
", XF86AudioMute, exec, pamixer --toggle-mute"
", XF86AudioMicMute, exec, pactl set-source-mute @DEFAULT_SOURCE@ toggle"
", XF86MonBrightnessDown, exec, ${brightness "4%-"}"
", XF86MonBrightnessUp, exec, ${brightness "4%+"}"
", XF86AudioPlay, exec, playerctl play-pause"
", XF86AudioNext, exec, playerctl next"
", XF86AudioPrev, exec, playerctl previous"
# Screenshot
", Print, exec, ${scripts}/screenshot"
"Shift, Print, exec, ${scripts}/screenshot-slurp"
];
};
};
}

View file

@ -1,6 +1,6 @@
configuration {
cycle: false;
modi: "drun,run,workspace:~/.config/rofi/workspace.sh,workspacemove:~/.config/rofi/workspacemove.sh";
modi: "drun";
font: "JetBrainsMono Nerd Font 14";
location: 0;
terminal: "alacritty";
@ -10,9 +10,6 @@ configuration {
drun-display-format: "{name}";
display-drun: "  Apps ";
display-run: "  Run ";
display-workspace: "  Workspace ";
display-workspacemove: "  Move to Workspace ";
// Bindings
kb-remove-to-eol: "";

View file

@ -1,6 +0,0 @@
@import "config.rasi"
configuration {
show-icons: false;
}

View file

@ -1,8 +0,0 @@
#!/usr/bin/env bash
if [ $# -ne 0 ]; then
swaymsg workspace "$@" > /dev/null
else
swaymsg -t get_workspaces |
jq -r 'map(.name) + ["10:browser","20:terminal","30:code","40:files","50:discord","60:settings"] | unique | .[]'
fi

View file

@ -1,8 +0,0 @@
#!/usr/bin/env bash
if [ $# -ne 0 ]; then
swaymsg move container to workspace "$@" > /dev/null
else
swaymsg -t get_workspaces |
jq -r 'map(.name) + ["10:browser","20:terminal","30:code","40:files","50:discord","60:settings"] | unique | .[]'
fi

View file

@ -1,140 +0,0 @@
{ pkgs, lib, ... }:
let
modifier = "Mod4";
terminal = "alacritty";
in {
home.packages = with pkgs; [
swayidle
wl-clipboard
wtype
wlroots
grim
slurp
imv
];
wayland.windowManager.sway = {
enable = true;
wrapperFeatures.gtk = true;
config = {
inherit modifier terminal;
menu = "rofi -show drun";
fonts = {
names = [ "JetBrainsMono Nerd Font" ];
style = "Medium";
size = 10.0;
};
bars = [{ command = "waybar"; }];
window.border = 3;
gaps = {
inner = 8;
outer = 0;
};
colors = {
unfocused.border = "#474f6f";
unfocused.background = "#1a1b26";
unfocused.text = "#a9b1d6";
unfocused.indicator = "#474f6f";
unfocused.childBorder = "#474f6f";
focused.border = "#7bc5e4";
focused.background = "#1a1b26";
focused.text = "#a9b1d6";
focused.indicator = "#7bc5e4";
focused.childBorder = "#7bc5e4";
focusedInactive.border = "#787c99";
focusedInactive.background = "#1a1b26";
focusedInactive.text = "#a9b1d6";
focusedInactive.indicator = "#787c99";
focusedInactive.childBorder = "#787c99";
urgent.border = "#d5556f";
urgent.background = "#444b6a";
urgent.text = "#ffffff";
urgent.indicator = "#d5556f";
urgent.childBorder = "#d5556f";
};
startup = map (x: { command = x; }) [
''swayidle timeout 120 'swaylock -f --grace=180' \
timeout 600 'systemctl suspend' \
before-sleep 'swaylock -f' ''
''export XDG_SESSION_TYPE=wayland''
''export XDG_CURRENT_DESKTOP=sway''
];
keybindings = let
multimedia = summary: app: value:
''
notify-send ${summary} -c multimedia -a ${app} \
$(makoctl list | jq -r 'first(.data[][]|select(.category.data=="multimedia")|.id.data|["-r",.])[]') \
-h INT:value:$(${value})
'';
# Volume using pamixer
audio-disp = multimedia "Volume" "pamixer" "pamixer --get-volume";
audio = cmd: "exec pamixer ${cmd} && ${audio-disp}";
# Brightness using brightnessctl
brightness-disp = multimedia "Brightness" "brightnessctl" ''brightnessctl -e -m | cut -d "," -f4 | tr -d "%"'';
brightness = x: "exec brightnessctl -e set ${x} && ${brightness-disp}";
# Play controls using playerctl
playerctl = cmd: "exec playerctl ${cmd}";
# Grim screenshot file name
filename = ''~/Pictures/$(date +%Y-%m-%d_%H-%M-%S).png'';
in pkgs.lib.mkOptionDefault {
"${modifier}+Shift+d" = "exec rofi -show run -config ~/.config/rofi/noicons.rasi";
"${modifier}+w" = "exec rofi -show workspace -config ~/.config/rofi/noicons.rasi";
"${modifier}+Shift+w" = "exec rofi -show workspacemove -config ~/.config/rofi/noicons.rasi";
"${modifier}+t" = "layout tabbed";
"${modifier}+Shift+m" = "exec swaylock";
# Emacs Everywhere
"${modifier}+q" = "exec ~/.emacs.d/bin/doom +everywhere";
# Screenshot
"Print" = ''exec grim ${filename}'';
"Shift+Print" = ''exec grim -g "$(slurp)" ${filename}'';
"Mod1+Print" = ''exec grim -g "$(swaymsg -t get_tree | jq -j '.. | \
select(.type?) | select(.focused).rect | "\(.x),\(.y) \(.width)x\(.height)"')" ${filename}'';
# Special XF86 key bindings
"XF86AudioRaiseVolume" = audio "-i 2";
"XF86AudioLowerVolume" = audio "-d 2";
"Shift+XF86AudioRaiseVolume" = audio "-i 2 --allow-boost";
"Shift+XF86AudioLowerVolume" = audio "-d 2 --allow-boost";
"XF86AudioMute" = ''exec pamixer --toggle-mute'';
"XF86AudioMicMute" = ''exec pactl set-source-mute @DEFAULT_SOURCE@ toggle'';
"XF86MonBrightnessDown" = brightness "4%-";
"XF86MonBrightnessUp" = brightness "4%+";
"XF86AudioPlay" = playerctl "play-pause";
"XF86AudioNext" = playerctl "next";
"XF86AudioPrev" = playerctl "previous";
# Exit
"${modifier}+Shift+e" = ''exec pkill -0 swaynag || \
swaynag -t exit -m "Do you really want to exit?" \
-B "Reboot" "reboot" -B "Shutdown" "poweroff" -b "Exit" "swaymsg exit"'';
# Workspaces
"${modifier}+1" = "workspace 10:browser";
"${modifier}+2" = "workspace 20:terminal";
"${modifier}+3" = "workspace 30:code";
"${modifier}+4" = "workspace 40:files";
"${modifier}+5" = "workspace 50:discord";
"${modifier}+6" = "workspace 60:settings";
"${modifier}+Shift+1" = "move container to workspace 10:browser";
"${modifier}+Shift+2" = "move container to workspace 20:terminal";
"${modifier}+Shift+3" = "move container to workspace 30:code";
"${modifier}+Shift+4" = "move container to workspace 40:files";
"${modifier}+Shift+5" = "move container to workspace 50:discord";
"${modifier}+Shift+6" = "move container to workspace 60:settings";
};
output."*".bg = "${../../assets/background.png} fill";
};
};
}

View file

@ -10,8 +10,9 @@
margin = "8 8 0";
modules-left = [ "sway/workspaces" "sway/mode" "custom/sep" "cpu" "memory" "temperature" ];
modules-center = [ "sway/window" ];
modules-left = [ "hyprland/workspaces" "custom/sep" "cpu" "memory" "temperature" ];
modules-center = [ "hyprland/window" ];
modules-right =
if config.platform == "laptop" then
@ -21,33 +22,6 @@
modules = {
"sway/workspaces" = {
disable-scroll = true;
all-outputs = true;
numeric-first = true;
format = "<big>{icon}</big>";
persistent_workspaces = {
"10:browser" = [];
"20:terminal" = [];
"30:code" = [];
"40:files" = [];
"50:discord" = [];
"60:settings" = [];
};
format-icons = {
browser = "${spanfa}<small> </small></span>";
terminal = "${spanfa}</span>";
code = "${spanfa}</span>";
files = "${spanfa}</span>";
discord = "${spanfa}</span>";
settings = "${spanfa}</span>";
};
};
"sway/mode" = {
format = "<span style=\"italic\">{}</span>";
};
"mpd" = {
format = "{stateIcon} {consumeIcon}{randomIcon}{repeatIcon}{singleIcon}{artist} - {album} - {title} ({elapsedTime:%M:%S}/{totalTime:%M:%S}) {songPosition}|{queueLength} ";
format-disconnected = "Disconnected ";
@ -200,17 +174,13 @@
background: @background;
border: none;
padding: 0px 3px;
text-shadow: 0px 0px 2px shade(@blue, 1.1);
}
#workspaces button.persistent {color: @empty;}
#workspaces button.focused {
#workspaces button.active {
color: shade(@pink, 1.1);
text-shadow: 0px 0px 2px shade(@pink, 1.2);
}
#workspaces button.urgent {
background-color: @altred;
color: #ffffff;
}
#clock,
#battery,

9
scripts/autostart Executable file
View file

@ -0,0 +1,9 @@
#!/usr/bin/env bash
swaybg -o '*' -i "$1" -m fill &
waybar &
swayidle timeout 120 'swaylock -f --grace=180' \
timeout 600 'systemctl suspend' \
before-sleep 'swaylock -f' &

4
scripts/exit Executable file
View file

@ -0,0 +1,4 @@
#!/usr/bin/env bash
pkill -0 swaynag || \
swaynag -t exit -m "Do you really want to exit?" \
-B "Reboot" "reboot" -B "Shutdown" "poweroff" -b "Exit" "hyprctl dispatch exit"

4
scripts/multimedia Executable file
View file

@ -0,0 +1,4 @@
#!/usr/bin/env bash
notify-send "$1" -c multimedia -a "$2" \
$(makoctl list | jq -r 'first(.data[][]|select(.category.data=="multimedia")|.id.data|["-r",.])[]') \
-h "INT:value:$3"

4
scripts/screenshot Executable file
View file

@ -0,0 +1,4 @@
#!/usr/bin/env bash
grim - | wl-copy
notify-send "Screenshot saved to clipboard" \
-a grim -c screenshot -u low

4
scripts/screenshot-slurp Executable file
View file

@ -0,0 +1,4 @@
#!/usr/bin/env bash
grim -g "$(slurp)" - | wl-copy
notify-send "Screenshot saved to clipboard" \
-a grim -c screenshot -u low