#!/bin/sh ## some layouts to order the windows ## . $HOME/.config/wms/wms_var FLAG=$1 # input RID=$(lsw -r) # root window id FW=$(pfw) # focused window CMW=$(lsw | wc -l) # count maped windows RW=$(wattr w $RID) # root width RH=$(wattr h $RID) # root height SW=$((RW - 2 * BW)) # usable screen width SH=$((RH - 2 * BW)) # usable screen height usage() { echo "usage: wms_usher.sh [ -m, -t, -w ] -m) monucule -t) tiled -w) widespread" } # all windows at full screen monocule() { for wid in $(lsw); do wtp 0 0 $SW $SH $wid done } # tiling. Master and stack tiling() { gap=$(atomx WM_GAP $RID) # gaps sw=$((RW - 2 * gap - 2 * BW)) # screen widht width gaps added sh=$((RH - 2 * gap - 2 * BW)) # screen height width gaps added u_wind=$((CMW - 1)) # calculate unfocused windows m_perc=$(atomx WM_MP $RID) # master area percent m_width=$((sw * m_perc / 100 - 2 * BW)) # master area width m_height=$sh # master area height mx=$gap # master x coordinate my=$gap # master y coordinate s_width=$((sw - m_width - gap - 2 * BW)) # stack width s_height=$((sh / u_wind)) # stack height sx=$((m_width + 2 * gap + 2 * BW)) # stack X coordinate sy=$gap # stack Y coordinate wtp $mx $my $m_width $m_height $FW # put focused window as master for wid in $(lsw | grep -v $FW); do # unfocused windows in stack wtp $sx $sy $s_width $s_height $wid sy=$((sy + s_height + gap + 2 * BW)) # incremental Y coordinate s_height=$((sh / u_wind - gap - 2 * BW)) # new stack height calculation done } # widespread widespread() { wp=$(atomx WM_WP $RID) # window percentage from atom ww=$((SW * wp / 100)) # windows width wh=$((SH * wp / 100)) # windows height x=$(((RW - ww) / (CMW * 2))) # initial X coordinate y=$(((RH - wh) / (CMW * 2))) # initial Y coordinate x_max=$(((RW - ww) / CMW)) # function X value y_max=$(((RH - wh) / CMW)) # function Y value for wid in $(lsw); do # windows in cascade wtp $x $y $ww $wh $wid x=$((x + x_max)) # incremental X value y=$((y + y_max)) # incremental Y value done } if [ -n "$FW" ]; then # if there is a focused window case $FLAG in -m) monocule ;; -t) tiling ;; -w) widespread ;; *) usage ;; esac fi