Open gusbemacbe opened 5 years ago
Sorry "does not work" is not a useful description. Please describe exactly what output + result you are expecting and exactly what output + result you get.
Observe that the window title in the panel:
I wanted to replace Qemu-system-x86_64
for macOS Mojave
, like you see in the StartupWMClass = mojave
, which is detected by Exec
that intercepted the option -c <WM_CLASS>
.
So I saw that your project offers the option of setting WM_CLASS
name by middle of applying -c <WM_CLASS>
.
References:
Read the opening paragraph of the README here. This little script just checks if you already have a window open for that app + file, else it opens a new window. Is that what you are trying to do?
Yes, I have read the whole README. Yes, it is. The desktop file's window manager title still holds the Qemu-x86_64
.
If I change to StartupWMClass = Qemu-x86_64
, it will work and the desktop file window manager title will appear normally as "macOS Mojave", but I have other Qemu virtual machines with different desktop files that will appear with the same name of "macOS Mojave" because they belong to the same app whose original WM_CLASS is same.
I tested, using your project for different desktop files of same app with different shell scripts, different names and different StartupWMClass, but I did not get.
What does "but I did not get" mean at the end of that last sentence?
It meant that the option -c
did not replace the WM_CLASS
name in the command Exec
, with or without the original or modified StartupWMClass.
I think because my file is a shell script file.
If you do not understand yet due to my language barrier, I will explain what I will do, with input, output, result and expected.
Qemu-system-x86_64
. The command line of the app is qemu-system-x86_64
.qemu-macos-mojave.sh
and qemu-macos--catalina.sh
in the folder called VMs, following the sample and simple codes:The file qemu-macos-mojave.sh
:
#!/bin/bash
qemu-system-x86_64 \
-enable-kvm \
-m 512 \
-device virtio-vga,virgl=on
-display sdl,gl=on \
-netdev user,id=ethernet.0,hostfwd=tcp::10022-:22
-device rtl8139,netdev=ethernet.0 \
-soundhw ac97 \
-device ich9-ahci,id=sata \
-drive id=ESP,if=none,format=qcow2,file=ESP.qcow2 \
-device ide-hd,bus=sata.2,drive=ESP \
-drive id=SystemDisk,if=none,file=mojave.qcow2 \
-device ide-hd,bus=sata.4,drive=SystemDisk \
The file qemu-macos-catalina.sh
:
#!/bin/bash
qemu-system-x86_64 \
-enable-kvm \
-m 512 \
-device virtio-vga,virgl=on
-display sdl,gl=on \
-netdev user,id=ethernet.0,hostfwd=tcp::10022-:22
-device rtl8139,netdev=ethernet.0 \
-soundhw ac97 \
-device ich9-ahci,id=sata \
-drive id=ESP,if=none,format=qcow2,file=ESP.qcow2 \
-device ide-hd,bus=sata.2,drive=ESP \
-drive id=SystemDisk,if=none,file=catalina.qcow2 \
-device ide-hd,bus=sata.4,drive=SystemDisk \
/usr/bin/qemu-macos-mojave
and to /usr/bin/qemu-macos-catalina
.qemu-macos-mojave.desktop
and qemu-macos-catalina.desktop
. Pay attention to the Name
and StartupWMCLass
. The file qemu-macos-mojave.desktop
:
[Desktop Entry]
Categories = OperatingSystem; OS; System; VirtualMachine;
Comment = Run and open the virtual machine of macOS Mojave with QEMU
Exec=bash -c 'cd "$HOME/VMs" && qemu-macos-mojave'
GenericName = Virtual Machine
Icon = qemu
Name = macOS Mojave
StartupNotify = false
StartupWMClass = Qemu-system-x86_64
Terminal = false
Type = Application
Version = 1.1
The file qemu-macos-catalina.desktop
:
[Desktop Entry]
Categories = OperatingSystem; OS; System; VirtualMachine;
Comment = Run and open the virtual machine of macOS Catalina with QEMU
Exec=bash -c 'cd "$HOME/VMs" && qemu-macos-catalina'
GenericName = Virtual Machine
Icon = qemu
Name = macOS Catalina
StartupNotify = false
StartupWMClass = Qemu-system-x86_64
Terminal = false
Type = Application
Version = 1.1
Only the desktop file qemu-macos-mojave.desktop
worked, because its WM_CLASS
appeared as macOS Mojave
instead of Qemu-system-x86_64
. Perfect! But the another file, qemu-macos-catalina.desktop
, did not work, because its WM_CLASS
also appeared as macOS Mojave
instead of macOS Catalina
because both files share the same original StartupWMClass
.
qemu-macos-mojave.desktop
's WM_CLASS
should be macOS Mojave in the window manager title at the panel.qemu-macos-catalina.desktop
's WM_CLASS
should be macOS Catalina in the window manager title at the panel.I open the desktop files qemu-macos-mojave.desktop
and qemu-macos-catalina.desktop
. Pay attention to the Exec
(notice the option -c
), Name
and StartupWMCLass
.
qemu-macos-mojave.desktop
, I replaced:
Exec=bash -c 'cd "$HOME/VMs" && qemu-macos-mojave'
for Exec=bash -c 'cd "$HOME/VMs" && /usr/bin/raise-or-run -c mojave qemu-macos-mojave'
;StartupWMClass = Qemu-system-x86_64
for StartupWMClass = mojave
;qemu-macos-catalina.desktop
, I replaced:
Exec=bash -c 'cd "$HOME/VMs" && qemu-macos-catalina'
for Exec=bash -c 'cd "$HOME/VMs" && /usr/bin/raise-or-run -c catalina qemu-macos-catalina'
;StartupWMClass = Qemu-system-x86_64
for StartupWMClass = catalina
;The same problems continue as in the previous result. The -c
really did not replace the WM_CLASS
, and the windows still continued as Qemu-system-x86_64
. Maybe your project does not detect the StartupWMClass string if the -c
is equal.
qemu-macos-mojave.desktop
, if your project detects that -c mojave
and StartupWMClass = mojave
are equal, it will replace the Qemu-system-x86_64
(WM_CLASS string) for macOS Mojave
(Name
string).qemu-macos-catalina.desktop
, if your project detects that -c catalina
and StartupWMClass = catalina
are equal, it will replace the Qemu-system-x86_64
(WM_CLASS string) for macOS CatalinaMojave
(Name
string).Did you understand this whole explanation?
You say "The -c really did not replace the WM_CLASS". Are you expecting that raise-or-run
changes something to do with your app etc? This utility is trivial. It merely looks to see if a window is already open with the class you specify + file name. Runwctrl -lx
yourself to see what the script looks at. That is all the script uses in it's tiny lines of logic.
BTW, completely separate unrelated issue but as a matter of style you really should not be creating symlinks in /usr/bin
(i.e as root) for the above. Get rid of those because everything else you are doing above is created and run as your normal user. Just change the exec line to
Exec=bash -c 'cd "$HOME/VMs" && ./qemu-macos-mojave.sh'
Are you expecting that raise-or-run changes something to do with your app etc? This utility is trivial. It merely looks to see if a window is already open with the class you specify + file name. Runwctrl -lx yourself to see what the script looks at. That is all the script uses in it's tiny lines of logic.
Yes, all this is what I wanted.
Hello!
.sh
) to run QEMU, opening a specific virtual machine. The originalWM_CLASS
of Qemu isQemu-system-x86
./usr/bin/qemu-macos-mojave
.qemu-macos-mojave.desktop
, setting-c
following: