LoginSignup
6
6

More than 5 years have passed since last update.

xdotoolでシェルからブラウザをリロードするワンライナー

Last updated at Posted at 2012-11-22

sudo aptitude install xdotool でインストールする

xdotool windowfocus `xdotool search --onlyvisible --name opera`; xdotool key ctrl+r; xdotool windowfocus `xdotool search --onlyvisible --class gnome-terminal`;

などとするとOperaにctrl+rが送信されてリロードされる。

  • windowactivateは指定したウィンドウを最前面にする
  • windowfocusは指定したウィンドウにフォーカスだけされるので、背面でリロードしたいときはこちらを使う
    • フォーカスされたままだとキー入力がOperaに行ってしまうので端末に戻す必要がある

vimでシェルコマンド送信する機能使ってこのワンライナーを送るようにするとかどうだろうか

:autocmd! BufWriteCmd * r!xdotool windowfocus `xdotool search --onlyvisible --maxdepth 3 --name opera`; xdotool key ctrl+r; xdotool windowfocus `xdotool search --onlyvisibl
e --maxdepth 3 --class gnome-terminal|tail -1`

できたけどなんか動きが遅い。。
どうやらxdotool searchが --maxdepth を指定しないとすごく重くなる模様。 --maxdepth 3でも妙に重い。
なるべくsearchしたくない

最初に現在のwindowをgetactivewindowで保存しておいて一度だけブラウザをsearchするようなシェルスクリプトにしたほうがよさそうだ。

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6