Gnomeのスナップウィンドウ間の左/右分割のデフォルト位置の変更

Gnomeのスナップウィンドウ間の左/右分割のデフォルト位置の変更

Ubuntu 18.04のGNOME 3.28で

SUPER+← snaps a window to the left
SUPER+→ snaps a window to the right

これらの操作は、設定のGnomeキーボードショートカットリストの「左ビューの分割」または「右のビューの分割」と呼ばれます。ウィンドウが揃ったら、分割位置(デフォルトでは中央)を左右にドラッグして、1つのウィンドウでより多くのスペースを提供し、別のウィンドウにはより少ないスペースを提供できます。その後に配置されたウィンドウは、この新しい分割位置に従います。私の考えでは、これは美しくスタイリッシュな実装です。

私の質問は、デフォルトの分割位置を中央から遠ざける方法です。私は右側に80文字幅の端末ウィンドウを置き(16:9画面幅の半分未満のサイズ)、左側のブラウザウィンドウのためのより広い残りのスペースを残すのが好きです。デフォルトでは、再起動後に左/右のスナップ境界を手動でドラッグすることを避けたいと思います。以下は、私が好むボーダー位置を含む分割ウィンドウのスクリーンショットです。

スクリーンショット

キャプチャされたウィンドウには丸みを帯びたエッジはありませんが、代わりに分割の両側の全長方形の領域を占めます。

マウスドラッグで分割位置を変更できるので、起動時にこの変数をプログラムで設定できますか?ただし、初期ウィンドウスナップで変数がリセットされ、強制的に適用する方法がない可能性があります。 dwm xDのようなタイリングwmに切り替える必要があるかもしれませんが、gnomeは問題ありません。

ベストアンサー1

または、目的のタスクを実行するスクリプトを作成し、ここにショートカットをマップすることもできます。次のbashスクリプトは画面の1/3または2/3に設定します。

screenWidth=$(xrandr --current | grep '*' | uniq | awk '{print $1}' | cut -d 'x' -f1)
windowWidth=$(xwininfo -id $(xprop -root _NET_ACTIVE_WINDOW | cut -d ' ' -f 5) | grep Width | cut -d ' ' -f 4)

numberRegex='^[0-9]+$'

if  ! [[ $windowWidth =~ $numberRegex ]] ; then
   echo "error: windowWith not a number: '$windowWidth'" >> tile-plus.log; exit 1
fi


if  ! [[ $screenWidth =~ $numberRegex ]] ; then
   echo "error: screenWidth not a number: '$screenWidth'" >> tile-plus.log; exit 1
fi

doubleWidth=$((2*windowWidth))

parameter=$1

echo "Comparing screenWidth $screenWidth and double of width $doubleWidth" >> tile-plus.log
if [[ doubleWidth -gt screenWidth ]] ; then
   echo "Detected big size" >> tile-plus.log
   nextWidth=$((screenWidth / 3))
else
   echo "Detected small size" >> tile-plus.log
   nextWidth=$((screenWidth * 2 / 3))
fi

case $parameter in
right)
   echo "Received right parameter" >> tile-plus.log
   nextOffset=$((screenWidth - nextWidth))
   ;;
*)
  echo "Received $parameter defaulting to left" >> tile-plus.log
  parameter="left"
  nextOffset=0
esac


echo Width will be set to $nextWidth and offset to $nextOffset >> tile-plus.log

wmctrl -r :ACTIVE: -b add,maximized_vert
wmctrl -r :ACTIVE: -e 1,$nextOffset,0,$nextWidth,600

「~/.keyboard-shortcuts/tile-plus.h」に保存すると、その<Super><Alt>Right実行のバインディングbash .keyboard-shortcuts/tile-plus.h right<Super><Alt>Leftその実行のショートカットを作成できますbash .keyboard-shortcuts/tile-plus.h left

おすすめ記事