Skip to content

Instantly share code, notes, and snippets.

@debuti
Last active May 5, 2020 15:54
Show Gist options
  • Select an option

  • Save debuti/a6f851142c467a976574e6a08ae26b20 to your computer and use it in GitHub Desktop.

Select an option

Save debuti/a6f851142c467a976574e6a08ae26b20 to your computer and use it in GitHub Desktop.

Revisions

  1. debuti revised this gist May 5, 2020. 1 changed file with 11 additions and 1 deletion.
    12 changes: 11 additions & 1 deletion windows.md
    Original file line number Diff line number Diff line change
    @@ -5,22 +5,32 @@ SHEIGHT=$((cd /tmp/.X11-unix && for x in X*; do DISPLAY=":${x#X}" xdpyinfo | gre
    ```

    # Current desktop
    ```
    wmctrl -d | egrep '^[0-9]+\s+\*' | cut -f1 -d" "
    ```

    # Current desktop windows
    ```
    wmctrl -pl | egrep "^0x[0-9a-f]+\s+$(wmctrl -d | egrep '^[0-9]+\s+\*' | cut -f1 -d" ")"
    ```

    # All t32 instances of the current desktop
    ```
    wmctrl -pl | egrep "^0x[0-9a-f]+\s+$(wmctrl -d | egrep '^[0-9]+\s+\*' | cut -f1 -d" ")" | grep t32marm
    ```

    # Move and resize window
    ```
    wmctrl -ir $WID -e 0,X,Y,W,H
    ```

    # Move all windows in a horizontal tile
    ```
    TITLE=Pluma;
    WIDS=( $(wmctrl -pl | egrep "^0x[0-9a-f]+\s+$(wmctrl -d | egrep '^[0-9]+\s+\*' | cut -f1 -d" ")" | grep $TITLE | cut -f1 -d" ") )
    COUNT=$(echo "${#WIDS[@]}")
    WW=$(( $SWIDTH / $COUNT ))
    for i in "${!WIDS[@]}"; do
    wmctrl -ir ${WIDS[$i]} -e 0,$(( $WW * $i )),0,$WW,$SHEIGHT
    done
    done
    ```
  2. debuti revised this gist May 5, 2020. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions windows.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,8 @@
    # Get screen dimensions
    ```
    SWIDTH=$((cd /tmp/.X11-unix && for x in X*; do DISPLAY=":${x#X}" xdpyinfo | grep dimensions; exit 0; done) | grep -oP '[0-9]+x[0-9]+(?= pixels)' | cut -f1 -dx)
    SHEIGHT=$((cd /tmp/.X11-unix && for x in X*; do DISPLAY=":${x#X}" xdpyinfo | grep dimensions; exit 0; done) | grep -oP '[0-9]+x[0-9]+(?= pixels)' | cut -f2 -dx)
    ```

    # Current desktop
    wmctrl -d | egrep '^[0-9]+\s+\*' | cut -f1 -d" "
  3. debuti created this gist May 5, 2020.
    24 changes: 24 additions & 0 deletions windows.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    # Get screen dimensions
    SWIDTH=$((cd /tmp/.X11-unix && for x in X*; do DISPLAY=":${x#X}" xdpyinfo | grep dimensions; exit 0; done) | grep -oP '[0-9]+x[0-9]+(?= pixels)' | cut -f1 -dx)
    SHEIGHT=$((cd /tmp/.X11-unix && for x in X*; do DISPLAY=":${x#X}" xdpyinfo | grep dimensions; exit 0; done) | grep -oP '[0-9]+x[0-9]+(?= pixels)' | cut -f2 -dx)

    # Current desktop
    wmctrl -d | egrep '^[0-9]+\s+\*' | cut -f1 -d" "

    # Current desktop windows
    wmctrl -pl | egrep "^0x[0-9a-f]+\s+$(wmctrl -d | egrep '^[0-9]+\s+\*' | cut -f1 -d" ")"

    # All t32 instances of the current desktop
    wmctrl -pl | egrep "^0x[0-9a-f]+\s+$(wmctrl -d | egrep '^[0-9]+\s+\*' | cut -f1 -d" ")" | grep t32marm

    # Move and resize window
    wmctrl -ir $WID -e 0,X,Y,W,H

    # Move all windows in a horizontal tile
    TITLE=Pluma;
    WIDS=( $(wmctrl -pl | egrep "^0x[0-9a-f]+\s+$(wmctrl -d | egrep '^[0-9]+\s+\*' | cut -f1 -d" ")" | grep $TITLE | cut -f1 -d" ") )
    COUNT=$(echo "${#WIDS[@]}")
    WW=$(( $SWIDTH / $COUNT ))
    for i in "${!WIDS[@]}"; do
    wmctrl -ir ${WIDS[$i]} -e 0,$(( $WW * $i )),0,$WW,$SHEIGHT
    done