From 986b1039ed12895c06d48da0f424ef365b90d65c Mon Sep 17 00:00:00 2001 From: stephen Date: Thu, 12 Dec 2024 04:22:16 +0000 Subject: [PATCH] 1.0.0, with readme --- Cargo.lock | 2 +- Cargo.toml | 4 ++- README.md | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 README.md diff --git a/Cargo.lock b/Cargo.lock index dadbf1e..2ef03c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -103,7 +103,7 @@ dependencies = [ [[package]] name = "swayout" -version = "0.1.0" +version = "1.0.0" dependencies = [ "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index 31b658b..b5bcbd2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,9 @@ [package] name = "swayout" -version = "0.1.0" +version = "1.0.0" edition = "2021" +description = "A tool to configure sway outputs" +authors = ["Stephen Byrne"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/README.md b/README.md new file mode 100644 index 0000000..550d204 --- /dev/null +++ b/README.md @@ -0,0 +1,83 @@ +# swayout + +`swayout` is a utility to configure [sway](https://swaywm.org/) outputs. + +[kanshi](https://sr.ht/~emersion/kanshi/) and [way-displays](https://github.com/alex-courtis/way-displays) certainly +do a better job of this. I wrote this because I wanted a project to learn Rust. + +Monitors and layouts are configured in a toml file +(`~/.config/swayout/config.toml`). + +Example `config.toml`: + +```toml +# This is my laptop's built-in screen. +[monitors.laptop] +make = "Unknown" +model = "0x403D" +serial = "0x00000000" + +# I usually have it hooked up to this monitor, which is the top one on my desk. +[monitors.top] +make = "Dell Inc." +model = "DELL U2415" +serial = "CFV9N99T0Y0U" + +# Sometimes I hook it up to these monitors, which are left and right. +# The left is rotated 270 degrees. +[monitors.left] +make = "Goldstar Company Ltd" +model = "LG HDR 4K" +serial = "0x0000B9C0" +[monitors.right] +make = "Goldstar Company Ltd" +model = "LG HDR 4K" +serial = "0x0000B9BF" + +# When I have "left" and "right" hooked up, I want this layout. +[layouts.two4k.left] +mode = "3840x2160" +scale = "1.5" +x = 0 +y = 0 +transform = "270" +[layouts.two4k.right] +mode = "3840x2160" +scale = "1.5" +x = 1440 +y = 1120 +transform = "normal" +``` + +When you run `swayout`, it prints all available layout names to standard output, one per line. +Printed layouts include: + +* All layouts defined in `config.toml` for which the monitors are currently available. E.g.: `two4k`. +* All monitors defined in `config.toml` that are currently available. E.g.: `laptop`, `left`, `right`. +* All available outputs that are not matched by a configured monitor. E.g.: `HDMI-2`. + +If you pass a layout name (or monitor name, or output name) as a command line argument to `swayout`, +it calls `swaymsg` to configure that layout. +If a monitor name or output name is passed, only that monitor or output is enabled, and the output's defaults are used. + +This behavior is useful in conjunction with [tofi](https://github.com/philj56/tofi). +My sway configuration has: + +``` +set $select_layout swayout | tofi | xargs swayout +bindsym $mod+Shift+m exec $select_layout +``` + +## TODO + +Things I might do someday: + +### Automatic + +Add a `automatic` option to layouts and an `--automatic` flag to `swayout`, and have it automatically enable the +first layout with `automatic=true` for which all outputs are available. + +This could be run by `bindswitch lid:toggle exec swayout --automatic`. + +How to call when an output is connected or disconnected? +Wayland events via [wayland_client](https://docs.rs/wayland-client/latest/wayland_client/index.html)? \ No newline at end of file