Recent

Author Topic: KDE/Plasma: Switch between activities?  (Read 4444 times)

sierdolg

  • New Member
  • *
  • Posts: 21
KDE/Plasma: Switch between activities?
« on: November 29, 2019, 02:09:56 pm »
OK, this may be a very specific question now, but maybe someone can help anyway:

Does anyone have experience (or an idea) of how to move the window of a Lazarus form from one activity to another via code (not necessarily in ObjectPascal, it could also be an external shell call)?

I have a modest application that I use frequently and that I don't want to restart if it's already running. Instead, the running application's window shall be switched from the activity where it was displayed before to my current activity.

UniqueInstance works very well when it comes to preventing multiple start.

However, in order to achieve the behavior described above, I must also
(1) find out on which activity the most recent start attempt took place
- and -
(2) move the current window to this activity.

I've been looking around for a while, but haven't found neither solutions nor  further informationabout a Linux command line tool capable of moving an existing window from activity A to activity B.

Therefore any idea would be welcome!

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: KDE/Plasma: Switch between activities?
« Reply #1 on: November 29, 2019, 02:44:53 pm »
I use KDE but have never played with activities. Is there a dbus message to tell a window to move between activities?

Is it even possible to move a single window, or does this have to be done for the entire program i.e. all windows?

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

zeljko

  • Hero Member
  • *****
  • Posts: 1594
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: KDE/Plasma: Switch between activities?
« Reply #2 on: November 29, 2019, 02:48:32 pm »
AFAIK x11 does not know anything about "activities" , only about pager (virtual desktops) ,so maybe you should check dbus specs.

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: KDE/Plasma: Switch between activities?
« Reply #3 on: November 29, 2019, 03:20:20 pm »
Hi!

Sorry sierdolg - you are the first one that I know that uses that stuff.

As zeljko said this is not the domain of the X server.
Perhaps you find more information on the KDE development pages.

And:  KDE should repair their big amount of bugs. Instead of inventing new useless features.

Winni

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: KDE/Plasma: Switch between activities?
« Reply #4 on: December 01, 2019, 06:13:41 am »
Is there any difference between KDE "Activities" and Gnome "workspaces" ?

I am wondering if whatever works for the display pager or workspace switcher would also work under KDE ?

My problem is I don't know how to get a window to move itself between workspaces either. And I would dearly like to ....

From what I see it might be gdk display calls and thats sure not going to work on KDE ....

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

bylaardt

  • Sr. Member
  • ****
  • Posts: 309
Re: KDE/Plasma: Switch between activities?
« Reply #5 on: December 01, 2019, 02:26:38 pm »
Does anyone have experience (or an idea) of how to move the window of a Lazarus form from one activity to another via code (not necessarily in ObjectPascal, it could also be an external shell call)?
maybe
qdbus org.kde.ActivityManager /ActivityManager/Resources/Linking

you can use  from shell:
Code: Bash  [Select][+][-]
  1. qdbus org.kde.ActivityManager /ActivityManager/Resources/Linking LinkResourceToActivity [agent] [resource] [activity]
  2. qdbus org.kde.ActivityManager /ActivityManager/Resources/Linking ResourceUnlinkedFromActivity [agent] [resource] [activity]

Is there any difference between KDE "Activities" and Gnome "workspaces" ?
Workspaces are more similar to "desktop" concept on KDE.
In different "activities" you have different widgets while on the "desktop" is ever the same.
To  manage "desktops, use:
Code: Bash  [Select][+][-]
  1. qdbus org.kde.KWin /KWin

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: KDE/Plasma: Switch between activities?
« Reply #6 on: December 01, 2019, 10:43:24 pm »
Indeed !

(workspaces, not activities, sorry sierdolg)

I have a qdbus command on my U18.04 Mate - probably because I have installed QT5 on it. Sure looks like it needs to be looked into !  Thanks for that tip bylaardt

Davo

Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: KDE/Plasma: Switch between activities?
« Reply #7 on: December 02, 2019, 12:04:56 am »
Hi!

How ro interact  with the KDE Plasma Desktop via JavaScript:

https://userbase.kde.org/KDE_System_Administration/PlasmaDesktopScripting

Perhaps it helps.


Winni

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: KDE/Plasma: Switch between activities?
« Reply #8 on: December 02, 2019, 12:24:55 pm »
Hmm, I can sure switch a window (ie a Lazarus Form) between workspaces using wmctrl.  While this is not  what the the original question was about but it may help someone ...

Code: Pascal  [Select][+][-]
  1. function TSearchForm.MoveNoteWindowHere(WTitle : string) : boolean;
  2. var
  3.     AProcess: TProcess;
  4.     List : TStringList = nil;
  5. begin
  6.     Result := False;
  7.     {$IFDEF LINUX}
  8.     AProcess := TProcess.Create(nil);
  9.     AProcess.Executable:= 'wmctrl';
  10.     AProcess.Parameters.Add('-R' + WTitle);
  11.     AProcess.Options := AProcess.Options + [poWaitOnExit, poUsePipes];
  12.     try
  13.         AProcess.Execute;
  14.         Result := (AProcess.ExitStatus = 0);        // says at least one packet got back
  15.     except on
  16.         E: EProcess do debugln('Could not move ' + WTitle);
  17.     end;
  18.     if not Result then
  19.         debugln('wmctrl error trying to move ' + WTitle);
  20.     List := TStringList.Create;
  21.     List.LoadFromStream(AProcess.Output);       // just to clear it away.
  22.     List.Free;
  23.     AProcess.Free;
  24.     {$endif}
  25. end;
         

In Lazarus, the Window Title is actually the TForm.Caption, so dead easy. The above function grabs the nominated window and if its not in the current workspace, brings it there. My guess is that there is a api that could be used, calling TProcess is not exactly elegent but it does work.

Works on Gnome or QT based desktops but does not address this new KDE thing of 'activities'. 

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: KDE/Plasma: Switch between activities?
« Reply #9 on: December 02, 2019, 12:45:52 pm »
I note that Debian describes that as

Code: Pascal  [Select][+][-]
  1. wmctrl - control an EWMH/NetWM compatible X Window Manager
  2.  

which might turn out to be useful search terms.

As others have said, I suspect that all of this is a level of abstraction that X11 knows nothing about. At that level it's all implemented as minimise/hide operations.

Windows of course does have "Window Stations" etc., I've previously walked the entire tree of that for a watchdog program.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: KDE/Plasma: Switch between activities?
« Reply #10 on: December 02, 2019, 10:38:32 pm »
Code: Pascal  [Select][+][-]
  1. wmctrl - control an EWMH/NetWM compatible X Window Manager
  2.  

I have tested my approach with both XOrg and Wayland, what a thrill it was to test something on Wayland and find it works !

Windows ?  Yeah, I read somewhere that Windows was trying to do virtual workspaces as well, thats great. Funny they start doing it just as Linux distros are starting to hide it from users. Gnome (of course) in particular. Personally, I would not survive without workspaces.

So, for Windows, the key word is "Window Stations" ?

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018