~tsdh/swayr

5ec67b307b99601aef8392678d7c1eba691bddda — Tassilo Horn 2 months ago 8cea829
Improve layouting commands and update deps
5 files changed, 35 insertions(+), 26 deletions(-)

M Cargo.lock
M Cargo.toml
M src/cmds.rs
M src/layout.rs
M src/util.rs
M Cargo.lock => Cargo.lock +18 -18
@@ 73,9 73,9 @@ dependencies = [

[[package]]
name = "directories"
version = "3.0.2"
version = "4.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e69600ff1703123957937708eb27f7a564e48885c537782722ed0ba3189ce1d7"
checksum = "5f0435dee2e8f0783bd48571bd8a8a8f531b5adcf0b8d7dc705a37c81108418d"
dependencies = [
 "dirs-sys",
]


@@ 150,9 150,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"

[[package]]
name = "libc"
version = "0.2.101"
version = "0.2.102"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3cb00336871be5ed2c8ed44b60ae9959dc5b9f08539422ed43f09e34ecaeba21"
checksum = "a2a5ac8f984bfcf3a823267e5fde638acc3325f6496633a5da6bb6eb2171e103"

[[package]]
name = "memchr"


@@ 198,9 198,9 @@ dependencies = [

[[package]]
name = "proc-macro2"
version = "1.0.28"
version = "1.0.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612"
checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d"
dependencies = [
 "unicode-xid",
]


@@ 298,18 298,18 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"

[[package]]
name = "serde"
version = "1.0.129"
version = "1.0.130"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d1f72836d2aa753853178eda473a3b9d8e4eefdaf20523b919677e6de489f8f1"
checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913"
dependencies = [
 "serde_derive",
]

[[package]]
name = "serde_derive"
version = "1.0.129"
version = "1.0.130"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e57ae87ad533d9a56427558b516d0adac283614e347abf85b0dc0cbbf0a249f3"
checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b"
dependencies = [
 "proc-macro2",
 "quote",


@@ 318,9 318,9 @@ dependencies = [

[[package]]
name = "serde_json"
version = "1.0.66"
version = "1.0.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "336b10da19a12ad094b59d870ebde26a45402e5b470add4b5fd03c5048a32127"
checksum = "0f690853975602e1bfe1ccbf50504d67174e3bcf340f23b5ea9992e0587a52d8"
dependencies = [
 "itoa",
 "ryu",


@@ 372,9 372,9 @@ dependencies = [

[[package]]
name = "syn"
version = "1.0.75"
version = "1.0.76"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7f58f7e8eaa0009c5fec437aabf511bd9933e4b2d7407bd05273c01a8906ea7"
checksum = "c6f107db402c2c2055242dbf4d2af0e69197202e9faacbef9571bbe47f5a1b84"
dependencies = [
 "proc-macro2",
 "quote",


@@ 401,18 401,18 @@ dependencies = [

[[package]]
name = "thiserror"
version = "1.0.26"
version = "1.0.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93119e4feac1cbe6c798c34d3a53ea0026b0b1de6a120deef895137c0529bfe2"
checksum = "602eca064b2d83369e2b2f34b09c70b605402801927c65c11071ac911d299b88"
dependencies = [
 "thiserror-impl",
]

[[package]]
name = "thiserror-impl"
version = "1.0.26"
version = "1.0.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "060d69a0afe7796bf42e9e2ff91f5ee691fb15c53d38b4b62a9a53eb23164745"
checksum = "bad553cc2c78e8de258400763a647e80e6d1b31ee237275d756f6836d204494c"
dependencies = [
 "proc-macro2",
 "quote",

M Cargo.toml => Cargo.toml +1 -1
@@ 15,7 15,7 @@ serde_json = "1.0.64"
clap = "3.0.0-beta.2"
swayipc = "3.0.0-alpha.3"
toml = "0.5.8"
directories = "3.0"
directories = "4.0"
regex = "1.5.4"
lazy_static = "1.4.0"
rand = "0.8.4"

M src/cmds.rs => src/cmds.rs +7 -5
@@ 350,16 350,18 @@ fn tile_current_workspace(include_floating: bool, shuffle: bool) {
                wins.reverse()
            }
            for win in wins {
                if win.is_floating() {
                    std::thread::sleep(std::time::Duration::from_millis(25));
                    con.run_command(format!(
                        "[con_id={}] floating disable",
                        win.get_id()
                    ))?;
                }
                std::thread::sleep(std::time::Duration::from_millis(25));
                con.run_command(format!(
                    "[con_id={}] move to workspace current",
                    win.get_id()
                ))?;
                std::thread::sleep(std::time::Duration::from_millis(25));
                con.run_command(format!(
                    "[con_id={}] floating disable",
                    win.get_id()
                ))?;
                placed_wins.push(win);
                if shuffle {
                    std::thread::sleep(std::time::Duration::from_millis(25));

M src/layout.rs => src/layout.rs +5 -2
@@ 125,6 125,8 @@ pub fn maybe_auto_tile(config: &config::Config) {
    }
}

const SWAYR_TMP_WORKSPACE: &str = "✨";

pub fn relayout_current_workspace(
    include_floating: bool,
    insert_win_fn: Box<


@@ 146,8 148,9 @@ pub fn relayout_current_workspace(
                }
                moved_wins.push(win);
                con.run_command(format!(
                    "[con_id={}] move to scratchpad",
                    win.get_id()
                    "[con_id={}] move to workspace {}",
                    win.get_id(),
                    SWAYR_TMP_WORKSPACE
                ))?;
            }


M src/util.rs => src/util.rs +4 -0
@@ 23,6 23,10 @@ use std::path as p;
use std::process as proc;

pub fn get_swayr_socket_path() -> String {
    // We prefer checking the env variable instead of
    // directories::BaseDirs::new().unwrap().runtime_dir().unwrap() because
    // directories errors if the XDG_RUNTIME_DIR isn't set or set to a relative
    // path which actually works fine for sway & swayr.
    let xdg_runtime_dir = std::env::var("XDG_RUNTIME_DIR");
    let wayland_display = std::env::var("WAYLAND_DISPLAY");
    format!(