You are not logged in.
you want to start something in a new urxvt tab, don't you?
Not really, just the usual toggle behavior, actually no idea what I was doing there (probably typos) as it seems to work now.
p.s. I should probably change all this wbar statements to something like
(launchee iceweasel || iceweasel)
so wbar it will fall to its standard behavior if launchee script is not found.
Last edited by brontosaurusrex (2015-12-09 11:37:54)
Offline
Here is a new version of the launcher script.
Now using window id's exclusively in stead of pids.
#!/bin/bash
#.....
# there has to be at least one parameter, the name of the file to execute
if (( $# == 0 ));then
echo "Usage: $(basename $0) executable_name [parameters]"
exit 1
fi
has_element () {
local e
for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
return 1
}
launchee=$(basename "$1")
# test to see if program is already running
declare -a launchee_win_ids
launchee_win_ids=( $(wmctrl -lx | awk -v pattern="$launchee" 'BEGIN {IGNORECASE = 1} $3 ~ pattern {print $1}' ) )
if (( ${#launchee_win_ids[@]} ));
then
# means at least one launchee process must already be running
active_window_id=$(printf '0x%8x' $(xdotool getwindowfocus))
active_window_id=${active_window_id// /0}
# is acitve_window_pid one of the already running launchee?
if has_element "$active_window_id" "${launchee_win_ids[@]}"; then
# launched app is currently in focus, so do nothing
# xdotool getactivewindow windowminimize
:
else
# launchee instance is not in focus, so raise and bring to focus
# which one do you bring into focus if there are many?
# First one is easiest
wmctrl -i -a "${launchee_win_ids[0]}"
fi
else
# start it up
"$@"&
fi
exit 0
I have changed the behaviour slightly:
If you now launch an application from an already running instance of that application, it now does nothing.
The old version then minimised the current instance.
Try it out and let me know for which application if it does not work for you
BTW:
The script contains bash code to transform a decimal window_id to a hexadecimal one.
Last edited by xaos52 (2015-12-10 12:37:32)
Offline
@xaos52, nice, slightly moded to enable minimize/maximize behavior and to shut-up the shellcheck.net
https://raw.githubusercontent.com/bront … n/launchee
Any purpose of the ":" line?
Last edited by brontosaurusrex (2015-12-10 13:22:42)
Offline
@xaos52, nice, slightly moded to enable minimize/maximize behavior and to shut-up the shellcheck.net
https://raw.githubusercontent.com/bront … n/launcheeAny purpose of the ":" line?
A quick web search with "bash colon" came up with:
: (a colon)
: [arguments]
Do nothing beyond expanding arguments and performing redirections. The return status is zero.
and
you can usually use either : or true. Both are specified by POSIX, and some find true easier to read. However there is one interesting difference: : is a so-called POSIX special built-in, whereas true is a regular built-in.
Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt «» BunsenLabs on DeviantArt
Offline
Right, sort of an empty event? So if
# xdotool getactivewindow windowminimize
is enabled it serves no purpose?
Offline