Add Sway session with Waybar and split configs for Hyprland

This commit is contained in:
Fabio Scotto di Santolo
2026-03-31 17:04:05 +02:00
parent e57f2e8253
commit da3c97a35a
19 changed files with 533 additions and 32 deletions

View File

@@ -57,6 +57,20 @@ desktop_hyprland_packages:
- wl-clipboard
- xdg-desktop-portal-hyprland
desktop_sway_packages:
- grim
- kanshi
- slurp
- SwayOSD
- sway
- swayidle
- swaylock
- Waybar
- wl-clipboard
- xfce4-clipman-plugin
- xfce4-screenshooter
- xdg-desktop-portal-wlr
profile_packages:
- alacritty
- bluez
@@ -187,6 +201,28 @@ desktop_hyprland_dotfiles:
dest: .local/bin/screenshot-wayland
mode: "0755"
desktop_sway_dotfiles:
- name: Sway config
src: .config/sway/
dest: .config/sway/
mode: preserve
- name: Waybar config
src: .config/waybar/
dest: .config/waybar/
mode: preserve
- name: Sway wallpaper assets
src: .config/i3/wallpapers/
dest: .config/sway/wallpapers/
mode: preserve
- name: Sway session wrapper
src: .local/bin/start-sway-session
dest: .local/bin/start-sway-session
mode: "0755"
- name: Wayland screenshot script
src: .local/bin/screenshot-wayland
dest: .local/bin/screenshot-wayland
mode: "0755"
desktop_flatpak_packages:
- be.alexandervanhee.gradia
- ch.protonmail.protonmail-bridge

View File

@@ -3,6 +3,7 @@ hostname: nymph
desktop_sessions_enabled:
- i3
- sway
- hyprland
desktop_prompt_for_session: true
@@ -33,3 +34,14 @@ host_hyprland_dotfiles:
- src: .config/hypr/host.conf
dest: .config/hypr/host.conf
mode: "0644"
host_sway_dotfiles:
- src: .config/sway/host.conf
dest: .config/sway/host.conf
mode: "0644"
- src: .config/sway/session-env
dest: .config/sway/session-env
mode: "0644"
- src: .config/kanshi/config
dest: .config/kanshi/config
mode: "0644"

View File

@@ -66,6 +66,11 @@
if 'hyprland' in (desktop_sessions_enabled | default([]))
else []
)
+ (
(desktop_sway_packages | default([]))
if 'sway' in (desktop_sessions_enabled | default([]))
else []
)
+ (host_packages | default([]))
) | unique
}}

View File

@@ -33,3 +33,18 @@
when:
- "'hyprland' in (desktop_sessions_enabled | default([]))"
- (host_hyprland_dotfiles | default([])) | length > 0
- name: Copy host-specific Sway dotfiles
tags: [dotfiles, dotfiles:desktop, dotfiles:host, sway]
ansible.builtin.copy:
src: "{{ playbook_dir }}/../dotfiles/{{ hostname }}/{{ item.src }}"
dest: "{{ user_home }}/{{ item.dest }}"
owner: "{{ username }}"
group: "{{ user_group }}"
mode: "{{ item.mode }}"
loop: "{{ host_sway_dotfiles | default([]) }}"
loop_control:
label: "{{ item.dest }}"
when:
- "'sway' in (desktop_sessions_enabled | default([]))"
- (host_sway_dotfiles | default([])) | length > 0

View File

@@ -0,0 +1,37 @@
---
- name: Ensure Sway config directories exist
tags: [dotfiles, dotfiles:desktop, sway]
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: "{{ username }}"
group: "{{ user_group }}"
mode: "0755"
loop:
- "{{ user_home }}/.config/sway"
- "{{ user_home }}/.config/waybar"
- "{{ user_home }}/.config/kanshi"
when: "'sway' in (desktop_sessions_enabled | default([]))"
- name: Install Sway emptty session entry
tags: [packages, services, emptty, sway]
ansible.builtin.template:
src: Sway.desktop.j2
dest: /etc/emptty/wayland-sessions/Sway.desktop
owner: root
group: root
mode: "0644"
when: "'sway' in (desktop_sessions_enabled | default([]))"
- name: Copy Sway desktop dotfiles
tags: [dotfiles, dotfiles:desktop, sway]
ansible.builtin.copy:
src: "{{ playbook_dir }}/../dotfiles/desktop/{{ item.src }}"
dest: "{{ user_home }}/{{ item.dest }}"
owner: "{{ username }}"
group: "{{ user_group }}"
mode: "{{ item.mode }}"
loop: "{{ desktop_sway_dotfiles | default([]) }}"
loop_control:
label: "{{ item.dest }}"
when: "'sway' in (desktop_sessions_enabled | default([]))"

View File

@@ -0,0 +1,8 @@
[Desktop Entry]
Name=Sway
Comment=Sway Wayland compositor
Exec={{ user_home }}/.local/bin/start-sway-session
TryExec=sway
Type=Application
DesktopNames=sway;wlroots
Keywords=wayland;wm;windowmanager;window;manager;tiling;compositor;

View File

@@ -19,6 +19,7 @@
- services_runit
- profile_desktop_common
- profile_desktop_i3
- profile_desktop_sway
- profile_desktop_hyprland
- profile_desktop_host

View File

@@ -11,7 +11,7 @@ exec-once = dex --autostart --environment Hyprland
exec-once = gnome-keyring-daemon --start --components=secrets
exec-once = ~/.local/bin/setup-gtk-theme
exec-once = hyprpaper
exec-once = waybar
exec-once = waybar -c ~/.config/waybar/config-hyprland.jsonc -s ~/.config/waybar/style.css
exec-once = hypridle
exec-once = dunst
exec-once = pipewire

View File

@@ -0,0 +1,200 @@
set $mod Mod4
set $terminal alacritty
set $fallback_terminal st
set $menu rofi -show drun -theme ~/.config/rofi/config.rasi
set $locker ~/.local/bin/lock-session
set $powermenu ~/.local/bin/powermenu
set $screenshot ~/.local/bin/screenshot-wayland
# Host-specific overrides
include ~/.config/sway/host.conf
font pango:Liberation Mono 10
# Session bootstrap
exec dbus-update-activation-environment --systemd WAYLAND_DISPLAY DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP XDG_SESSION_DESKTOP XDG_SESSION_TYPE XCURSOR_THEME XCURSOR_SIZE
exec systemctl --user import-environment WAYLAND_DISPLAY DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP XDG_SESSION_DESKTOP XDG_SESSION_TYPE XCURSOR_THEME XCURSOR_SIZE
exec dex --autostart --environment sway
exec gnome-keyring-daemon --start --components=secrets
exec ~/.local/bin/setup-gtk-theme
exec waybar -c ~/.config/waybar/config-sway.jsonc -s ~/.config/waybar/style.css
# Session services
exec pipewire
exec pipewire-pulse
exec wireplumber
exec kanshi
exec swayidle -w timeout 600 '~/.local/bin/lock-session' timeout 900 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' before-sleep '~/.local/bin/lock-session'
# Tray and desktop applets
exec dunst
exec swayosd-server
exec /usr/libexec/xfce-polkit
exec nm-applet
exec blueman-applet
exec udiskie --tray --automount
exec xfce4-clipman
# Input and output defaults
seat seat0 xcursor_theme Yaru 24
output * bg ~/.config/sway/wallpapers/dont_like_wallpapers.jpg fill
input type:keyboard {
xkb_layout us
xkb_variant intl
}
focus_follows_mouse no
mouse_warping none
floating_modifier $mod normal
# Borders
default_border pixel 2
default_floating_border pixel 2
hide_edge_borders none
# Floating rules
for_window [app_id="Rofi"] floating enable
for_window [app_id="org.pulseaudio.pavucontrol"] floating enable
for_window [class="Pavucontrol"] floating enable
for_window [app_id="nm-connection-editor"] floating enable
for_window [class="Nm-connection-editor"] floating enable
for_window [app_id="blueman-manager"] floating enable
for_window [class="Blueman-manager"] floating enable
set $left h
set $down j
set $up k
set $right l
# App launchers and window actions
bindsym $mod+Return exec $terminal
bindsym $mod+Shift+Return exec $fallback_terminal
bindsym $mod+d exec $menu
bindsym $mod+Shift+v exec pavucontrol
bindsym $mod+Shift+f exec thunar
bindsym $mod+Shift+x exec $locker
bindsym $mod+Shift+q kill
# Screenshots
bindsym Print exec sh -c 'xfce4-screenshooter -f || ~/.local/bin/screenshot-wayland full'
bindsym Shift+Print exec sh -c 'xfce4-screenshooter -r || ~/.local/bin/screenshot-wayland region'
bindsym Alt+Print exec sh -c 'xfce4-screenshooter -w || ~/.local/bin/screenshot-wayland output'
# Focus
bindsym $mod+$left focus left
bindsym $mod+$down focus down
bindsym $mod+$up focus up
bindsym $mod+$right focus right
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right
# Move windows
bindsym $mod+Shift+$left move left
bindsym $mod+Shift+$down move down
bindsym $mod+Shift+$up move up
bindsym $mod+Shift+$right move right
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right
# Split and layouts
bindsym $mod+b split h
bindsym $mod+v split v
bindsym $mod+f fullscreen toggle
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split
bindsym $mod+Shift+space floating toggle
bindsym $mod+space focus mode_toggle
bindsym $mod+a focus parent
# Scratchpad
bindsym $mod+Shift+minus move scratchpad
bindsym $mod+minus scratchpad show
# Volume and brightness OSD
bindsym XF86AudioRaiseVolume exec swayosd-client --output-volume raise
bindsym XF86AudioLowerVolume exec swayosd-client --output-volume lower
bindsym XF86AudioMute exec swayosd-client --output-volume mute-toggle
bindsym XF86AudioMicMute exec swayosd-client --input-volume mute-toggle
bindsym XF86MonBrightnessUp exec swayosd-client --brightness raise
bindsym XF86MonBrightnessDown exec swayosd-client --brightness lower
# Media keys
bindsym XF86AudioPlay exec playerctl play-pause
bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous
# Workspaces
set $ws1 1
set $ws2 2
set $ws3 3
set $ws4 4
set $ws5 5
set $ws6 6
set $ws7 7
set $ws8 8
set $ws9 9
set $ws10 10
bindsym $mod+1 workspace number $ws1
bindsym $mod+2 workspace number $ws2
bindsym $mod+3 workspace number $ws3
bindsym $mod+4 workspace number $ws4
bindsym $mod+5 workspace number $ws5
bindsym $mod+6 workspace number $ws6
bindsym $mod+7 workspace number $ws7
bindsym $mod+8 workspace number $ws8
bindsym $mod+9 workspace number $ws9
bindsym $mod+0 workspace number $ws10
bindsym $mod+Shift+1 move container to workspace number $ws1
bindsym $mod+Shift+2 move container to workspace number $ws2
bindsym $mod+Shift+3 move container to workspace number $ws3
bindsym $mod+Shift+4 move container to workspace number $ws4
bindsym $mod+Shift+5 move container to workspace number $ws5
bindsym $mod+Shift+6 move container to workspace number $ws6
bindsym $mod+Shift+7 move container to workspace number $ws7
bindsym $mod+Shift+8 move container to workspace number $ws8
bindsym $mod+Shift+9 move container to workspace number $ws9
bindsym $mod+Shift+0 move container to workspace number $ws10
# Reload and power menu
bindsym $mod+Shift+c reload
bindsym $mod+Shift+r reload
bindsym $mod+Shift+BackSpace exit
bindsym $mod+Shift+Escape exec $powermenu
# Resize mode
mode "resize" {
bindsym $left resize shrink width 10 px or 10 ppt
bindsym $down resize grow height 10 px or 10 ppt
bindsym $up resize shrink height 10 px or 10 ppt
bindsym $right resize grow width 10 px or 10 ppt
bindsym Left resize shrink width 10 px or 10 ppt
bindsym Down resize grow height 10 px or 10 ppt
bindsym Up resize shrink height 10 px or 10 ppt
bindsym Right resize grow width 10 px or 10 ppt
bindsym Return mode "default"
bindsym Escape mode "default"
bindsym $mod+r mode "default"
}
bindsym $mod+r mode "resize"
client.focused #4a90d9 #4a90d9 #ffffff #4a90d9 #4a90d9
client.focused_inactive #3a3a46 #2b2b36 #eeeeee #3a3a46 #3a3a46
client.unfocused #2b2b36 #1f1f28 #bcbcbc #2b2b36 #2b2b36
client.urgent #c7162b #c7162b #ffffff #c7162b #c7162b
client.placeholder #1f1f28 #1f1f28 #bcbcbc #1f1f28 #1f1f28
client.background #1f1f28

View File

@@ -0,0 +1 @@
# Host-specific Sway overrides live here.

View File

@@ -12,13 +12,12 @@
"pulseaudio",
"backlight",
"network",
"bluetooth",
"battery",
"temperature",
"memory",
"clock",
"custom/powermenu",
"tray"
"tray",
"custom/powermenu"
],
"hyprland/workspaces": {
@@ -31,8 +30,9 @@
"pulseaudio": {
"scroll-step": 1,
"format": "VOL {volume}%",
"format-muted": "MUTE",
"format": "󰕾 {volume}%",
"format-bluetooth": "󰂯 {volume}%",
"format-muted": "󰖁",
"on-click": "pavucontrol",
"tooltip": false
},
@@ -41,16 +41,16 @@
"device": "intel_backlight",
"on-scroll-up": "brightnessctl set +5%",
"on-scroll-down": "brightnessctl set 5%-",
"format": "BL {percent}%"
"format": "󰃠 {percent}%"
},
"network": {
"interval": 1,
"tooltip": true,
"format-wifi": "WIFI",
"format-ethernet": "ETH",
"format-linked": "LINK",
"format-disconnected": "OFF",
"format-wifi": "󰖩",
"format-ethernet": "󰈀",
"format-linked": "󰈀",
"format-disconnected": "󰖪",
"tooltip-format": "{ifname}",
"tooltip-format-wifi": "{essid} ({signalStrength}%)",
"tooltip-format-ethernet": "{ifname}",
@@ -58,34 +58,28 @@
"on-click": "nm-connection-editor"
},
"bluetooth": {
"format": "BT",
"format-connected": "BT {device_alias}",
"format-off": "BT OFF",
"on-click": "blueman-manager"
},
"battery": {
"interval": 10,
"states": {
"warning": 20,
"critical": 10
},
"format": "BAT {capacity}%",
"format-charging": "BAT {capacity}% AC",
"format-plugged": "BAT {capacity}% AC",
"format": "{icon} {capacity}%",
"format-charging": "󰂄 {capacity}%",
"format-plugged": "󰂄 {capacity}%",
"format-alt": "{time}"
,"format-icons": ["󰁺", "󰁻", "󰁼", "󰁽", "󰁾", "󰁿", "󰂀", "󰂁", "󰂂", "󰁹"]
},
"temperature": {
"critical-threshold": 80,
"format": "TMP {temperatureC}C",
"format": "󰔏 {temperatureC}C",
"tooltip": false
},
"memory": {
"interval": 5,
"format": "MEM {percentage}%",
"format": "󰍛 {percentage}%",
"states": {
"warning": 85
}
@@ -94,18 +88,19 @@
"clock": {
"interval": 60,
"timezone": "Europe/Rome",
"format": "{:%Y-%m-%d %H:%M}",
"format-alt": "{:%A %d/%m/%Y}"
"format": "󰥔 {:%Y-%m-%d %H:%M}",
"format-alt": "{:%A %d/%m/%Y}",
"tooltip-format": "{:%A %d %B %Y\n%H:%M:%S %Z}"
},
"custom/powermenu": {
"format": "POWER",
"format": "",
"on-click": "~/.local/bin/powermenu",
"tooltip": false
},
"tray": {
"icon-size": 15,
"spacing": 6
"spacing": 4
}
}

View File

@@ -0,0 +1,105 @@
{
"layer": "top",
"position": "bottom",
"height": 28,
"spacing": 4,
"modules-left": [
"sway/workspaces"
],
"modules-right": [
"pulseaudio",
"backlight",
"network",
"battery",
"temperature",
"memory",
"clock",
"tray",
"custom/powermenu"
],
"sway/workspaces": {
"disable-scroll": true,
"all-outputs": true,
"format": "{name}",
"sort-by-number": true
},
"pulseaudio": {
"scroll-step": 1,
"format": "󰕾 {volume}%",
"format-bluetooth": "󰂯 {volume}%",
"format-muted": "󰖁",
"on-click": "pavucontrol",
"tooltip": false
},
"backlight": {
"device": "intel_backlight",
"on-scroll-up": "brightnessctl set +5%",
"on-scroll-down": "brightnessctl set 5%-",
"format": "󰃠 {percent}%"
},
"network": {
"interval": 1,
"tooltip": true,
"format-wifi": "󰖩",
"format-ethernet": "󰈀",
"format-linked": "󰈀",
"format-disconnected": "󰖪",
"tooltip-format": "{ifname}",
"tooltip-format-wifi": "{essid} ({signalStrength}%)",
"tooltip-format-ethernet": "{ifname}",
"tooltip-format-disconnected": "Disconnected",
"on-click": "nm-connection-editor"
},
"battery": {
"interval": 10,
"states": {
"warning": 20,
"critical": 10
},
"format": "{icon} {capacity}%",
"format-charging": "󰂄 {capacity}%",
"format-plugged": "󰂄 {capacity}%",
"format-alt": "{time}"
,"format-icons": ["󰁺", "󰁻", "󰁼", "󰁽", "󰁾", "󰁿", "󰂀", "󰂁", "󰂂", "󰁹"]
},
"temperature": {
"critical-threshold": 80,
"format": "󰔏 {temperatureC}C",
"tooltip": false
},
"memory": {
"interval": 5,
"format": "󰍛 {percentage}%",
"states": {
"warning": 85
}
},
"clock": {
"interval": 60,
"timezone": "Europe/Rome",
"format": "󰥔 {:%Y-%m-%d %H:%M}",
"format-alt": "{:%A %d/%m/%Y}",
"tooltip-format": "{:%A %d %B %Y\n%H:%M:%S %Z}"
},
"custom/powermenu": {
"format": "⏻",
"on-click": "~/.local/bin/powermenu",
"tooltip": false
},
"tray": {
"icon-size": 15,
"spacing": 4
}
}

View File

@@ -4,14 +4,19 @@
min-height: 0;
padding: 0;
margin: 0;
font-family: "Liberation Mono", monospace;
font-size: 12px;
}
window#waybar {
background: #1f1f28;
color: #d0d0d0;
border-top: 2px solid #3a3a46;
font-family: "Liberation Mono", "Symbols Nerd Font", monospace;
font-size: 12px;
}
window#waybar * {
font-family: inherit;
font-size: inherit;
}
#workspaces,
@@ -46,9 +51,11 @@ window#waybar {
background: transparent;
}
#workspaces button.active {
#workspaces button.active,
#workspaces button.focused {
background: #4a90d9;
color: #ffffff;
border-top: 2px solid #4a90d9;
border-top: 2px solid #6daeea;
}
#workspaces button.urgent {
@@ -80,7 +87,13 @@ window#waybar {
}
#tray {
padding-right: 12px;
padding: 0 8px;
}
menu,
menuitem {
font-family: "Liberation Sans", sans-serif;
font-size: 11px;
}
tooltip {

View File

@@ -3,6 +3,25 @@
set -eu
case "${XDG_CURRENT_DESKTOP:-}" in
*sway*|*Sway*)
exec swaylock -f \
--color 000000ff \
--inside-color 1f1f28ff \
--ring-color 2f4058ff \
--separator-color 3a3a46ff \
--line-color 00000000 \
--key-hl-color 6daeeaff \
--bs-hl-color c7162bff \
--inside-ver-color 1f1f28ff \
--inside-wrong-color 1f1f28ff \
--ring-ver-color 4a90d9ff \
--ring-wrong-color c7162bff \
--text-color d0d0d0ff \
--text-ver-color d0d0d0ff \
--text-wrong-color d0d0d0ff \
--indicator \
--clock
;;
*Hyprland*|*hyprland*)
exec hyprlock
;;
@@ -15,6 +34,10 @@ if command -v hyprlock >/dev/null 2>&1; then
exec hyprlock
fi
if command -v swaylock >/dev/null 2>&1; then
exec swaylock -f
fi
if [ -x "$HOME/.config/i3/scripts/lockscreen" ]; then
exec "$HOME/.config/i3/scripts/lockscreen"
fi

View File

@@ -17,6 +17,9 @@ case "$choice" in
;;
Logout)
case "${XDG_CURRENT_DESKTOP:-}" in
*sway*|*Sway*)
swaymsg exit
;;
*Hyprland*|*hyprland*)
hyprctl dispatch exit
;;

View File

@@ -0,0 +1,27 @@
#!/bin/sh
[ -r /etc/profile ] && . /etc/profile
[ -r "$HOME/.profile" ] && . "$HOME/.profile"
[ -r "$HOME/.config/sway/session-env" ] && . "$HOME/.config/sway/session-env"
set -eu
session_name=sway
export XDG_CURRENT_DESKTOP="$session_name"
export XDG_SESSION_DESKTOP="$session_name"
export XDG_SESSION_TYPE=wayland
if [ "${SWAY_UNSUPPORTED_GPU:-0}" = "1" ]; then
set -- sway --unsupported-gpu
else
set -- sway
fi
exec dbus-run-session sh -eu -c '
umask 077
printf "%s\n" "$DBUS_SESSION_BUS_ADDRESS" > "$HOME/.dbus-session-bus-address"
eval "$(ssh-agent -s)" >/dev/null
gpgconf --launch gpg-agent
exec "$@"
' sh "$@"

View File

@@ -0,0 +1,15 @@
profile solo {
output DP-1 disable
output DP-2 disable
output HDMI-A-1 disable
output HDMI-A-2 disable
output eDP-1 enable mode 1920x1080 position 0,0
}
profile dual {
output DP-2 disable
output HDMI-A-1 disable
output HDMI-A-2 disable
output eDP-1 enable mode 1920x1080 position 0,0
output DP-1 enable mode 3440x1440@100Hz position 1920,0
}

View File

@@ -0,0 +1 @@
set $terminal ~/.local/bin/prime-run /usr/bin/alacritty

View File

@@ -0,0 +1,4 @@
export LIBVA_DRIVER_NAME=iHD
export SWAY_UNSUPPORTED_GPU=1
export WLR_DRM_DEVICES=/dev/dri/card0:/dev/dri/card1
export WLR_NO_HARDWARE_CURSORS=1