web-dev-qa-db-ja.com

openboxを使用してすべてのデスクトップにアプリケーションを自動的に表示するにはどうすればよいですか?

wmctrlなどを使用して、特定のウィンドウをすべてのデスクトップに自動的に表示することはできますか?

Prime Player Google Play Music miniplayer Chrome extension を使用して、音楽の再生を制御します。既にミニプレーヤーを他のウィンドウの一番上に表示するために呼び出すことができるbashエイリアスがありますが、ミニプレーヤーウィンドウをすべてのデスクトップに送信して、右クリックしてデスクトップに送信すべてのデスクトップ(openbox経由)。

理想的には、スクリプトでバックグラウンドで何かを実行し、ミニプレーヤーウィンドウを検出するとすぐにそれを一番上に置き、すべてのデスクトップに送信します。これは可能ですか?

3
Andy Forceno

実際には、サードパーティのスクリプトなしでこれを行うことができます。 Openboxは、広範な アプリケーションごとの設定 をサポートしています。

アプリ固有のルールの作成

アプリケーションルールは、ウィンドウ名、クラス、ロール、タイトルなどのさまざまなプロパティと照合されます。これらのプロパティのほとんどは、特定のウィンドウに対して次を実行することで取得できます。

obxprop | grep "^_OB_APP"

問題のウィンドウをクリックします。

Chrome拡張ウィンドウのルールをどのように指定するかを見て、可能な限り多くの一致するプロパティを指定して、ルールをできるだけ具体的にすることができます。すべてのChromeウィンドウに適用する必要はありません。さまざまなマッチングプロパティを試して、最適なものを確認してください。

一致するウィンドウを定義したら、問題のウィンドウ/アプリケーションにのみ適用されるさまざまなプロパティを設定できます。以下は、使用可能なすべてのプロパティを説明するデフォルトのrc.xmlの抜粋です。

# each rule element can be left out or set to 'default' to specify to not 
# change that attribute of the window

<decor>yes</decor>
# enable or disable window decorations

<shade>no</shade>
# make the window shaded when it appears, or not

<position force="no">
  # the position is only used if both an x and y coordinate are provided
  # (and not set to 'default')
  # when force is "yes", then the window will be placed here even if it
  # says you want it placed elsewhere.  this is to override buggy
  # applications who refuse to behave
  <x>center</x>
  # a number like 50, or 'center' to center on screen. use a negative number
  # to start from the right (or bottom for <y>), ie -50 is 50 pixels from
  # the right Edge (or bottom). use 'default' to specify using value
  # provided by the application, or chosen by openbox, instead.
  <y>200</y>
  <monitor>1</monitor>
  # specifies the monitor in a xinerama setup.
  # 1 is the first head, or 'mouse' for wherever the mouse is
</position>

<size>
  # the size to make the window.
  <width>20</width>
  # a number like 20, or 'default' to use the size given by the application.
  # you can use fractions such as 1/2 or percentages such as 75% in which
  # case the value is relative to the size of the monitor that the window
  # appears on.
  <height>30%</height>
</size>

<focus>yes</focus>
# if the window should try be given focus when it appears. if this is set
# to yes it doesn't guarantee the window will be given focus. some
# restrictions may apply, but Openbox will try to

<desktop>1</desktop>
# 1 is the first desktop, 'all' for all desktops

<layer>normal</layer>
# 'above', 'normal', or 'below'

<iconic>no</iconic>
# make the window iconified when it appears, or not

<skip_pager>no</skip_pager>
# asks to not be shown in pagers

<skip_taskbar>no</skip_taskbar>
# asks to not be shown in taskbars. window cycling actions will also
# skip past such windows

<fullscreen>yes</fullscreen>
# make the window in fullscreen mode when it appears

<maximized>true</maximized>
# 'Horizontal', 'Vertical' or boolean (yes/no)

特定のケースでは、アプリケーションのlayerdesktopを指定することに興味があります。特定のアプリケーションのすべてのウィンドウを常に最前面に配置し、使用可能なすべてのデスクトップに遍在するように指定するルールの例を次に示します。

<application name="miniplayer" class="miniplayer" type="normal">
  <layer>above</layer>
  <desktop>all</desktop>
</application>

この例では、任意のアプリケーション名とクラスを選択しました。前に述べたように、特定のアプリケーションの正しい値を見つける必要があります。


Edit:私はあなたの特定のアプリケーションを調べ、私のシステムで動作するルールを思い付きました:

<application name="crx_npngaakpdgeaajbnidkkginekmnaejbi" class="Google-chrome" type="normal" role="pop-up">
  <layer>above</layer>
  <desktop>all</desktop>
</application>

これがあなたにも役立つことを願っています。


アプリ固有のルールを追加するためのopenbox設定の修正

アプリケーションルールを追加するには、openbox rc.xml(ストックOpenboxの場合は~/.config/openbox/rc.xmlまたはLXDEの場合は~/.config/openbox/lxde-rc.xmlの下にあります)を開き、ファイルの最後の<applications>セクションに移動します。

<applications>..</applications>タグの間にアプリケーション固有のルールを挿入します。次に、ファイルを保存し、次を実行して構成の再読み込みに進みます。

openbox --reconfigure

この後、アプリケーション固有のルールが有効になり、新しく生成されたウィンドウに自動的に適用されます。

3
Glutanimate

Python 2.7およびライブラリpython-wnckを使用したより一般的なソリューションが見つかりました。

詳細に興味がある場合は、 this および this を確認してください

そうでない場合は、この手順を実行してください。 Ubuntuで手順1〜2は既に実行されている必要があります。

  1. python2.7をインストールします。 Sudo apt-get install python2.7

  2. python-wnckをインストールします。 Sudo apt-get install python-wnck

  3. stick_player.pyファイルを作成します。 touch stick_player.py

  4. python Shebangを追加します。

echo '#!' which python> stick_player.py

  1. 実行可能にします。 chmod +x stick_player.py

  2. このスクリプトをstick_player.pyに貼り付けます。次のようになります

#!/usr/bin/python

import wnck

screen = wnck.screen_get_default()
screen.force_update()

for win in screen.get_windows():
    if win.get_name() == 'Prime Player':
        win.stick()
  1. 新しいウィンドウでプレーヤーを実行します。私の場合、ウィンドウ名は「Prime Player」でした。それが私に知らせない場合。

  2. スクリプトを実行します。 ./stick_player.py


「すべてのワークスペースで表示」も元に戻す場合は、これを実行します。もう一度手順3〜7を行いますが、.

  1. ファイルunstick_player.pyを作成します。 touch unstick_player.py

  2. python Shebangを追加します。

echo '#!' which python> unstick_player.py

  1. 実行可能にします。 chmod +x unstick_player.py

  2. 最後の行をwin.stick()からwin.unstick()に変更します

  3. スクリプトを実行します。 ./unstick_player.py


また

次のスクリプトを使用して、すべてのウィンドウ名を見つけることができます。

#!/usr/bin/python

import wnck

screen = wnck.screen_get_default()
screen.force_update()

for win in screen.get_windows():
    print win.get_name()
3
c0rp