~tsdh/swayr#35: 
`switch-to-matching-or-urgent-or-lru-window` fails

The switch-to-matching-or-urgent-or-lru-window doesn't seem to work well.

I ran the following shell script:

swayr-test.sh

#!/bin/bash
set -x

pacman -Q swayr-git
foot --app-id=APP_ID --title=TITLE > /dev/null 2>&1 &
sleep 1
swayr switch-to-urgent-or-lru-window

swayr switch-to-matching-or-urgent-or-lru-window [title="TITLE"]
swayr switch-to-matching-or-urgent-or-lru-window [app_id="APP_ID"]
swayr switch-to-matching-or-urgent-or-lru-window [app_name="APP_ID"]

result:

$ ./swayr-test.sh
+ pacman -Q swayr-git
swayr-git r456.0718a04-1
+ sleep 1
+ foot --app-id=APP_ID --title=TITLE
+ swayr switch-to-urgent-or-lru-window
Executed sway command '[con_id=167] focus' (It's the LRU window.)
+ swayr switch-to-matching-or-urgent-or-lru-window '[title=TITLE]'
Error: "error at 1:8: expected one of \"\\\"\", \"__focused__\", [' ' | '\\t']"
+ swayr switch-to-matching-or-urgent-or-lru-window '[app_id=APP_ID]'
Error: "error at 1:9: expected one of \"\\\"\", \"__focused__\", [' ' | '\\t']"
+ swayr switch-to-matching-or-urgent-or-lru-window '[app_name=APP_ID]'
Error: "error at 1:11: expected one of \"\\\"\", \"__focused__\", [' ' | '\\t']"
$
Status
RESOLVED BY_DESIGN
Submitter
~tkna
Assigned to
No-one
Submitted
2 years ago
Updated
2 years ago
Labels
swayr

~tsdh REPORTED BY_DESIGN 2 years ago

The syntax is wrong: the values of title, app_id, and app_name must either be a string enclosed with double-quotes or the special keyword __focused­­__ without double-quotes. So basically your script looks ok but probably [ needs to be quoted itself. However, the syntax is wrong in the trace output. It seems like bash tries to be smart here and put the complete criteria query in single quotes but also remove the double-quotes from "TITLE" and friends.

FWIW, I think using something like '[app_name="foot"]' should work fine for most shells, i.e., put the complete criteria query in single-quotes and values of type string/regex in double-quotes.

~tkna 2 years ago

All right. I'm sorry I misunderstood.

Register here or Log in to comment, or comment via email.