Skip to content

Commit

Permalink
Raw: Tiling script to stand in (replace?) broken (in 18.04) quicktile.
Browse files Browse the repository at this point in the history
- "Crude quarter tiling tool for elementary OS":

    https://gist.github.com/peteruithoven/db0cba0b0849c8cb5e267f6e75126304

  Thank you:

    github.com/peteruithoven

- See also known issue:

    ssokolow/quicktile#95
  • Loading branch information
landonb committed Jan 4, 2019
1 parent d003546 commit b40e0b1
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions bin/quarter-tiler
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

# Crude quarter tiling tool
# Installation:
# Move file to: /usr/local/bin/quarter-tiler
# Make executable: sudo chmod +x /usr/local/bin/quarter-tiler
# Assign keyboard shortcuts to commands like "quarter-tiler topleft"

# Margins around windows (elementary OS native apps) (HiDPI)
MARGIN_TOP=130
MARGIN_RIGHT=158
MARGIN_BOTTOM=185
MARGIN_LEFT=158
# Desktops info
INFO=$(wmctrl -d | head -1)
# Desktop size
[[ $INFO =~ 'DG: '([0-9]+)'x'([0-9]+) ]]
WIDTH=${BASH_REMATCH[1]}
HEIGHT=${BASH_REMATCH[2]}
# Available width height, and offsets see: $ wmctrl -d
[[ $INFO =~ 'WA: '([0-9]+)','([0-9]+)' '([0-9]+)'x'([0-9]+) ]]
OFFSET_X=${BASH_REMATCH[1]}
OFFSET_Y=${BASH_REMATCH[2]}
AV_WIDTH=${BASH_REMATCH[3]}
AV_HEIGHT=${BASH_REMATCH[4]}

X_LEFT=$((0-($MARGIN_RIGHT+$OFFSET_X)))
X_CENTER=$(($AV_WIDTH/2+$MARGIN_RIGHT+$MARGIN_LEFT))
HALF_WIDTH=$X_CENTER
Y_TOP=$((0-($MARGIN_TOP-$OFFSET_Y)))
Y_CENTER=$(($Y_TOP+$HEIGHT/2))
HALF_HEIGHT=$(($AV_HEIGHT/2+$MARGIN_TOP+$MARGIN_BOTTOM))
SIZE=$HALF_WIDTH,$HALF_HEIGHT

case "$1" in
topleft)
CMD="wmctrl -r :ACTIVE: -e 0,$X_LEFT,$Y_TOP,$SIZE"
;;
topright)
CMD="wmctrl -r :ACTIVE: -e 0,$X_CENTER,$Y_TOP,$SIZE"
;;
bottomleft)
CMD="wmctrl -r :ACTIVE: -e 0,$X_LEFT,$Y_CENTER,$SIZE"
;;
bottomright)
CMD="wmctrl -r :ACTIVE: -e 0,$X_CENTER,$Y_CENTER,$SIZE"
;;
esac

# In case window is tiled, disable tile
wmctrl -r :ACTIVE: -b remove,maximized_vert
# Wait for transition
sleep 0.1s

eval $($CMD)

0 comments on commit b40e0b1

Please sign in to comment.