You are not logged in.

#1 2015-06-08 13:44:08

Fred7109
Member
Registered: 2015-05-17
Posts: 134

[Solved] Hotkey and detecting workspace + running programs

Hi

I have a hotkey 'Super + z' set to open https://search.disconnect.me/. If I run the script when firefox is in another workspace, then it takes firefox and move it to my current workspace where i ran the script.

Is it therefore possible to make a script with bash or python, so if firefox is running in the same workspace then it will open the website as a new tab in firefox. But if firefox is running in another workspace, then it will open a new instance of firefox in the current workspace and launch the website.

Regards
Frederik Jørgensen

Last edited by Fred7109 (2015-06-08 15:03:15)

Offline

#2 2015-06-08 14:09:28

Malkymder
Member
Registered: 2015-05-13
Posts: 258

Re: [Solved] Hotkey and detecting workspace + running programs

Your current Desktop manager would be usefull info to provide wink

Offline

#3 2015-06-08 14:10:48

Fred7109
Member
Registered: 2015-05-17
Posts: 134

Re: [Solved] Hotkey and detecting workspace + running programs

Sorry for the missing info. I am using XFCE and the default window manager smile

Last edited by Fred7109 (2015-06-08 14:15:31)

Offline

#4 2015-06-08 14:45:15

Malkymder
Member
Registered: 2015-05-13
Posts: 258

Re: [Solved] Hotkey and detecting workspace + running programs

Here is a bash script that should work for you

Install this if you don't already have it installed

 sudo pacman -S wmctrl
#!/bin/bash
# Find Firefox
ff_desktop="$( wmctrl -l | grep Firefox |awk '{print $2}' )"
# show current desktop
curr_desktop="$( wmctrl -d | gawk '{if ($2 == "*") print $1}' )"
#
if [ "$ff_desktop" == "$curr_desktop" ]; then # firefox opened in the same workspace
    exec firefox --new-tab https://search.disconnect.me/
else
    exec firefox --new-window https://search.disconnect.me/
fi

Offline

#5 2015-06-08 15:02:50

Fred7109
Member
Registered: 2015-05-17
Posts: 134

Re: [Solved] Hotkey and detecting workspace + running programs

Thanks for help!
But the script is not working perfect yet. Because it always open firefox in a new window, it should only open firefox in a new window if there not is a current instance in the same workspace? smile

Last edited by Fred7109 (2015-06-08 15:12:32)

Offline

#6 2015-06-08 15:44:03

Fred7109
Member
Registered: 2015-05-17
Posts: 134

Re: [Solved] Hotkey and detecting workspace + running programs

I have made som small changes and now it works perfect:

#!/bin/bash
# Find Firefox
ff_desktop="$( wmctrl -l | grep Firefox |awk '{print $2}' )"
# show current desktop
curr_desktop="$( wmctrl -d | gawk '{if ($2 == "*") printf $1}' )"
#
if [[ $ff_desktop == *"$curr_desktop"* ]]; then # firefox is opened in the same workspace
    exec firefox --new-tab https://search.disconnect.me/
else
    exec firefox --new-window https://search.disconnect.me/
fi

Last edited by Fred7109 (2015-06-08 16:43:11)

Offline

Board footer

Powered by FluxBB