You are not logged in.

#1 2018-10-09 22:33:42

pepemopap
Member
Registered: 2015-09-30
Posts: 49

Exec comand when windows focus?

Hi friends! There is a way for config Openbox to exec some command when a windows is focused? I have done some changes in rc.xml before but no idea if it is possible.
Thanks!

Offline

#2 2018-10-10 05:45:37

ohnonot
...again
Registered: 2015-09-29
Posts: 5,592

Re: Exec comand when windows focus?

when any window is focused???
or a certain, defined window?
please tell us what you are trying to achieve, i think there's probably a better way.

Offline

#3 2018-10-10 07:08:37

pepemopap
Member
Registered: 2015-09-30
Posts: 49

Re: Exec comand when windows focus?

Any windows or certain, dont mind.

I need create a special user account, when it login and start openbox a virtual machine is automatically opened in fullscreen mode. Its easy config openbox/autostart with:

vboxmanage startvm "{8fca9a6d-b285-4873-912f-c873ae41a1d1}"

The problem is that when virtualmachine is powered off I would like to logout and go back to lightdm or poweroff the computer automatically. I have no idea how to solve it, because when vboxmanage startvm command is exec, it runs in background and dont wait until the process ends, and continue executing next command. This is because i cant do something similar to:

vboxmanage startvm "{8fca9a6d-b285-4873-912f-c873ae41a1d1}"; poweroff

My idea is exec some script when virtualbox losses the focus for this special user.

Thanks for your support!

Last edited by pepemopap (2018-10-10 07:28:55)

Offline

#4 2018-10-10 08:23:17

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,755

Re: Exec comand when windows focus?

Offline

#5 2018-10-10 10:32:37

pepemopap
Member
Registered: 2015-09-30
Posts: 49

Re: Exec comand when windows focus?

brontosaurusrex wrote:

Thanks, but iI would prefer another solution thath no use a infinite pooling loop exec a command every second.

Offline

#6 2018-10-10 11:09:49

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,755

Re: Exec comand when windows focus?

^ Fair, there is also 'xprop -spy'
https://askubuntu.com/questions/1010276 … ut-polling
but irc i read someplace that is memory leaker.

Offline

#7 2018-10-11 04:42:47

ohnonot
...again
Registered: 2015-09-29
Posts: 5,592

Re: Exec comand when windows focus?

pepemopap wrote:

The problem is that when virtualmachine is powered off I would like to logout and go back to lightdm or poweroff the computer automatically. I have no idea how to solve it, because when vboxmanage startvm command is exec, it runs in background and dont wait until the process ends, and continue executing next command. This is because i cant do something similar to:

vboxmanage startvm "{8fca9a6d-b285-4873-912f-c873ae41a1d1}"; poweroff

i see.
so what you really need is vboxmanage to stay in the foreground.
i just had a look at how vboxmanage actually starts virtual machines.
looking at output from

ps aux

i noticed that vboxmanage just starts a few other processes, namely something like this:

/usr/lib/virtualbox/VirtualBox --comment refracta --startvm d384c0d0-389e-49c0-8f5b-18b56fb327d8 --no-startvm-errormsgbox

i tried, and i can start this directly, and it stays in the foreground.
so try adding this to autostart:

/usr/lib/virtualbox/VirtualBox --comment refracta --startvm d384c0d0-389e-49c0-8f5b-18b56fb327d8 --no-startvm-errormsgbox; poweroff

Offline

#8 2018-10-11 19:27:34

pepemopap
Member
Registered: 2015-09-30
Posts: 49

Re: Exec comand when windows focus?

Wow ohnonot! Very clever! Works perfect!
Thanks

Offline

Board footer

Powered by FluxBB