LoginSignup
9

More than 5 years have passed since last update.

アプリケーションを起動するかアクティブにする

Last updated at Posted at 2016-02-22

Mac

open -a "Google Chrome"

Linux

xmonadを使っている場合

runOrRaiseを使えばよい。

import XMonad.Actions.WindowGo

  -- ...
  , ((controlMask, xK_u), runOrRaise "google-chrome-stable" (className =? "google-chrome"))
  -- ...

のような設定を足すとC-uでChromeが立ち上がる。

wmctrl(1)を使う方法

activate-window
#!/bin/sh
keyword=$1
shift

match=$(wmctrl -l | grep "${keyword}$")
case $? in
  1)
    $@
    ;;
  0)
    window_id=$(echo $match | tail -n1 | cut -d' ' -f1)
    wmctrl -i -R $window_id
    ;;
esac

上記のようなコマンドactivate-windowを作っておき、

activate-window "Google Chrome" google-chrome-stable

とする。

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
9