hyprland-community/hyprland-autoname-workspaces

[BUG] hyprland-autoname-workspace crashes when new workspace/client name includes character '/'

psimovec opened this issue ยท 21 comments

Describe the bug
When I try to change name of client to include forward slash '/', hyprland-autoname-workspace crashes.
Goal is to add colors dynamically to waybar, something like hyprctl dispatch renameworkspace 6 '<span color="blue">6</span>' works.
To Reproduce
Steps to reproduce the behavior:

  1. Add to your config something like: "(?i)Kitty" = '/'
  2. run hyprland-autoname-workspaces
  3. crash

Expected behavior
Rename the client to /, do not crash

Linux Distro (please complete the following information):
Arch

**Program version?

tag 0.4.4, commit 09a64e3
Additional context

> RUST_BACKTRACE=full cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.08s
     Running `target/debug/hyprland-autoname-workspaces`
thread 'main' panicked at 'App can't rename workspaces on st   0:     0x55d058a6153a - std::backtrace_rs::backtrace::libstack backtrace:
98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:692:13
unwind::trace::h38953cd7b82c38d3
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x55d058a6153a - std::backtrace_rs::backtrace::trace_unsynchronized::h53802a8b087ae509
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x55d058a6153a - std::sys_common::backtrace::_print_fmt::h0806bc2b3dfbb06c
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x55d058a6153a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h6bd42fa772461846
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x55d058a828be - core::fmt::write::h086d90dd8e1b1a3f
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/fmt/mod.rs:1232:17
   5:     0x55d058a5e845 - std::io::Write::write_fmt::h18f12173b1839b43
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/io/mod.rs:1684:15
   6:     0x55d058a61305 - std::sys_common::backtrace::_print::hfeb1e373746d03b6
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x55d058a61305 - std::sys_common::backtrace::print::h9dc79345d5a578b2
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x55d058a62abf - std::panicking::default_hook::{{closure}}::h45526a9efda640f6
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:271:22
   9:     0x55d058a627fb - std::panicking::default_hook::h3e08227c1528c168
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:290:9
  10:     0x55d058a63068 - std::panicking::rust_panic_with_hook::he81c02edd7e7b80e
                               at /rustc/84c898d65adf2f39a5aer::{{closure}}::h98331a6e5528817d
  11:     0x55d058a62f69 - std::panicking::begin_panic_handl  23:     0x55d058a5963c - std::panicking::try::h5074e9976b1                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:583:13
  12:     0x55d058a619a6 - std::sys_common::backtrace::__rust_end_short_backtrace::h83c0d32dd2d13f12
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:150:18
  13:     0x55d058a62c72 - rust_begin_unwind
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:579:5
  14:     0x55d0585c9aa3 - core::panicking::panic_fmt::h9ad38cbb8980e66e
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/panicking.rs:64:14
  15:     0x55d0585c9f53 - core::result::unwrap_failed::h6787e69082462417
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/result.rs:1750:5
  16:     0x55d0585f59be - core::result::Result<T,E>::expect::h7a233c435d697425
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/result.rs:1047:23
  17:     0x55d0586201b9 - hyprland_autoname_workspaces::main::h539590fcc564dce9
                               at /home/psimovec/test/hyprland-autoname-workspaces/src/main.rs:20:5
  18:     0x55d05862228b - core::ops::function::FnOnce::call_once::h839c23dcd80ffa6e
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/ops/function.rs:250:5
  19:     0x55d05860646e - std::sys_common::backtrace::__rust_begin_short_backtrace::h0def45c3f2f047f3
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:134:18
  20:     0x55d058608ea1 - std::rt::lang_start::{{closure}}::h5feba351e3d9119c
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/rt.rs:166:18
  21:     0x55d058a5963c - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h814f0ad687ab2f92
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/ops/function.rs:287:13
  22:     0x55d058a5963c - std::panicking::try::do_call::had9b6a5cabf2fdc8
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:487:40
                               at /rustc/84c898d65adf2f39a5a3e92c
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:451:19
  24:     0x55d058a5963c - std::panic::catch_unwind::he1669253985d4352
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panic.rs:140:14
  25:     0x55d058a5963c - std::rt::lang_start_internal::{{closure}}::hd778e2099ecb758e
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/rt.rs:148:48
  26:     0x55d058a5963c - std::panicking::try::do_call::h1ce263ca927523fa
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:487:40
  27:     0x55d058a5963c - std::panicking::try::he3d901a7a8ca0bfd
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:451:19
  28:     0x55d058a5963c - std::panic::catch_unwind::hb9e5b8ae73c93b8f
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panic.rs:140:14
  29:     0x55d058a5963c - std::rt::lang_start_internal::h2947494479068ade
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/rt.rs:148:20
  30:     0x55d058608e7a - std::rt::lang_start::he46f5779c6465a34
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/rt.rs:165:17
  31:     0x55d0586203be - main
  32:     0x7f1bca3cb790 - <unknown>
  33:     0x7f1bca3cb84a - __libc_start_main
  34:     0x55d0585ca135 - _start
  35:                0x0 - <unknown>```

Are you QA engineer? Thanks ๐Ÿ˜„

Are you QA engineer? Thanks smile

I used to be QE intern for 2 years ๐Ÿ˜„

Can you try to escape the / with \/ ? (didn't try)

Are you QA engineer? Thanks smile

I used to be QE intern for 2 years smile

Feel free to polish the README please when you will be hyprland-autoname-workspaces expert ๐Ÿ™๐Ÿป

Can you try to escape the / with \/ ? (didn't try)

I tried that and it didn't work, but I tried it again with full debug and the error message is different - Invalid escape

RUST_BACKTRACE=full cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.08s
     Running `target/debug/hyprland-autoname-workspaces`
thread 'main' panicked at 'Unable to read config: "Unable to parse: Error { inner: ErrorInner { kind: InvalidEscape('/'), line: Some(11), col: 16, at: Some(330), message: \"\", key: [] } }"', src/main.rs:16:29
stack backtrace:
   0:     0x5555b961453a - std::backtrace_rs::backtrace::libunwind::trace::h38953cd7b82c38d3
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x5555b961453a - std::backtrace_rs::backtrace::tra98507f1fe0ce10a2b8dbc/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:150:18
   2:     0x5555b961453a - std::sys_common::backtrace::_print_fmt::h0806bc2b3dfbb06c
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x5555b961453a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h6bd42fa772461846
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x5555b96358be - core::fmt::write::h086d90dd8e1b1a3f
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/fmt/mod.rs:1232:17
   5:     0x5555b9611845 - std::io::Write::write_fmt::h18f12173b1839b43
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/io/mod.rs:1684:15
   6:     0x5555b9614305 - std::sys_common::backtrace::_print::hfeb1e373746d03b6
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x5555b9614305 - std::sys_common::backtrace::print::h9dc79345d5a578b2
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x5555b9615abf - std::panicking::default_hook::{{closure}}::h45526a9efda640f6
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:271:22
   9:     0x5555b96157fb - std::panicking::default_hook::h3e08227c1528c168
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:290:9
  10:     0x5555b9616068 - std::panicking::rust_panic_with_hook::he81c02edd7e7b80e
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:692:13
  11:     0x5555b9615f69 - std::panicking::begin_panic_handler::{{closure}}::h98331a6e5528817d
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:583:13
  12:     0x5555b96149a6 - std::sys_common::backtrace::__rust_end_short_backtrace::h83c0d32dd2d13f12
                               at /rustc/84c898d65adf2f39a5a  13:     0x5555b9615c72 - rust_begin_unwind
                               at /rustc/84c898d65adf2f39a5a  25:     0x5555b960c63c - std::rt::lang_start_internal::{{closure}}::hd778e2099ecb758e
98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:579:5
  14:     0x5555b917caa3 - core::panicking::panic_fmt::h9ad38cbb8980e66e
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/panicking.rs:64:14
  15:     0x5555b917cf53 - core::result::unwrap_failed::h6787e69082462417
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/result.rs:1750:5
  16:     0x5555b91a8c49 - core::result::Result<T,E>::expect::he04abbcc0b0fdde7
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/result.rs:1047:23
  17:     0x5555b91d04ea - hyprland_autoname_workspaces::main::h539590fcc564dce9
                               at /home/psimovec/test/hyprland-autoname-workspaces/src/main.rs:16:15
  18:     0x5555b91d528b - core::ops::function::FnOnce::call_once::h839c23dcd80ffa6e
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/ops/function.rs:250:5
  19:     0x5555b91b946e - std::sys_common::backtrace::__rust_begin_short_backtrace::h0def45c3f2f047f3
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/sys_common/backtrace.rs:134:18
  20:     0x5555b91bbea1 - std::rt::lang_start::{{closure}}::h5feba351e3d9119c
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/rt.rs:166:18
  21:     0x5555b960c63c - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h814f0ad687ab2f92
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/ops/function.rs:287:13
  22:     0x5555b960c63c - std::panicking::try::do_call::had9b6a5cabf2fdc8
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:487:40
  23:     0x5555b960c63c - std::panicking::try::h5074e9976b13e92c
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:451:19
  24:     0x5555b960c63c - std::panic::catch_unwind::he1669253985d4352
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panic.rs:140:14
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/rt.rs:148:48
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/rt.rs:148:48
  26:     0x5555b960c63c - std::panicking::try::do_call::h1ce263ca927523fa
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:487:40
  27:     0x5555b960c63c - std::panicking::try::he3d901a7a8ca0bfd
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panicking.rs:451:19
  28:     0x5555b960c63c - std::panic::catch_unwind::hb9e5b8ae73c93b8f
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/panic.rs:140:14
  29:     0x5555b960c63c - std::rt::lang_start_internal::h2947494479068ade
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/rt.rs:148:20
  30:     0x5555b91bbe7a - std::rt::lang_start::he46f5779c6465a34
                               at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/rt.rs:165:17
  31:     0x5555b91d33be - main
  32:     0x7f551131f790 - <unknown>
  33:     0x7f551131f84a - __libc_start_main
  34:     0x5555b917d135 - _start
  35:                0x0 - <unknown>

Interesting ๐Ÿค” I search the good rust regex syntax.

Interesting thinking I search the good rust regex syntax.

I found somewhere that '/' is just a normal character in Rust regex, so it doesn't need to be escaped (but it was 6 years old post). So I guess the question is why it crashes for not escaped '/'

Interesting thinking I search the good rust regex syntax.

I found somewhere that '/' is just a normal character in Rust regex, so it doesn't need to be escaped. So I guess the question is why it crashes for not escaped '/'

Yeah I read the same, in the same time, why are we regexing here. Do you confirm you well want '/' as "instead" of an icon for example here?

What about "(?i)Kitty" = "/" ?

Yeah I read the same, in the same time, why are we regexing here. Do you confirm you well want '/' as "instead" of an icon for example here?

Yes, I want something in style
"[Ff]irefox" = ' <span color="orange">๏‰ฉ</span> '

Is this working for this case ? "[Ff]irefox" = " <span color=\"orange\">๏‰ฉ</span>" ? (I'm not yet toml expert)

What about "(?i)Kitty" = "/" ?

tried that already, the error looks the same for me

thread 'main' panicked at 'App can't rename workspaces on start: NotOkDispatch("unknown request")', src/main.rs:22:10

NotOkDispatch

No this looks like a valid toml syntax now but maybe another bug in the hyrland-rs lib. I will dig more.

Is this working for this case ? "[Ff]irefox" = " <span color=\"orange\">๏‰ฉ</span>" ? (I'm not yet toml expert)

Unfortunately it does not work.
I didn't notice any toml yet before seeing this project :D

Just in case, I have tried to rename hyprctl dispatch renameworkspace 6 '/', the workspace disappears from the waybar, but the hyprctl workspace is correctly renamed.

workspace ID 6 (/) on monitor eDP-1:
	windows: 1
	hasfullscreen: 0
	lastwindow: 0x562825962c70
	lastwindowtitle: psimovec@bramborka:~

just to keep in mind when debugging

So very curious, I understand there is a joke with slash in string in rust, there is some crates to workaround but ... meh ... ๐Ÿค”

@psimovec for now if you like we can do this tricks #42 to prevent the crash and draw a kindof slash. But we can't use <span></span> for the moment so. This is maybe a hyprland-rs issue but I can't put the finger on for the moment.

@yavko do you have an idea an idea about the problem ? We try to be able to use hyprland-rs rename dispatcher to pass some special char like / at least, and maybe <>.

@psimovec for now if you like we can do this tricks #42 to prevent the crash and draw a kindof slash. But we can't use <span></span> for the moment so. This is maybe a hyprland-rs issue but I can't put the finger on for the moment.

@yavko do you have an idea an idea about the problem ? We try to be able to use hyprland-rs rename dispatcher to pass some special char like / at least, and maybe <>.

I just need to clarify that <> characters work as expected.

Super @maximbaz come to the help

image

I do the PR to hyprland-rs, all debugging credit to @maximbaz โค๏ธ

yavko commented

@yavko do you have an idea an idea about the problem ? We try to be able to use hyprland-rs rename dispatcher to pass some special char like / at least, and maybe <>.

No clue, hyprland-rs doesn't do anything with slashes afaik