RedBearAK / toshy

Keymapper config to make Linux work like a 'Tosh!
https://toshy.app
GNU General Public License v3.0
375 stars 18 forks source link

(Question) How can I disable Toshy in another desktop environment #446

Open kidclone3 opened 2 days ago

kidclone3 commented 2 days ago

Hi, I am using Ubuntu 24.04.

I have installed both Gnome (default) and xfce4. Both can be run simultaneously by the same user.

How can I configure Toshy to be disabled in xfce4 while it runs normally on Gnome?

RedBearAK commented 2 days ago

@kidclone3

Both can be run simultaneously by the same user.

Exactly how does that work? Are you just running them in different TTYs, or running one in a windowed mode or something?

I've never really thought about how to disable Toshy in a specific desktop environment while leaving it active in other desktop environments. And unlike the keyboard type detection, the environment check only runs at startup, since the environment normally can't change. So to have the two running simultaneously presents a bit of a challenge.

It might be possible to kind of hack the current support for disabling Toshy when the Synergy log says the focus has left the host part of the screen, but it would have to be possible to somehow detect that the focus has moved to Xfce or back.

I'd really need to know more about how you are accomplishing the simultaneous usage of the two DEs.

This might not have a simple solution.

And, it's probably good to ask the question of why you feel the need for Toshy to be disabled in Xfce? How does it interfere with something while using Xfce? Oh, of course the method to get the window context would be different if you're using a Wayland session with GNOME, while Xfce is using X11. So there's lots of complication here, potentially.

It would probably be possible to whip up a custom function that could mimic the way Synergy logs the focus changes, which could be triggered by a custom keyboard shortcut. That could at least give a quick manual way to disable the keymapping without constantly stopping and restarting the keymapper service.

Anyway, more information is needed.

kidclone3 commented 1 day ago

I am using a Macbook Air M1 as my personal laptop. When I work from home, I will remote into my work PC. I use Ubuntu 24.04 at work, which has Gnome DE as the default desktop environment. I also set up remote desktop protocol for this PC. I found that Gnome is not actually well-suited for remote use, so I chose XFCE4 for its ease of use.

❯ cat ~/.xsession
xfce4-session

So when I disconnect from my PC (mostly due to timeout), the XFCE4 session is still active (I checked this using htop, and didn't pay much attention to it).

I use Control + left/right to switch desktops on my Mac, and sometimes it also gets stuck on my Ubuntu PC, as in issue #402. It doesn't bother me too much during remote sessions, and when things get really bad, I simply disable Toshy for convenience.

But that raised an idea for me about solving issue #402: Could two desktop environments running simultaneously be causing the problem? And if I could prevent Toshy from working in another desktop environment, could that solve the issue? I want to find a way to test this. That's why I'm asking here.

Sorry for the late reply.

RedBearAK commented 1 day ago

I'm still missing a lot of context here, and don't really understand what's happening on a technical level.

Is the MacBook still running macOS? Only the remote PC is running Linux and Toshy?

I don't really understand what this is doing, and where you're running it. Are you running this on the Ubuntu system, while still being logged into GNOME?

❯ cat ~/.xsession
xfce4-session

I use Control + left/right to switch desktops on my Mac, and sometimes it also gets stuck on my Ubuntu PC, as in issue https://github.com/RedBearAK/toshy/issues/402.

Ah, I thought the username seemed familiar. So this happens to you while remoting into the Linux PC. But I'm still not clear on exactly how you're remoting into the Linux PC.

As I said before, the environment is only checked once at startup of the keymapper, so I'm not sure how it would be possible to disable Toshy when you change the desktop environment in the middle of a login session. That's not normally how things work.

kidclone3 commented 1 day ago

Is the MacBook still running macOS? Only the remote PC is running Linux and Toshy? Yeah, my Macbook is running MacOS 14.7.1, and my Linux is running Ubuntu 24.04.1 LTS.

Toshy is the only application which running and affect to keymap. I am using ibus-bamboo but I don't think it made any affect here.

I don't really understand what this is doing, and where you're running it. Are you running this on the Ubuntu system, while still being logged into GNOME?

I barely shut down my PC, but just lock my screen. As far as I know, the GNOME session is still there and nothing change.

So this happens to you while remoting into the Linux PC. But I'm still not clear on exactly how you're remoting into the Linux PC.

I use xrdp service to create remote session on Linux. On my mac, I use "Windows App" (which former name is Microsoft remote desktop) because it is the only app support RDP and works perfectly.

Could two desktop environments running simultaneously be causing the problem?

The reason for this hypothesis due to the following:

  1. When Google Chrome is running on GNOME, I cannot open it in XFCE4 until I shut down all running instances. 2.So, I need to use another browser here, such as Firefox. However, when I use any website with an upload file function (HTML tag ), it fails to open any file manager in XFCE4 (but it opened in GNOME when I logged in the next day). I though it might be due to a conflict caused by using two file manager apps: Nemo and Nautilus (default). But it is not sound true to me.
RedBearAK commented 1 day ago

OK, so you're remoting in to the Linux machine with RDP. But you skipped over a critical part. Are you just running those commands in a terminal while still in the GNOME session, thus creating an Xfce session running on top of the GNOME session?

If so, restarting Toshy at that point might cause it to at least be able to know that the active session on the screen is an Xfce session. However I'm still not clear on why you wouldn't want to just disable Toshy when you are remoting in. It sounds like you want Toshy to be active when you are sitting at the PC and using GNOME, but not active when you are remoting in and using Xfce?

Sorry if I'm not quite understanding what you're trying to achieve. This simultaneous login sessions thing is not something I've ever imagined dealing with.

kidclone3 commented 5 hours ago

OK, so you're remoting in to the Linux machine with RDP. But you skipped over a critical part. Are you just running those commands in a terminal while still in the GNOME session, thus creating an Xfce session running on top of the GNOME session?

I follow this instruction, so I think it is not running on top of Gnome like you said.

It sounds like you want Toshy to be active when you are sitting at the PC and using GNOME, but not active when you are remoting in and using Xfce?

Yeah, that's what I want to try right now.

RedBearAK commented 4 hours ago

The link contains instructions for installing Xfce only because the instructions were written for Ubuntu Server, which normally doesn't have a graphical desktop environment installed by default.

I'm not really sure what to tell you besides just manually stopping the Toshy services when you remote in, or when you leave the office, and start the Toshy services when you return to the office. If you can't see the Toshy tray icon you can try running the "Toshy Tray Icon" app from your app launcher, to make it easier to control the services.

Otherwise, a terminal can let you run the equivalent commands:

toshy-services-stop
toshy-services-start

I can't think of an automatic way to do what you're intending.