Switching to Hyprland

New year new me. So I switched from Sway to Hyprland, and I’m quite happy.

The story goes that I was setting up a Macbook Air for productivity. I was taking inspiration from there and felt soothed by the animations, so I felt inclined to do some ricing again. I was testing it out, and the setup was a breeze, so I stuck with it. (I just installed hyprland in a seperate TTY while I was running in sway, so I could switch back and forth).

Heres my configuration: GitLab: hyprland/.config/hypr/hyprland.conf · master · Fabian Untermoser / dot-file

Getting Used to it

It took a few days of trial & error to kind of replicate my previous Sway setup. It involves a few life improvements such as remapping Capslock to a modifier key, and treat is as escape on a single press. Setting up common shortcuts like screenshotting using grim. I avoided tinkering with the theming.

Screenshotting was done using a submap.

$screenshot_selection = grim -g "$(slurp)" - | wl-copy
$screenshot_window = hyprctl -j activewindow | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"' | grim -g - - | wl-copy && notify-send "Active Window Screenshot"
$screenshot_edit = grim -g "$(slurp)" - | swappy -f -
$screenshot_ocr = grim -g "$(slurp)" - | tesseract - - | wl-copy
exec-once = wl-paste --watch cliphist store
bind = $mod, P, exec, clipboard.sh
 
# screenshot mode
bind = , Print, submap, screenshot
bind = SHIFT, Print, exec, $screenshot_selection
bind = $mod SHIFT, S, exec, $screenshot_selection
bind = $mod ALT, S, exec, $screenshot_window
bind = $mod CTRL SHIFT, S, exec, $screenshot_edit
bind = $mod CTRL ALT, S, exec, $screenshot_ocr
 
submap = screenshot
bind = , Print, exec, $screenshot_selection
bind = , Return, exec, $screenshot_selection
bind = , e, exec, $screenshot_edit
bind = , o, exec, $screenshot_ocr
bind = , Escape, exec, $exit_submap
bind = , Return, exec, $exit_submap
bind = , Return, submap, reset
bind = , Escape, submap, reset
submap = reset
 

After a few months of usage

My previous workflow was based on being able to focus/hide certain windows using modifier keys, similar to a minimize function. The way to do this in hyprland is to use special workspaces.

Special Workspace for KeepassXC

# Special Workspaces
 
# keepassxc
bind = $mod, C, exec, pgrep -x keepassxc || keepassxc
# toggle special workspace
bind = $mod, C, togglespecialworkspace, keepassxc
bind = $mod, C, centerwindow
windowrule = match:class KeePassXC, float on
# assign workspace
windowrule = match:class KeePassXC, workspace special:keepassxc

Special workspaces are not ideal though. Once a special workspace is visible, new windows will be assigned to that workspace. This becomes annoying when you toggle a special workspace with a floating window and soawn a new window. When toggling again the whole workspace dissapears along with the window that you spawned, which feels very unintuitiv.

I had to tweak this at some point for when using my laptop screen along with an external monitor. When my mouse focused an outout and toggled an app from a special workspace, the application window size was off. If i first open the app on my laptop screen, and then focus my bigger external monitor and toggle, the application window size kept its dimensions and position. This resulted in the window that was centered on the previous big screen to be halfway out the laptop screen screen. I created the script hyprland-toggle.sh as an attempt to fix that.

# thunderbird
bind = $mod, T, exec, pgrep -x thunderbird-beta || thunderbird-beta
bind = $mod, T, exec, ~/.config/hypr/scripts/hyprland-toggle.sh thunderbird-beta
 
windowrule = match:class thunderbird-beta, float on
# set initial sizr
windowrule = match:initial_title Mozilla Thunderbird Beta, size 1800 1000, center on
# assign workspacd
windowrule = match:class thunderbird-beta, workspace special:thunderbird