项目作者: nwg-piotr

项目描述 :
Launcher script to avoid running multiple instance of the same window
高级语言: Shell
项目地址: git://github.com/nwg-piotr/rof.git
创建时间: 2018-11-01T01:36:37Z
项目社区:https://github.com/nwg-piotr/rof

开源协议:GNU General Public License v3.0

下载


rof

rof is a launcher script to avoid launching multiple instances of the same window. The name stands for [r]un [o]r set [f]ocus).

While playing with my collection of Tint2 executors one of things I hated most
was that commands assigned to mouse events would execute again and again after each click, even if previous instances were
already running. The behavior I expected was: launch the command if not yet running, else just bring focus to the command
window. Having no better idea on how to achieve this, I wrote this short script. It searches the process ID of the name given, then tries to find a window by the process ID. If found, it’ll be given focus, instead of running the command again.

Dependencies:

xorg-xprop, wmctrl (valid for Arch Linux; package names may vary in other distributions)

Usage:

  1. rof [-P process_name] command

Use rof command to simply run if the command and the process name are the same.

Provide the optional process name, for instance if the command is a script which runs another command:

  1. rof -P zenity zenity-set-volume.sh

launches the script which opens a zenity box, with arguments: zenity --scale --value ${lvl} --title "Volume" --text "Set master volume level"

Sample:

The script may be useful in a Tint2 executor left/right click commands:

  1. #-------------------------------------
  2. # Executor 4
  3. execp = new
  4. execp_command = ~/tint2-executors/volume-icon.sh
  5. execp_interval = 3
  6. execp_has_icon = 1
  7. execp_cache_icon = 1
  8. execp_continuous = 0
  9. execp_markup = 1
  10. execp_tooltip = Scroll ↓↑, middle click to mute
  11. execp_lclick_command = rof -P zenity ~/tint2-executors/zenity-set-volume.sh
  12. execp_rclick_command = rof pavucontrol
  13. execp_mclick_command = amixer set Master toggle -q
  14. execp_uwheel_command = amixer set Master 5%+ unmute -q && ~/tint2-executors/notify-vol.sh
  15. execp_dwheel_command = amixer set Master 5%- -q && ~/tint2-executors/notify-vol.sh
  16. execp_font_color = #000000 100
  17. execp_padding = 0 0
  18. execp_background_id = 0
  19. execp_centered = 0
  20. execp_icon_w = 26
  21. execp_icon_h = 26