You are not logged in.

#1 2015-05-26 17:19:53

Pank
Member
From: IT
Registered: 2009-06-13
Posts: 371

[Solved] Gnome-Shell and separating programs in the program switcher

Hi,

I would like to treat different instances of Emacs as different programs in Super-Tab program switcher in Gnome-Shell (I run mail and music in different instances).

In the overview they show as different programs via .desktop files.  But with Super-Tab they always collapse into one program (always with the normal Emacs icon).

Any tips on how to tell gnome that different instances of some program is are to be considered different applications?

Here's an example of a desktop file that I use to start a "specialized" Emacs instance.

#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Name=EMMS
GenericName=Music Player
GenericName[es]=Reproductor de música
Comment=The Emacs Multimedia System.
Exec=emacsclient -s emms -ca '' --eval "(progn (setq x-resource-class \"EMMS\") (emms-smart-browse) )" -F '((title . "EMMS") (icon-type . "/home/rasmus/.local/share/icons/emms.png"))'
Icon=emms
Terminal=false
Type=Application
StartupNotify=true
Categories=AudioVideo;Player;Audio;

Last edited by Pank (2015-05-28 14:35:58)


Arch x64 on Thinkpad X200s/W530

Offline

#2 2015-05-28 12:04:53

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

Re: [Solved] Gnome-Shell and separating programs in the program switcher

Offline

#3 2015-05-28 12:29:08

Pank
Member
From: IT
Registered: 2009-06-13
Posts: 371

Re: [Solved] Gnome-Shell and separating programs in the program switcher

Unfortunately your suggestions would break grouping for other applications...


Arch x64 on Thinkpad X200s/W530

Offline

#4 2015-05-28 13:11:44

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

Re: [Solved] Gnome-Shell and separating programs in the program switcher

For this you would have to change the window's class
Try working with something like

xprop -name "<nameofmywindow>" -f WM_CLASS 8s -set WM_CLASS "<mynewclass>"

not sure why  x-resource-class \"EMMS\") isn't working when you use

Exec=emacsclient -s emms -ca '' --eval "(progn (setq x-resource-class \"EMMS\") (emms-smart-browse) )" -F '((title . "EMMS") (icon-type . "/home/rasmus/.local/share/icons/emms.png"))'

Last edited by Malkymder (2015-05-28 13:16:06)

Offline

#5 2015-05-28 13:28:41

Pank
Member
From: IT
Registered: 2009-06-13
Posts: 371

Re: [Solved] Gnome-Shell and separating programs in the program switcher

Indeed chaining the wm_class works.

I think why it doesn't work with x-resource-class is because it retains /Emacs/ in its wm_class, so WM_CLASS = "EMMS", "Emacs".  It further seems as if GS is trying to minimize the number groups in the program switcher.

Do you know which property determines the name for a group in the program switcher?   When I change the wm_class with xprop, only the icon is shown, but no name.  The name EMMS is shown when I click Alt [key above tab].

Thanks,


Arch x64 on Thinkpad X200s/W530

Offline

#6 2015-05-28 14:19:49

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

Re: [Solved] Gnome-Shell and separating programs in the program switcher

Offline

#7 2015-05-28 14:35:36

Pank
Member
From: IT
Registered: 2009-06-13
Posts: 371

Re: [Solved] Gnome-Shell and separating programs in the program switcher

Thanks.  Now, I'm calling (p-wm_class "EMMS") from my emms.desktop file now.  There's also text under the icon now.  Thanks a lot

Here's the defun:

(defun p-wm_class (&optional new-class)
  "Return the WM_CLASS for the current window name.
If NEW-CLASS is a string or list of strings, set a new WM_CLASS.
If NEW-CLASS is non-nil remove Emacs from WM_CLASS and 
WM_CLASS has more than one value."
  (let ((old-class
         (with-temp-buffer
           (save-excursion
             (call-process-shell-command
              (format "xprop -name %s -f WM_CLASS 8s"
                      x-resource-class)
              nil t))
           (when (search-forward "WM_CLASS" nil t)
             (search-forward "=" (line-end-position))
             (split-string-and-unquote
              (buffer-substring (point)
                                (line-end-position))
              "[ \t,]"))))
        ;; anyway don't know how to set more than one value...
        (new-class-string (cond ((and (listp new-class)
                                      (cl-every 'stringp new-class))
                                 (mapconcat 'identity
                                            new-class ", "))
                                ((stringp new-class)
                                 new-class))))
    (or
     (cond ((stringp new-class)
            (call-process-shell-command
             (format "xprop -name %s -f WM_CLASS 8s -set WM_CLASS \"%s\""
                     x-resource-class
                     new-class))
            new-class)
           ((and new-class (member-ignore-case "Emacs" old-class))
            (call-process-shell-command
             (format "xprop -name %s -f WM_CLASS 8s -set WM_CLASS \"%s\""
                     x-resource-class
                     (car (delete "emacs" (delete "Emacs" old-class)))))
            (car (delete "emacs" (delete "Emacs" old-class)))))
        old-class)))

Arch x64 on Thinkpad X200s/W530

Offline

#8 2015-05-28 14:52:56

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

Re: [Solved] Gnome-Shell and separating programs in the program switcher

Nice work big_smile

Offline

#9 2015-05-28 14:54:53

Pank
Member
From: IT
Registered: 2009-06-13
Posts: 371

Re: [Solved] Gnome-Shell and separating programs in the program switcher

Oh, I forgot to add the happy result:
zcIVfze.png

Very cool!  Thanks a lot for the hints Malkymder!  It has been on my wish list for a while.


Arch x64 on Thinkpad X200s/W530

Offline

#10 2018-06-05 06:12:52

memeplex
Member
Registered: 2008-11-10
Posts: 33

Re: [Solved] Gnome-Shell and separating programs in the program switcher

It's really much much simpler:

    emacsclient -F '((name . "MyClass"))' -c

Notice that:

    StartupWMClass: If specified, it is known that the application will map at least one window with the given string as its WM class or WM name hint (see the Startup Notification Protocol Specification for more details).

Last edited by memeplex (2018-06-05 06:14:23)

Offline

#11 2018-06-05 07:20:57

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,754

Re: [Solved] Gnome-Shell and separating programs in the program switcher

Thanks for sharing, however as the thread is 3 years old it's unlikely the OP still looks for yet another alternative.

Closing this now.

Offline

Board footer

Powered by FluxBB