LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 01-30-2020, 08:35 AM   #1
Agent X
LQ Newbie
 
Registered: Jan 2020
Location: Somewhere
Distribution: Manjaro KDE
Posts: 12

Rep: Reputation: 4
Howto auto-switch apps assigned desktop when app is launched


Below copies of post from a thread I have on the Manjaro forums. Any help finding a solution would be appreciated.

Quote:
I've noticed that sometime when I click a app to launch it I get taken to it's assigned desktop. I like this behavior and would like to know how to make it universal. Myself I'm use to just clicking on the particular virtual desktop in Pager, but my friend still gets a bit confused on what to do when a app opens on a different desktop than one he's on. For him auto-switching would be much easier cause he's still so new to Linux. Thanks
Quote:
Example:

kstart5 --desktop 4 /usr/bin/vivaldi-stable
Either edit the desktop file in /usr/share/applications or write a script file.
Quote:
That's simple enough. Not the script still don't really know that much about creating my own scripts. Thanks[/CODE]

[CODE]What applications are you wanting to run? I have a really good script that may help you.
Code:
#!/bin/bash
#notify-send "Starting/Switching to Browser"
######################################################################################################
# This script will toggle minimize/activate first window with specified class
# If window not found program will be launched
#
# window class can be found with next programs:
#   wmctrl -x -l
#   xprop
# No credit taken.......... Cannot read the original.....
# Found on http://blog.sokolov.me/2014/06/20/linuxx11-toggle-window-minimizemaximize/
# in Russian :) but works when adjusting the wrapping.
# Assigned to meta-f in KDE plasma 5
######################################################################################################
NEEDED_WINDOW_CLASS="Navigator.firefox"
LAUNCH_PROGRAM="kstart5 --desktop 4 /usr/bin/firefox"
######################################################################################################
NEEDED_WINDOW_WINDOW_ID_HEX=`wmctrl -x -l | grep "${NEEDED_WINDOW_CLASS}" | awk '{print $1}' | head -n 1`
NEEDED_WINDOW_WINDOW_ID_DEC=$((${NEEDED_WINDOW_WINDOW_ID_HEX}))
if [ -z "${NEEDED_WINDOW_WINDOW_ID_HEX}" ]; then
    ${LAUNCH_PROGRAM}&
else
    echo "Found window ID:${NEEDED_WINDOW_WINDOW_ID_DEC}(0x${NEEDED_WINDOW_WINDOW_ID_HEX})"
    ACIVE_WINDOW_DEC=`xdotool getactivewindow`
    if [ "${ACIVE_WINDOW_DEC}" == "${NEEDED_WINDOW_WINDOW_ID_DEC}" ]; then
        xdotool windowminimize ${NEEDED_WINDOW_WINDOW_ID_DEC}
    else
        xdotool windowactivate ${NEEDED_WINDOW_WINDOW_ID_DEC}
    fi
fi
Quote:
Assign to a hot key. It launches firefox on first press, subsequent presses raise or lower firefox.

Needs xdotool & wmctrl installed.
Quote:
kstart5 --desktop 4 /usr/bin/vivaldi-stable

I'm going to be better off with that I think. Got it to work with Vivaldi but not Chrome.
Quote:
What did you try for chrome??

Think it is called google-chrome-stable.....
Quote:
start panel, search google, rightclick edit application, click application tab, and kstart5 --desktop 2 /usr/bin/google-chrome-stable %U under command.
Quote:
Let me test.

From a terminal:

kstart5 --desktop 4 /usr/bin/google-chrome-stable
works. Also works if I do what you did - check for a space missing.
Code:
[agentx@Secret-Computer ~]$ kstart5 --desktop 4 /usr/bin/google-chrome-stab
le
Omitting both --window and --windowclass arguments is not recommended
Icon theme "HiColor" not found.
Icon theme "Gnome" not found.
Invalid Context= "Legacy" line for icon theme:  "/usr/share/icons/Adwai
ta/8x8/legacy/"
Invalid Context= "Legacy" line for icon theme:  "/usr/share/icons/Adwai
ta/16x16/legacy/"
Invalid Context= "UI" line for icon theme:  "/usr/share/icons/Adwaita/1
6x16/ui/"
Invalid Context= "Legacy" line for icon theme:  "/usr/share/icons/Adwai
ta/22x22/legacy/"
Invalid Context= "Legacy" line for icon theme:  "/usr/share/icons/Adwai
ta/24x24/legacy/"
Invalid Context= "UI" line for icon theme:  "/usr/share/icons/Adwaita/2
4x24/ui/"
Invalid Context= "Legacy" line for icon theme:  "/usr/share/icons/Adwai
ta/32x32/legacy/"
Invalid Context= "UI" line for icon theme:  "/usr/share/icons/Adwaita/3
2x32/ui/"
Invalid Context= "Legacy" line for icon theme:  "/usr/share/icons/Adwai
ta/48x48/legacy/"
Invalid Context= "UI" line for icon theme:  "/usr/share/icons/Adwaita/4
8x48/ui/"
Invalid Context= "Legacy" line for icon theme:  "/usr/share/icons/Adwai
ta/256x256/legacy/"
Invalid Context= "Legacy" line for icon theme:  "/usr/share/icons/Adwai
ta/512x512/legacy/"
Invalid Context= "Legacy" line for icon theme:  "/usr/share/icons/Adwai
ta/scalable/legacy/"
Invalid Context= "UI" line for icon theme:  "/usr/share/icons/Adwaita/s
calable/ui/"
[agentx@Secret-Computer ~]$ [1:1:0129/134334.822197:ERROR:chrome_content_cl
ient.cc(322)] Failed to locate and load the component updated flash plu
gin.
[5145:5145:0129/134335.004685:ERROR:chrome_content_client.cc(322)] Fail
ed to locate and load the component updated flash plugin.
[5145:5182:0129/134335.044566:ERROR:token_service_table.cc(140)] Failed
to decrypt token for service AccountId-102006715617681275257
[5145:5145:0129/134335.978620:ERROR:account_tracker.cc(241)] AccessToke
nFetched error: Invalid credentials (credentials missing).
[5210:1:0129/134337.581805:ERROR:child_process_sandbox_support_impl_lin
ux.cc(79)] FontService unique font name matching request did not receiv
e a response.
[5210:1:0129/134337.582606:ERROR:child_process_sandbox_support_impl_lin
ux.cc(79)] FontService unique font name matching request did not receiv
e a response.
[5210:1:0129/134337.584911:ERROR:child_process_sandbox_support_impl_lin
ux.cc(79)] FontService unique font name matching request did not receiv
e a response.
[5210:1:0129/134337.585792:ERROR:child_process_sandbox_support_impl_lin
ux.cc(79)] FontService unique font name matching request did not receiv
e a response.
Quote:
Weird, you can ignore the theme/icon/font stuff, I get:
Code:
21:45:38 ➜ ~ took 28s ➜ kstart5 --desktop 4 /usr/bin/google-chrome-stable
Omitting both --window and --windowclass arguments is not recommended
Icon theme "Yaru" not found.
21:48:20 ➜ ~ ➜ [1:1:0129/214820.187466:ERROR:chrome_content_client.cc(322)] Failed to locate and load the component updated flash plugin.
[21313:21313:0129/214820.383503:ERROR:chrome_content_client.cc(322)] Failed to locate and load the component updated flash plugin.
[21505:21505:0129/214820.512134:ERROR:sandbox_linux.cc(372)] InitializeSandbox() called with multiple threads in process gpu-process.
[21532:1:0129/214821.385944:ERROR:child_process_sandbox_support_impl_linux.cc(79)] FontService unique font name matching request did not receive a response.
[21532:1:0129/214821.387853:ERROR:child_process_sandbox_support_impl_linux.cc(79)] FontService unique font name matching request did not receive a response.

Last edited by Agent X; 01-30-2020 at 08:27 PM.
 
Old 01-30-2020, 08:26 PM   #2
Agent X
LQ Newbie
 
Registered: Jan 2020
Location: Somewhere
Distribution: Manjaro KDE
Posts: 12

Original Poster
Rep: Reputation: 4
Got it finally.

System Settings, Window Management, Window Behavior, change Focus stealing prevention to None.

Tested with various apps and each automatically took me to their assigned desktop when launched.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to put on the desktop icons for the apps to be launched? iqbala Bodhi 6 05-25-2019 02:06 PM
[SOLVED] using switch in a function to call another function with a switch but it is not going into 2 switch ... BW-userx Programming 2 08-20-2017 11:47 PM
dvd has no URL assigned, so I can't play dvd's(no url assigned is the error message) Zych Linux - Newbie 3 08-01-2010 07:26 AM
can I reserve a keyboard shortcut for an app if it's already assigned? newbiesforever Linux - General 2 11-07-2008 11:17 AM
How can I configure a GNOME desktop shortcut to authenticate to run the assigned app? tim914 Linux - Desktop 6 10-02-2008 06:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 07:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration