WebDeck icon indicating copy to clipboard operation
WebDeck copied to clipboard

Porting to Linux (and MacOS) Progress Tracker

Open OWL4C opened this issue 1 year ago • 5 comments

I found this program today and started to port it to Linux (and by extension, MacOS should be relatively easy to add on afterwards, if libraries exist). Here i want to track my progress, mark issues and basically make it easier for others to follow.

After commenting out all windows specific apis and imports, as well as installing portaudio19-dev (Debian based Linux Systems, for others please consult your maintainers page for the portaudio package), it starts and works (i.e. the WebUI opens and buttons do things).

Current Issues: All Windows specific features are broken. This includes

  • Window Actions (Find Window, Raise/Lower/Minimize,...): These are based on the win32api. There is a crossplatform library pywinctl which should serve our needs. I have already started on this, but as far as i can see the only button to use these is "Restart Explorer" and maybe open some window/file thing i haven't fully traced yet. [Tangent: there should be a "focus window" button anyway, so maybe this can be implemented too]
  • Audio Recording / Playback. The used lib already supports cross platform audio, and in fact you can correctly choose audio devices for in / out. These do not work correctly though, and next to the real hw devices you can also choose pipewire/pulse, so there is some cleaning up to do.
  • Audio Devices. Haven't looked to much into this, but basically everything using pycaw needs to be reworked. There is both an ALSA and pulseaudio api i have found already, but no pipewire/jack (should exist though). These are all to actually change the interfaces (mute, set in / out) etc as opposed to play / rec audio.
  • Connected to that is a whole lot of code customised to VB Cable, which doesn't have a linux alternative, especially since you can easily use Pipewire + Helvum (or any other Pipewire Patchbay) + Easy Effects to get most features (custom configs for all others i think) on Linux. This means depending on how it is used different ports have to be used.

MacOS: Pywinctl has support for MacOS, but it is more limited (high latency, not much functionality). There may be better options, but since right now there doesn't seem to be much use for Window Actions besides Explorer, it might be easier to just skip this. Audio is probably similar, since MacOS is already very locked down towards HW Access / Volume Mixing etc. Soundflower is an open source app that might be required for feature parity. I currently have no plan on actually implementing any MacOS Fixes, but i'll try to make any OS specific fix fail safely so you can still use the other parts.

VLC and OBS have linux compatible libraries, but there are multiple and i haven't tested functionality yet. This might of course be impacted by the many different Linux Packaging Formats, and Snaps/Flatpaks might prove especially difficult. OBS uses Websockets though so it should be possible to play nicely with flatpak.

Current Progress: Single Key Keyboard Input already works fine. Text needs root. Volume / Media / Soundboard / System is broken (based on win32). OBS / Spotify untested. Color Picker works but does not create a popup (possibly add a to clipboard function too). Stat Display works (even with GPU) but needs to be clicked in order to update. Storage Display recognizes linux disks, but cannot get information.

In the following gist is the pip requirements i used to get it running. For some reason, the provided requirements.txt eroored on install, (i removed pywin32, but another windows specific package, that doesn't seem to be in the txt, tries to install and fail). These might not be the only required packages, but at least the application starts now; conversely there might be multiple redundant packages (for example obs related ones), or packages unimportant. This is merely a pip list --format=freeze of my venv.

OWL4C avatar Oct 28 '24 20:10 OWL4C

Hey :)

Maybe you should have asked me before you started all this work, but it's awesome that you were able to pull this off so quickly, so whatever. I spent a few weeks restructuring the entire application precisely to make contributions easier, but more particularly the Linux port.

I’d like to suggest adding your work to the repository in a separate branch, such as feature/linux-port for example, to keep the Linux-specific work separate. We can maintain the primary Windows-compatible code on master. This should make it easier for both of us (and future contributors) to follow the changes and merge once it's stable.

Additionally, I think it would be beneficial for us to communicate more easily. I’d like to add you on Discord so we can discuss the porting process directly and collaborate more effectively. There’s also another developer who offered help with the Linux port yesterday, and it could be useful to have all of us connected.

Looking forward to collaborating!

Lenochxd avatar Oct 28 '24 21:10 Lenochxd

I’ve merged your code into a new branch named linux-compatibility (co-authored with you). 64d0334 Thanks for your contributions! This branch will serve as the basis for Linux support while keeping the Windows functionality intact on master.

I didn’t merge the OBS-related changes yet. I need to verify whether they’ve already been addressed with commit ccef22492acca7130efa9f5235d22b8847692ff5 but I’m having trouble enabling OBS WebSockets on my system (Arch Linux), as the setting doesn’t appear in the OBS configuration.

Some updates on the application’s progress:

  • Xorg and Headless Mode: The app can now start in an Xorg environment or even without a GUI (echo $DISPLAY returns None). It should also work on Wayland, though I still need to test that. If it doesn’t, the --no-tray argument should resolve some issues.
  • Tray Icon: I’ve fixed the tray icon for Xorg environments (ed3663f).
  • Tkinter Stability: Linux-related crashes with tkinter windows have been resolved (a8d00ec, 0b744f6).

Next, we’ll need to work on making the button functionality fully compatible across platforms. I started creating a markdown table to track the progress of button implementation and ensure we stay organized. Let me know if you have any questions or further suggestions!

Lenochxd avatar Dec 12 '24 18:12 Lenochxd

Here is the table to track the progress of Linux compatibility for the buttons and their functionality:

Category Command Not Supported Planned In Progress Partially Supported Fully Supported Comment
Webdeck /fullscreen [x]
Webdeck /reload [x]
Webdeck /folder [x]
Webdeck /open-config [x]
Display /usage [x] 1. I can't test the GPU.
~~2. Disk needs to be reworked~~ 33608c68f0206f130ae5b283af2cc10c75d15d95
System /volume set [x] b39333a
System /volume + [x] b39333a
System /volume - [x] b39333a
System /volume mute [x] ~~Should work, but it does not~~ 9c27d47, 83ac777 ~~(sudo only)~~ e765676
System /mediacontrol playpause [x] ~~Should work, but it does not~~ 27051fd ~~(sudo only)~~ e765676
System /mediacontrol previous [x] ~~Should work, but it does not~~ 980bf2b ~~(sudo only)~~ e765676
System /mediacontrol next [x] ~~Should work, but it does not~~ 980bf2b ~~(sudo only)~~ e765676
System /start [x] ~~module 'os' has no attribute 'startfile'~~ fb01876
System /openfolder [x] ~~Default function just uses explorer {path} and that's why it does not work~~ 9490014
System /locksession [x] 20acd87
System /PCshutdown [x] 77d0d68
System /PCrestart [x] 77d0d68
System /PCsleep [x] 77d0d68
System /PChibernate [x] 77d0d68
System /screensaver [x] 08109ec
System /screensaversettings [x]
System /restartexplorer [x]
System /superAltF4 [x] 05e929c (requires xdotool)
System /forceclose [x] a3f14e8
System /restart [x] b7decdf
System /exec [x]
System /batch [x]
Text /key [x]
Text /write [x] 7f61290
Text /writeandsend [x] 7f61290
Text /speechrecognition [x]
Text /copy [x]
Text /paste [x]
Text /cut [x]
Text /clipboard [x] f7e16b6 (requires copyq, gpaste-client, clipman, parcellite, xfce4-clipman, klipper or diodon, or performs Win+V so it depends on the user's shortcut configuration)
Text /clearclipboard [x] a422090 (requires xclip, xsel or wl-clipboard)
Utilities /colorpicker [x] ~~Needs working notifications~~ 86bd2cb (requires notify-send)
Soundboard /playsound [x]
Soundboard /stop_soundboard [x]
OBS Studio /obs_key [x]
OBS Studio /obs_scene [x]
OBS Studio /obs_toggle_rec [x]
OBS Studio /obs_start_rec [x]
OBS Studio /obs_stop_rec [x]
OBS Studio /obs_toggle_rec_pause [x]
OBS Studio /obs_pause_rec [x]
OBS Studio /obs_resume_rec [x]
OBS Studio /obs_toggle_stream [x]
OBS Studio /obs_start_stream [x]
OBS Studio /obs_stop_stream [x]
OBS Studio /obs_toggle_virtualcam [x]
OBS Studio /obs_start_virtualcam [x]
OBS Studio /obs_stop_virtualcam [x]
Spotify /spotify volume + [x]
Spotify /spotify volume - [x]
Spotify /spotify volume set [x]
Spotify /spotify playsong [x]
Spotify /spotify playplaylist [x]
Spotify /spotify likesong [x]
Spotify /spotify likealbum [x]
Spotify /spotify add_or_remove [x]
Spotify /spotify add_to_playlist [x]
Spotify /spotify remove_from_playlist [x]
Spotify /spotify follow_or_unfollow_artist [x]
Spotify /spotify follow_artist [x]
Spotify /spotify unfollow_artist [x]

Lenochxd avatar Dec 12 '24 22:12 Lenochxd

Hey, i tried to compile this, and first i had to specifically create a venv with Python 3.11, as distutils got dropped in 3.12, then i also had to install the dev package of cx_freeze because it otherwise wouldn't be able compile.

The weirdest things was that i had to symlink some libraries like liblzma or libxau.

The last and most important thing i would like to note is, that you shouldn't be dependant on xdotool, as most users will be using Wayland in the future, and this makes the server crash on my Arch KDE Plasma Wayland session.

  File "/home/<user>/Dokumente/Repositories/WebDeck/app/utils/get_process_path.py", line 20, in <module>
    xdotool = get_process_path("xdotool")
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/<user>/Dokumente/Repositories/WebDeck/app/utils/get_process_path.py", line 17, in get_process_path
    raise NotImplementedError("This function is not implemented for this platform")
NotImplementedError: This function is not implemented for this platform

Some alternative would be ydotool.

PS: ydotool should also work on x!

AroPix avatar Feb 11 '25 20:02 AroPix

Hey, I didn't have these problems with libraries like liblzma or libxau, I recently created a VM to work on the linux port and I don't remember having to do anything with these dependencies

I didn't know xdotool didn't work on wayland, I'll try ydotool, thanks for the suggestion :)

Also, NotImplementedError is raised if "/lib/{process_name}" exists, the message is not clear I must have made a mistake here

Lenochxd avatar Feb 11 '25 20:02 Lenochxd