Re: [dev] Focusing on windows by name
I think [ "$foo" ] will work too. No need for -n. But yeah. Bashisms did lot of brain damage On 26/10/2011, at 20:09, Rob wrote: > On 26 October 2011 14:51, Peter John Hartman > wrote: >> I do something similar: >> >> if [[ $foo != "" ]]; then > > [ -n "$foo" ] > > if you're going for POSIX. >
Re: [dev] Focusing on windows by name
On 26 October 2011 14:51, Peter John Hartman wrote: > I do something similar: > > if [[ $foo != "" ]]; then [ -n "$foo" ] if you're going for POSIX.
Re: [dev] Focusing on windows by name
I do something similar: TMPFILE=/tmp/dwm-lastwindow xdotool getwindowfocus > $TMPFILE foo=$(xdotool search --class st) if [[ $foo != "" ]]; then xdotool windowactivate $foo else st -e tmux-start & fi -- sic dicit magister P University of Toronto / Fordham University Collins Hall B06; Office Hours TF10-12 http://individual.utoronto.ca/peterjh gpg --keyserver pgp.mit.edu --recv-keys E0DBD3D6
Re: [dev] Focusing on windows by name
Manolo Martínez a écrit : > Is using xdotool's search option slower or otherwise > worse than this? I can't tell. > (btw, i'm not sure I know what lsw is) http://tools.suckless.org/lsw Greetings, -- Bastien
Re: [dev] Focusing on windows by name
On 10/26/11 at 12:32pm, Bastien Dejean wrote: > No, this is not equivalent because the following command: > > wmctrl -xa mutt > > activates the first client matching the given 'title'. > > You could rather do: > > #! /bin/sh > > wid=$(lsw -l | grep -m 1 "$@" | cut -d ' ' -f 1) > > if [ -n "$wid" ]; then > xdotool windowactivate "$wid" > else > case "$@" in > mutt) > urxvt -title mutt -e mutt;; > MOC) > urxvt -e mocp;; > *) > echo "don't know how to raise '$@'" >&2 > exit 1;; > esac > fi > Thanks for this, Bastien. Is using xdotool's search option slower or otherwise worse than this? (btw, i'm not sure I know what lsw is) Cheers, Manolo --
Re: [dev] Focusing on windows by name
On 10/26/11 at 05:51pm, Patrick Haller wrote: > > > > In openbox I have a key bound to the following:"wmctrl -xa mutt || > > urxvt -name mutt -e mutt" > > xlsclients | grep -q mutt || urxvt -e mutt > xdotool seems to work: "xdotool search "mutt" windowactivate | urxvt -e mutt" Manolo --
Re: [dev] Focusing on windows by name
Patrick Haller a écrit : > On 2011-10-26 11:48, Manolo Martínez wrote: > > > > In openbox I have a key bound to the following:"wmctrl -xa mutt || > > urxvt -name mutt -e mutt" > > xlsclients | grep -q mutt || urxvt -e mutt No, this is not equivalent because the following command: wmctrl -xa mutt activates the first client matching the given 'title'. You could rather do: #! /bin/sh wid=$(lsw -l | grep -m 1 "$@" | cut -d ' ' -f 1) if [ -n "$wid" ]; then xdotool windowactivate "$wid" else case "$@" in mutt) urxvt -title mutt -e mutt;; MOC) urxvt -e mocp;; *) echo "don't know how to raise '$@'" >&2 exit 1;; esac fi
Re: [dev] Focusing on windows by name
On 10/26/11 at 05:51pm, Patrick Haller wrote: > > In openbox I have a key bound to the following:"wmctrl -xa mutt || > > urxvt -name mutt -e mutt" > > xlsclients | grep -q mutt || urxvt -e mutt > Thanks, Patrick, this does half of what I want: it launches mutt only if there is no previous mutt window. I need now to figure out how to give focus to the existing mutt window. Thanks for the pointer. M
Re: [dev] Focusing on windows by name
On 2011-10-26 11:48, Manolo Martínez wrote: > > In openbox I have a key bound to the following:"wmctrl -xa mutt || > urxvt -name mutt -e mutt" xlsclients | grep -q mutt || urxvt -e mutt