Skip to content

Instantly share code, notes, and snippets.

@iguanajuice
Last active January 26, 2025 07:11
Show Gist options
  • Select an option

  • Save iguanajuice/4b34ef2d93a53b7e1e91ddeb70768c4e to your computer and use it in GitHub Desktop.

Select an option

Save iguanajuice/4b34ef2d93a53b7e1e91ddeb70768c4e to your computer and use it in GitHub Desktop.

Revisions

  1. iguanajuice revised this gist Jan 26, 2025. No changes.
  2. iguanajuice revised this gist Jan 26, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion swaywait.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    if [ $# -ne 2 ]
    then
    echo "Usage: swaywait [target] [command]"
    echo "Usage: swaywait [app_id/class] [sway_command]"
    exit 1
    fi

  3. iguanajuice created this gist Aug 14, 2024.
    24 changes: 24 additions & 0 deletions swaywait.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    #!/bin/sh

    if [ $# -ne 2 ]
    then
    echo "Usage: swaywait [target] [command]"
    exit 1
    fi

    TARGET=$1
    COMMAND=$2

    swaymsg -t subscribe -m '["window"]' | while read line
    do
    CON=`echo $line | jq -r 'select(.change=="new").container'`
    APPID=`echo $CON | jq -r '.app_id'`
    CLASS=`echo $CON | jq -r '.window_properties.class'`
    CONID=`echo $CON | jq -r '.id'`

    if [ "$APPID" = "$TARGET" ] || [ "$CLASS" = "$TARGET" ]
    then
    swaymsg "[con_id=$CONID] $COMMAND"
    kill -PIPE 0
    fi
    done