Xfce Forum

Sub domains
 

You are not logged in.

#1 2026-01-15 03:00:25

rayandrews
Member
From: Vancouver B.C. Canada
Registered: 2011-12-30
Posts: 220
LinuxFirefox 140.0

[SOLVED] move an aplication to another screen

I have this application that always loads on the rightmost monitor.  I'd like it to open on my center monitor.  It seems that devilspie2 should be able to do that but I can't find a simple example and I get the impression that Xfce might be able to do it native.  Can we?

Last edited by rayandrews (2026-01-15 13:39:06)

Offline

#2 2026-01-15 12:25:58

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 12,426
LinuxFirefox 146.0

Re: [SOLVED] move an aplication to another screen

devilspie2 has a "centre" option that lets you pick a monitor. Something like:

if (get_application_name() == "APPNAME") then
    centre(2);
end

...where "2" is the second monitor.

ref: https://github.com/dsalt/devilspie2


Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2026-01-15 13:34:51

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 12,426
LinuxFirefox 146.0

Re: [SOLVED] move an aplication to another screen

rayandrews wrote:

Ok, so xfce can't get involved in that kind of thing, so it's devilspie then.

Xfce doesn't have this kind of functionality built in - you need to use a third party tool like devilspie(2). It integrates well.


Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#4 2026-01-15 16:53:30

eriefisher
Wanderer
From: ON, Canada
Registered: 2008-10-25
Posts: 870
LinuxFirefox 147.0

Re: [SOLVED] move an aplication to another screen

@ToZ, how would you handle this is a second monitor is only connected part time? As in a laptop that could travel.


I AM CANADIAN!
Siduction
Debian Sid
Xfce 4.20 with Wayland/Labwc

Offline

#5 2026-01-15 23:41:25

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 12,426
LinuxFirefox 146.0

Re: [SOLVED] move an aplication to another screen

eriefisher wrote:

@ToZ, how would you handle this is a second monitor is only connected part time? As in a laptop that could travel.

Devilspie2 supports the lua language so you could do some conditional checks like:

local num_monitors = get_num_monitors()

if (num_monitors > 1) and (get_application_name() == "APPNAME") then
    center(2)
end

Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#6 2026-01-16 11:42:29

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 12,426
LinuxFirefox 147.0

Re: [SOLVED] move an aplication to another screen

My apologies, I'm mixing up programming languages. For lua, you need to actually call an external program to get the number of monitors and then act on it. Instead of just thinking out loud, I've tested this and it seems to work (I've also adjusted the function name so you can call any external program if different needs arise):

function external(cmd)
	local f = assert(io.popen(cmd, 'r'))
	local s = assert(f:read('*a'))
	f:close()
	return s
end

if (get_application_name() == "APPNAME") then
	local num_monitors = tonumber(external("xdpyinfo | grep 'number of screens' | awk -F':    ' '{print $2}'"))
	if (num_monitors > 1) then
		center(2)
	end
end

... the application name is the same as the window name, which is the name of whatever file is given as the argument to geogebra, so the above test, fails for any other file.  I'd have thought this would work:

Try get_class_instance_name() or get_process_name() instead - they might not be unique everytime as you indicate.


Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#7 2026-01-16 14:42:18

rayandrews
Member
From: Vancouver B.C. Canada
Registered: 2011-12-30
Posts: 220
LinuxFirefox 140.0

Re: [SOLVED] move an aplication to another screen

Thanks.  BTW, remembering that this isn't even an xfce issue!

Got it:

To start geogebra:

function gg ()
{
        TITLE=$1
        export TITLE
       devilspie2&
    imwheel  # Speed up the mouse wheel scrolling
    /opt/GeoGebra-Linux-Portable-5-4-911-3/geogebra-portable $1
    imwheel -k -q
}

... and the devilspie2 script:

local file = os.getenv("TITLE")
local name = get_window_name()
--debug_print("file is: " .. file)
--debug_print("name is: " .. name)

if (file == get_window_name()) then
    set_window_geometry(1920,0,1910,1030);
end

:-)

Last edited by rayandrews (2026-01-16 20:17:54)

Offline

#8 Today 18:52:08

rayandrews
Member
From: Vancouver B.C. Canada
Registered: 2011-12-30
Posts: 220
LinuxFirefox 140.0

Re: [SOLVED] move an aplication to another screen

BTW, ToZ, just a followup, I'm up and running with devilspie2, here's the current state of the thing:

debug_print(get_window_name())
debug_print(get_application_name())

if string.match(get_window_name(), "Algebra") then
    set_window_geometry(3840, 0, 951, 1045); -- RL
end

-- GG does not set 'get_application_name' so must use title.
if string.match(get_window_name(), ".ggb") then
    set_window_geometry(1915,0,1920,1035);
end

if (get_application_name() == "geany" ) then
    set_window_geometry(4800, 0, 951, 1035); -- RR
end

... definitely a bug that geogebra doesn't set application name.

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.012 seconds, 7 queries executed - Memory usage: 549.3 KiB (Peak: 566.28 KiB) ]