
# sway

This is a new window manager based on the Wayland protocol.

Wayland itself is being adopted by the linux community as a replacement to xorg's X11, but there are many just like with X.


## notes

Coming from xorg, sway treats each display/monitor separately, meaning they have their own independent workspace, and you cannot drag your mouse across them.  However, the same controls that allow you to re-arrange "containers" on a single monitor directly apply to the second.  **To summarize, no additional or different `bindsym` commands are needed for multi-monitor controls.**

With `waybar` you can minify `corectrl` to the system tray by clicking its icon.  _It seems this package breaks often, so it may require the user to regularly rebuild._

Screen sharing on discord is broken until the developers fix it or implement pipewire support.

There is currently no support for restoring containers to their previous workspaces.  _This makes restarting significantly more messy, as launching a common utility like `firefox` or `subl` (sublime text), will open all containers in the current workspace, and you have to manually re-arrange them._

The `~/.config/sway/config.d/` directory should be used to establish overrides such as custom resolutions, special enhancements, or specific monitor bindings:

	# dual monitor configuration
	output HDMI-A-1 mode --custom 2560x1440@60Hz position 0 0
	output DP-1 mode 3440x1440@144Hz pos 3440 0 adaptive_sync on

	# bind workspaces 9 and 10 to HDMI/HDTV
	workspace 9 output HDMI-A-1
	workspace 10 output HDMI-A-1

	# bind workspaces 1-5 to DP
	workspace 1 output DP-1
	workspace 2 output DP-1
	workspace 3 output DP-1
	workspace 4 output DP-1
	workspace 5 output DP-1

Strange problem with global push-to-talk; had to start it once in order to trigger it, and the state may or may not persist on reboots.

There does not appear to be a way to add temperature support to `waybar`, since by default it reads the first `hwmon` resource, which is often unrelated or unimportant, and selecting the correct ones for CPU and GPU is entirely hardware dependent.  _It may be possible to write a script that generalizes running `sensors` and scanning for common or known driver names in order to grab the correct data._

The scratchpad is a bit messy in that the "cycle" for pulling windows out involves show/hide/show/hide on repeat, rather than show to show to show swapping the pulled window instead.  _It may be possible to script this with `swaymsg` with an iterator._


## nvidia

Since the nvidia proprietary driver is unsupported you may need these in your `~/.bash_profile`:

	export WLR_NO_HARDWARE_CURSORS=1
	alias sway='sway --unsupported-gpu'

_I haven't bought an nVidia GPU for a decade now, so I can't speak to the stability._


# Gaming & HDR

As of 1.1 released in July 2025, Sway supports HDR.

This is set to toggle by default, but can be defined when you configure the displays.

Using `gamescope` you can `--hdr-enabled`, but there are occasional bugs that may require temporary flags like `--hdr-debug-force-support`.

	gamescope --hdr-enabled --hdr-debug-force-support -- vkcube

I have not been able to get SteamVR working, but I'm not sure if that's because of the switch to sway or some other problem between years worth of updates or faulty hardware.




## better temperature scripts

Write a script to grab temperatures to replace the temperature module in waybar with custom commands...

_This is because configuring temperatures is hardware dependent and the waybar has unintelligent defaults and anti-agnostic configuration!_

Example that matters?

for amd cpu: `k10temp` followed by `tctl`
for intel cpu: `coretemp` followed by `package id 0`
for amd gpu `amdgpu` followed by `edge`

for nvidia we need to use `nvidia-smi` and parse that instead, but that also means if `nvidia-smi` does not exist we have to back out!

_For this we will want to have an `exec-if` that checks for results
_There may be cases where there is no GPU, so when no sensors appear can we have the custom module omitted?_

For gpu temperatures:

- `amdgpu`, followed by `edge`

_This may not exist for laptops, may differ for nvidia, and may also differ depending on the driver._

Samples:

	"custom/cputemp": {
		"format": "{}°C",
		"interval": "3",
		"exec": "/usr/local/bin/temps cpu",
		"exec-if": "/usr/local/bin/temps cpu can"
	}
	"custom/gputemp": {
		"format": "GPU: {}°C",
		"interval": "3",
		"exec": "/usr/local/bin/temps gpu",
		"exec-if": "/usr/local/bin/temps gpu can"
	}

_Other people have tried to write their own scripts, but due to the randomized nature of the udev naming, it may require a full programming language to maintain sanity, and it's just not important enough to me to focus on._


## workspace restoration

One problem with sway is that applications with multiple windows, such as the web browser or text editor, do not restore to their previous workspaces.

This seems to be due to the lack of metadata properties (eg. formerly xprops), which are no-longer available to external programs for security purposes.

It may be possible to write an IPC connected utility to save and restore workspaces though.

_This tool would need to know when to save, and to intelligently restore only once when applications are first launched._

It would need to have a way to pull wayland equivalents for the content mentioned in this issue:

- https://github.com/swaywm/sway/issues/1005

_Again, I haven't been bothered by this enough to justify sinking who knows how long into fixing it._


## sessions

I am still testing to verify whether my latest configuration iteration allows me to close sway with `super+x` and launch it again without redundant overlapping services.

The original sway setup involved launching tools with exec commands, but anything loaded as a daemon remains running, so you'd end up with more than one instance.

I've switched to using systemd unit files in an attempt to resolve this, but I also had to change the exit command to stop the entire session.

So far I believe some things may not close out correctly, such as the wallpaper service, but I'm pretty sure sound and the waybar do not duplicate or break.
