タイリング操作してみる。
(録画にリソースをとられているので緩慢な動きですが、
実際は、、、。もう少しだけマシかな?)
※一応スクリプトを載せますが、ググればもっと素晴らしいスクリプトが出てくるので、
興味のある方はそちらを見てくださいね。
→https://bbs.archlinux.org/viewtopic.php?id=119020
尚、スクリプトには別途、wmctrl とxorg-apps のインストールが必要です※
※追記1(2016/06/21 20:25)※
スクリプトの書式を変更。機能的な変化はなし。
※追記2(2016/06/27 21:50)※
余分な処理を削除。機能的な変化なし。
※追記3(2016/06/28 22:30)※
メインウィンドウのローテーションを保持したままサイズ変更出きるようにした。
第一引数に数値(ピクセル単位)だけを指定すると、メインウィンドウのサイズが変更される。
プラスの数値で広く、マイナスの数値で狭くなる。
<使い方>
第一引数には、h、v、r及び数値の指定ができる。
h ウィンドウを横に並べる。第2引数に数値を指定すると、その数値の分だけメインウィンドウが広くなる。
v ウィンドウを縦に並べる。第2引数に数値を指定すると、その数値の分だけメインウィンドウが広くなる。
r メインウィンドウを入れ替える(ローテートする)。
数値 メインウィンドウのサイズ変更。
(ウィンドウが4つ以上だと、メインの意味はなくなるので注意)
#!/bin/bash
PRE_IFS=$IFS
IFS=$'\n'
panel_h=28
title_h=28
disp_width=$(xwininfo -root | grep 'Width' | cut -f2 -d ':' | sed 's/^[ \t]*//')
disp_height=$(xwininfo -root | grep 'Height' | cut -f2 -d ':' | sed 's/^[ \t]*//')
rotate_flag=0
if [ $# -eq 1 ]; then
if [ $1 = 'h' -o $1 = 'v' ]; then
hv_flag=$1
main_add=0
elif [ $1 = 'r' ]; then
rotate_flag=1
elif [ $1 -gt 0 -o $1 -lt 0 ]; then
rotate_flag=2
else
hv_flag='h'
#main_add=$1
fi
elif [ $# -eq 2 ]; then
hv_flag=$1
main_add=$2
else
hv_flag='h'
main_add=0
fi
temp_file='./wm-ctrl.txt'
if [ $rotate_flag -gt 0 ]; then
hv_flag=$(sed -n 1p ./wm-ctrl.his | cut -f1 -d',')
main_add=$(sed -n 1p ./wm-ctrl.his | cut -f2 -d',' | sed 's/^[ \t]*//')
if [ $rotate_flag -eq 1 ]; then
temp_1=$(sed -n 2p ./wm-ctrl.his)
sed -i '$a '$temp_1'' ./wm-ctrl.his
sed -i 1,2d ./wm-ctrl.his
else
sed -i 1d ./wm-ctrl.his
main_add=$((main_add + $1))
fi
sed -i 's/_/ /g' ./wm-ctrl.his
temp_file='./wm-ctrl.his'
fi
wmctrl -l > wm-ctrl.txt
txt_lines=$(wc $temp_file | sed 's/^[ \t]*//' | cut -f1 -d " ")
if [ $txt_lines -gt 0 ]; then
current_ws=$(xprop -root -notype _NET_CURRENT_DESKTOP | cut -b 24)
#active_win=$(xprop -root -notype _NET_ACTIVE_WINDOW | cut -b 33-43)
ws_windows=0
for((i = 1; i <= $txt_lines; i++)); do
ws_flag=$(sed -n $i'p' $temp_file | cut -b 12-13)
if [ $ws_flag -eq $current_ws ]; then
let ws_windows++
fi
done
disp_width2=$((disp_width / 2))
disp_height2=$(($(((disp_height - panel_h) / 2)) - title_h))
disp_width_main=$((disp_width2 + main_add))
disp_height_main=$((disp_height2 + main_add))
disp_width_sub=$((disp_width2 - main_add))
disp_height_sub=$((disp_height2 - main_add))
pos_width=$((disp_width / 2))
pos_height=$(((disp_height - panel_h) / 2))
if [ $hv_flag = 'v' ]; then
x_pos=(0 0 $pos_width $pos_width)
y_pos=(0 $((pos_height + main_add)) $((pos_height + main_add)) 0)
else
x_pos=(0 $((pos_width + main_add)) $((pos_width + main_add)) 0)
y_pos=(0 0 $pos_height $pos_height)
fi
case $ws_windows in
1)
temp_width=$disp_width
temp_height=$((disp_height - panel_h - title_h));;
[2-3])
temp_width=$disp_width2
temp_height=$((disp_height - panel_h - title_h));;
*)
temp_width=$disp_width2
temp_height=$disp_height2;;
esac
window_array=()
n=0
for((i = 1; i <= $txt_lines; i++)); do
if [ $n -gt 3 ]; then
n=0
fi
ws_flag=$(sed -n $i'p' $temp_file | cut -b 11-13 | sed 's/^[ \t]*//')
if [ $ws_flag -eq $current_ws ]; then
win_id=$(sed -n $i'p' $temp_file | cut -b 1-10)
if [ $rotate_flag -eq 0 ]; then
if [ $n -eq 0 ]; then
echo $hv_flag','$main_add',' > wm-ctrl.his
echo $win_id'__'$current_ws'_' >> wm-ctrl.his
else
echo $win_id'__'$current_ws'_' >> wm-ctrl.his
fi
fi
if [ $ws_windows -eq 2 ]; then
if [ $n -eq 0 ]; then
if [ $hv_flag = 'v' ]; then
temp_width=$disp_width
temp_height=$disp_height_main
else
temp_width=$disp_width_main
fi
else
if [ $hv_flag = 'v' ]; then
temp_width=$disp_width
temp_height=$disp_height_sub
else
temp_width=$disp_width_sub
temp_height=$((disp_height - panel_h - title_h))
fi
fi
fi
if [ $ws_windows -eq 3 ]; then
if [ $n -eq 0 ]; then
if [ $hv_flag = 'v' ]; then
temp_width=$disp_width
temp_height=$disp_height_main
else
temp_width=$disp_width_main
fi
fi
fi
if [ $ws_windows -gt 2 -a $n -gt 0 ]; then
if [ $hv_flag = 'v' ]; then
temp_width=$disp_width2
temp_height=$disp_height_sub
else
temp_width=$disp_width_sub
temp_height=$disp_height2
fi
fi
if [ $ws_windows -gt 3 -a $n -gt 0 ]; then
x_pos=(0 $pos_width $pos_width 0)
y_pos=(0 0 $pos_height $pos_height)
temp_width=$disp_width2
temp_height=$disp_height2
fi
window_array+=( $win_id','${x_pos[$n]}','${y_pos[$n]}','$temp_width','$temp_height )
let n++
fi
done
for par in ${window_array[@]}; do
for((i = 1; i <= 5; i++)); do
declare par$i=$(echo ${par} | cut -f$i -d ',')
done
wmctrl -i -r $par1 -e 0,$par2,$par3,$par4,$par5
done
fi
if [ $rotate_flag -gt 0 ]; then
sed -i 's/ /_/g' ./wm-ctrl.his
temp=$hv_flag','$main_add','
sed -i '1i '$temp'' ./wm-ctrl.his
fi


