Xfce Forum

Sub domains
 

You are not logged in.

#1 2019-08-08 16:24:29

juanprm
Member
Registered: 2019-07-10
Posts: 14

[Solved] Problem when launching app by the direct launcher

Hello, i hope i describe my problem with enough details to get a solution.

So, i have a few launchers in my bar, when i open and app with the launcher in the bar i don't want the app open in a new window but in the icon itself.

Here is how this work in windows:

Windows

Notice i have Slack and a few Google Chome windows in the bar and it shows in the app icon.

Otherwise here it's how it shows in EndeavourOS with lastest XFCE updates

Linux

Notice that i have three launchers, i open the terminal and it shows a new window. Is there a way to customize this in XFCE?

Last edited by juanprm (2019-08-10 15:19:58)

Offline

#2 2019-08-08 17:13:40

peter.48
Member
Registered: 2017-01-31
Posts: 124

Re: [Solved] Problem when launching app by the direct launcher

I'm not sure but I think this might be a solution:

-> Panel Preferences -> tab Items -> edit Window butons -> Apppearance -> uncheck Show button labels

Offline

#3 2019-08-08 18:15:08

juanprm
Member
Registered: 2019-07-10
Posts: 14

Re: [Solved] Problem when launching app by the direct launcher

It only hides the text sad i wan't the app uses the icon from the launcher and not show another icon.

Capture.png

Offline

#4 2019-08-08 19:47:44

MrEen
Member
Registered: 2019-04-19
Posts: 295

Re: [Solved] Problem when launching app by the direct launcher

I think what you want is a dock, such as Docky. I don't know if there's an Xfce specific dock, but I'm sure others will offer info on this.

Offline

#5 2019-08-08 20:51:51

juanprm
Member
Registered: 2019-07-10
Posts: 14

Re: [Solved] Problem when launching app by the direct launcher

Yes, i was testing a bit and with a dock it works, maybe there is  a way to achieve this in native?

Offline

#6 2019-08-08 21:02:55

Misko_2083
Member
Registered: 2015-10-13
Posts: 191
Website

Re: [Solved] Problem when launching app by the direct launcher

You could use ToZ's script for the launcher.
https://forum.xfce.org/viewtopic.php?pid=24932#p24932


Do you want to exit the Circus?
https://www.youtube.com/watch?v=ZJwQicZHp_c

Offline

#7 2019-08-08 23:30:52

juanprm
Member
Registered: 2019-07-10
Posts: 14

Re: [Solved] Problem when launching app by the direct launcher

Misko_2083 wrote:

You could use ToZ's script for the launcher.
https://forum.xfce.org/viewtopic.php?pid=24932#p24932

Thanks, that looks kinda tricky but if it works ill give a shot big_smile
Hoping ToZ answers here and give me another solution or give me the simplified steps to implement his script.

Offline

#8 2019-08-08 23:47:48

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: [Solved] Problem when launching app by the direct launcher

Yeah, the script is kind of a workaround. There is no such functionality in Xfce. You either need to use a dock program (like plank, docky, etc), a panel plugin like docbarx, or the script.

Implement the script is tricky in that you have to change the .desktop files of every program that you want to work like that. It's time-consuming.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#9 2019-08-09 01:37:17

juanprm
Member
Registered: 2019-07-10
Posts: 14

Re: [Solved] Problem when launching app by the direct launcher

Ill go with the script, can u rewrite the steps? i tried to make it works but its kinda confusing, forgive me, i'm new in Linux.

Offline

#10 2019-08-09 02:12:20

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: [Solved] Problem when launching app by the direct launcher

Steps:

  1. Save the following script somewhere in your path (/usr/local/bin is good). Lets call is /usr/local/bin/xlaunch

    #!/bin/bash
    # This script acts as a launcher for apps that observes the following rules:
    #   1. If the app is not running, then start it up
    #   2. If the app is running, don't start a second instance, instead:
    #     2a. If the app does not have focus, give it focus
    #     2b. If the app has focus, minimize it
    # Reference link: http://forum.xfce.org/viewtopic.php?id=6168&p=1
    
    # there has to be at least one parameter, the name of the file to execute
    if [ $# -lt 1 ]
    then
      echo "Usage: `basename $0` {executable_name parameters}"
      exit 1
    fi
    
    BNAME=`basename $1`
    
    # test to see if program is already running
    if [ "`wmctrl -lx | tr -s ' ' | cut -d' ' -f1-3 | grep -i $BNAME`" ]; then 
    	# means it must already be running
    	ACTIV_WIN=$(xdotool getactivewindow getwindowpid)
    	LAUNCH_WIN=$(ps -ef | grep "$BNAME" | grep -v grep | tr -s ' ' | cut -d' ' -f2 | head -n 1)
    
    	if [ "$ACTIV_WIN" == "$LAUNCH_WIN" ]; then
    		# launched app is currently in focus, so minimize
    		xdotool getactivewindow windowminimize
    	else
    		# launched app is not in focus, so raise and bring to focus
    		for win in `wmctrl -lx | tr -s ' ' | cut -d' ' -f1-3 | grep -i $BNAME | cut -d' ' -f1`
    		do
    		    wmctrl -i -a $win
    		done
    	fi
    	exit
    
    else
    	# start it up
    	$*&
    fi
    
    exit 0
  2. Make the script executable:

    chmod +x /usr/local/bin/xlaunch
  3. For every program that you want this to work for, copy the program's .desktop file from /usr/share/applications to ~/.local/share/applications (create the directory if it doesn't exist)

  4. For every desktop file you copied over, change the "Exec=" line by prepending "xlaunch" to each program executable. For example, for the mousepad application, change:

    Exec=mousepad %F

    ...to:

    Exec=xlaunch mousepad %F

That should do it.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#11 2019-08-09 04:13:49

juanprm
Member
Registered: 2019-07-10
Posts: 14

Re: [Solved] Problem when launching app by the direct launcher

It don't work, am i doing something wrong?

PlFdkJw.png

This is my root folder (testing it in a live iso in case i break something)

uoBKP7h.png

This is where the script is.

kxxM6r8.png

This is the content of the file.

yXUDF46.png

This is the launcher command, everything LGTM but i don't know what is failing.

I did the steps one by one, making sure that everything is correct, I also did them again with other applications but it still does not work.

Last edited by juanprm (2019-08-09 04:23:53)

Offline

#12 2019-08-09 10:33:17

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: [Solved] Problem when launching app by the direct launcher

Can you post back the results of the following commands run from a terminal window:

echo $PATH
ls -l /usr/local/bin/xlaunch
which xlaunch
cat ~/.local/share/applications/Thunar.desktop | grep Exec
cat ~/.local/share/applications/transmission-gtk.desktop | grep Exec

Edit: Also make sure that xdotool and wmctrl are installed.

Last edited by ToZ (2019-08-09 13:13:02)


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#13 2019-08-09 15:11:38

juanprm
Member
Registered: 2019-07-10
Posts: 14

Re: [Solved] Problem when launching app by the direct launcher

UG07NsN.png

This is the result from the commands

Also make sure that xdotool and wmctrl are installed.

Both are installed.

Last edited by juanprm (2019-08-09 15:12:40)

Offline

#14 2019-08-09 17:47:39

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: [Solved] Problem when launching app by the direct launcher

Can you first try with a simpler program like mousepad or parole and use the following script?

#!/bin/bash
# This script acts as a launcher for apps that observes the following rules:
#   1. If the app is not running, then start it up
#   2. If the app is running, don't start a second instance, instead:
#     2a. If the app does not have focus, give it focus
#     2b. If the app has focus, minimize it
# Reference link: http://forum.xfce.org/viewtopic.php?id=6168&p=1

echo "1.start-->$(date)" >> /tmp/xlog
# there has to be at least one parameter, the name of the file to execute
if [ $# -lt 1 ]
then
  echo "Usage: `basename $0` {executable_name parameters}"
  exit 1
fi
echo "2.after check" >> /tmp/xlog

BNAME=`basename $1`
echo "3.BNAME=$BNAME" >> /tmp/xlog

# test to see if program is already running
if [ "`wmctrl -lx | tr -s ' ' | cut -d' ' -f1-3 | grep -i $BNAME`" ]; then 
	echo "4.$BNAME is running" >> /tmp/xlog
	# means it must already be running
	ACTIV_WIN=$(xdotool getactivewindow getwindowpid)
	LAUNCH_WIN=$(ps -ef | grep "$BNAME" | grep -v grep | tr -s ' ' | cut -d' ' -f2 | head -n 1)
	echo "5.ACTIV_WIN=$ACTIV_WIN" >> /tmp/xlog
	echo "6.LAUNCH_WIN=$LAUNCH_WIN" >> /tmp/xlog

	if [ "$ACTIV_WIN" == "$LAUNCH_WIN" ]; then
		# launched app is currently in focus, so minimize
		echo "7.launched app in focus so minimize" >> /tmp/xlog
		xdotool getactivewindow windowminimize
	else
		# launched app is not in focus, so raise and bring to focus
		echo "8.launched app is not in focus" >> /tmp/xlog
		for win in `wmctrl -lx | tr -s ' ' | cut -d' ' -f1-3 | grep -i $BNAME | cut -d' ' -f1`
		do
		    echo "9.bring to focus" >> /tmp/xlog
		    wmctrl -i -a $win
		done
	fi
else
	echo "10.starting up app" >> /tmp/xlog
	# start it up
	exec $*&
fi
echo "11.end" >> /tmp/xlog
exit 0

I've changed some code and added debug statements. Do the following test:

  1. From menu, select mousepad/parole (it should show up)

  2. From menu, select mousepad/parole (it should minimize)

  3. From menu, select mousepad/parole (it should display again)

...and then post back the contents of the /tmp/xlog file.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#15 2019-08-09 18:35:03

juanprm
Member
Registered: 2019-07-10
Posts: 14

Re: [Solved] Problem when launching app by the direct launcher

From menu, select mousepad/parole (it should show up)

    From menu, select mousepad/parole (it should minimize)

    From menu, select mousepad/parole (it should display again)

That works exactly as you said,


...and then post back the contents of the /tmp/xlog file.

Here it is.

1.start-->Fri 09 Aug 2019 01:30:03 PM UTC
2.after check
3.BNAME=mousepad
10.starting up app
11.end
1.start-->Fri 09 Aug 2019 01:30:12 PM UTC
2.after check
3.BNAME=mousepad
4.mousepad is running
5.ACTIV_WIN=1378
6.LAUNCH_WIN=2082
8.launched app is not in focus
9.bring to focus
11.end
1.start-->Fri 09 Aug 2019 01:30:31 PM UTC
2.after check
3.BNAME=mousepad
10.starting up app
11.end
1.start-->Fri 09 Aug 2019 01:30:39 PM UTC
2.after check
3.BNAME=mousepad
4.mousepad is running
5.ACTIV_WIN=2121
6.LAUNCH_WIN=2121
7.launched app in focus so minimize
11.end
1.start-->Fri 09 Aug 2019 01:30:46 PM UTC
2.after check
3.BNAME=mousepad
4.mousepad is running
5.ACTIV_WIN=1378
6.LAUNCH_WIN=2121
8.launched app is not in focus
9.bring to focus
11.end
1.start-->Fri 09 Aug 2019 01:31:28 PM UTC
2.after check
3.BNAME=mousepad
4.mousepad is running
5.ACTIV_WIN=979
6.LAUNCH_WIN=2121
8.launched app is not in focus
9.bring to focus
11.end
1.start-->Fri 09 Aug 2019 01:31:40 PM UTC
2.after check
3.BNAME=mousepad
10.starting up app
11.end

Offline

#16 2019-08-09 18:50:13

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: [Solved] Problem when launching app by the direct launcher

Good. Now clear the contents of the script:

> /tmp/xlog

...and try with transmission. Post back the contents of that log file after your tests.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#17 2019-08-09 20:31:37

juanprm
Member
Registered: 2019-07-10
Posts: 14

Re: [Solved] Problem when launching app by the direct launcher

...and try with transmission. Post back the contents of that log file after your tests.

Here is the log.

1.start-->Fri 09 Aug 2019 03:27:22 PM UTC
2.after check
3.BNAME=transmission-gtk
10.starting up app
11.end
1.start-->Fri 09 Aug 2019 03:27:29 PM UTC
2.after check
3.BNAME=transmission-gtk
4.transmission-gtk is running
5.ACTIV_WIN=1947
6.LAUNCH_WIN=1947
7.launched app in focus so minimize
11.end
1.start-->Fri 09 Aug 2019 03:27:33 PM UTC
2.after check
3.BNAME=transmission-gtk
4.transmission-gtk is running
5.ACTIV_WIN=1711
6.LAUNCH_WIN=1947
8.launched app is not in focus
9.bring to focus
11.end
1.start-->Fri 09 Aug 2019 03:27:38 PM UTC
2.after check
3.BNAME=transmission-gtk
4.transmission-gtk is running
5.ACTIV_WIN=1947
6.LAUNCH_WIN=1947
7.launched app in focus so minimize
11.end
1.start-->Fri 09 Aug 2019 03:27:59 PM UTC
2.after check
3.BNAME=transmission-gtk
10.starting up app
11.end
1.start-->Fri 09 Aug 2019 03:28:01 PM UTC
2.after check
3.BNAME=transmission-gtk
4.transmission-gtk is running
5.ACTIV_WIN=2077
6.LAUNCH_WIN=2077
7.launched app in focus so minimize
11.end
1.start-->Fri 09 Aug 2019 03:28:02 PM UTC
2.after check
3.BNAME=transmission-gtk
4.transmission-gtk is running
5.ACTIV_WIN=1711
6.LAUNCH_WIN=2077
8.launched app is not in focus
9.bring to focus
11.end
1.start-->Fri 09 Aug 2019 03:28:02 PM UTC
2.after check
3.BNAME=transmission-gtk
4.transmission-gtk is running
5.ACTIV_WIN=2077
6.LAUNCH_WIN=2077
7.launched app in focus so minimize
11.end
1.start-->Fri 09 Aug 2019 03:28:03 PM UTC
2.after check
3.BNAME=transmission-gtk
4.transmission-gtk is running
5.ACTIV_WIN=1711
6.LAUNCH_WIN=2077
8.launched app is not in focus
9.bring to focus
11.end
1.start-->Fri 09 Aug 2019 03:28:03 PM UTC
2.after check
3.BNAME=transmission-gtk
4.transmission-gtk is running
5.ACTIV_WIN=2077
6.LAUNCH_WIN=2077
7.launched app in focus so minimize
11.end
1.start-->Fri 09 Aug 2019 03:28:05 PM UTC
2.after check
3.BNAME=transmission-gtk
4.transmission-gtk is running
5.ACTIV_WIN=1711
6.LAUNCH_WIN=2077
8.launched app is not in focus
9.bring to focus
11.end
1.start-->Fri 09 Aug 2019 03:28:06 PM UTC
2.after check
3.BNAME=transmission-gtk
4.transmission-gtk is running
5.ACTIV_WIN=2077
6.LAUNCH_WIN=2077
7.launched app in focus so minimize
11.end

Offline

#18 2019-08-10 00:34:17

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: [Solved] Problem when launching app by the direct launcher

The logs say it is working. Is it working properly?


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#19 2019-08-10 03:07:44

juanprm
Member
Registered: 2019-07-10
Posts: 14

Re: [Solved] Problem when launching app by the direct launcher

Yes, it is working, but I think we deviate a bit from the OP.

Maybe i should explain it again?

Offline

#20 2019-08-10 11:24:01

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: [Solved] Problem when launching app by the direct launcher

Sure. But keep in mind that the functionality you are asking for is not present in xfce4-panel. This is just a workaround to mimic that functionality.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#21 2019-08-10 15:19:36

juanprm
Member
Registered: 2019-07-10
Posts: 14

Re: [Solved] Problem when launching app by the direct launcher

Thanks for the help, sorry for wasting your time editing the scripts.

Offline

Board footer

Powered by FluxBB