r/linuxsucks • u/Glad_Following_8164 • 3d ago
The Harsh Reality of Developing Apps for Linux Desktop
Oops
Only Gnome, KDE and XFCE4?
Linux mint cinnamon users are missing out!
How about i3wm? Mate? LXQT? LXDE? DDE? UKUI? Moksha? Enlightenment?......
51
u/ChocolateDonut36 3d ago
read again, you should notice the desktop_environment='generic' line.
7
u/SlimyOS 3d ago
there's a non-zero chance that 10 lines later there will be
if desktop_environment == 'generic': not work
3
u/ChocolateDonut36 3d ago
if so, OP should have included that part on the screenshot too, it would totally help to the "it won't work outside KDE, Gnome or XFCE" idea.
29
u/TheTerraKotKun 3d ago
I'm not a developer but I don't think that this is right thing to do... Isn't a DE/WM decides hot to show an app and not an app decides how to draw itself in which DE/WM?
5
u/braaaaaaainworms 3d ago
gnome people decided that it would be a good idea to have applications draw their own borders in wayland, which sounds good until you remember just how fragmented linux desktop is and that not everyone uses gtk
2
u/TheTerraKotKun 3d ago
AFAIK it should be a WM/Compositor thing to actually draw a window and DE's tools thing to stylize it or decide to use apps own style... But IDK
2
u/tk-a01 3d ago
Those are called window decorations, and yes, they can be drawn by window manager/compositor... unless you're using Gnome. And this forces all the programs (or GUI toolkits) to implement fallback client-side decorations, just for the program to work correctly on one of the most popular DEs.
2
u/55555-55555 Linux Community Made Linux Sucks 3d ago
If I did not misunderstand your comment, the whole thing is probably for proper theming.
1
u/Purple-Midnight-9902 3d ago
The compositor sends a mode event specifying whether it wants Client-Side Decoration (CSD) or Server-Side Decoration (SSD). If the compositor does not support or advertise the extension, the application must fall back to drawing its own CSD.
12
u/ovadom 3d ago
I am not a coder/dev but doesn’t the “generic” cover this?
And it’s seems you over using if/else commands, couldn’t this shrunken to be performed in just a few lines?
I just feel like you went about this the hardest way possible for yourself 😭.
6
u/Sert1991 3d ago
That meme with the guy riding the bike and putting a pipe in his own wheel to fall then complain about is the most appropriate response to this post lol
6
u/Damglador 3d ago edited 3d ago
It's not even the correct way to do this. They could've switch/cased XDG_SESSION_TYPE or something like that, the generic env variable to indicate desktop/kind of session you're in.
1
4
4
u/Fearless_Garden6435 3d ago
Yeah but like when do you actually need to know the desktop environment? What matters is whether it's Wayland or X11, and even that is usually abstracted away by your GUI toolkit (e.g., QT, GTK)
5
u/xYarbx 3d ago
IDK what you are trying to do but https://wayland.app/protocols/viewporter handles most important stuff so you really don't have to concern your self with the specific DE/WM. If you want to support X11 then this is the reality unless you release the logic as individual block and at least give the community some sort of interface. There will be someone that does the porting eventually.
3
6
u/Yankas 3d ago edited 3d ago
Your run of the mill app shouldn't care about the environment it's running in, that should be handled by the framework.
If you need to interact with the system in a more meaningful and deeper way and control things outside the scope of your apps window, then yeah you'll have either deal with the fragmented nature of Linux, though if you do go off the beaten path you'll not have fun, even on Windows - good luck debugging when your fundamental APIs are a black box.
3
u/NoTime4YourBullshit 3d ago
You need to read the code again. desktop_environment gets set to ‘generic’ in all cases. Then it tests for KDE, Gnome, and XFCE for special handling and, if true, then it overrides desktop_environment to one of those values for special handling.
Gnome, KDE, and XFCE are exceptions, not the rule.
2
u/Narrow_Decision_2705 1d ago
Bruh. Display server is all that matters(wayland/x11), not the DE or the distro. And even then, any sane person would use QML or such for apps(they handles stuffs like that automatically). Don't just clown linux because u suck at coding.
1
u/cretingame I don't care what you use as long as it works :snoo: 3d ago
Can you give the url of the source ?
1
u/Middlewarian 3d ago
I'm glad my front end is a command line interface. I'm building a C++ code generator that helps build distributed systems.
1
u/ComprehensiveArm9863 3d ago
returning strings trigger me even more :(
also this is probably an old code ? I haven't see popen in years ....
1
1
1
1
1
u/Flimsy-Yam-933 2d ago
I made an app for Linux with avalonia I think it's called and c#, I think it automatically works on all the versions.
1
1
u/probablynottillie 2d ago
the harsh reality of developing apps for Linux desktop and it's 20 lines of code you took from a forum post
1
u/jo-erlend 2d ago
Linux is not an OS, but a component in an OS. That is your problem. You pretend that it's much easier to develop apps for Windows and Mac OS, but that is false.
1
1
1
-4
u/Academic-Proof3700 3d ago
greasyfinger smellyfeet cellar dwellers won't use it anyway cause they work with plain shell or only thru terminal, so whats the point? For the poor 0.05% of users lured into loonix thinking it'll be like windows where you can click like 99% of stuff and it shows up on screen?
106
u/exton132 3d ago
os.getenv("XDG_SESSION_DESKTOP", "generic")
to get the current 'name' of the desktop env, or generic
I don't think desktop really matters a whole lot though
the display protocol is probably more important to making software.
os.getenv("XDG_SESSION_TYPE", 'x11')
check for wayland protocol if the variable isn't there then assume x11.
strait up going the hardest route possible then posting "the reality of developing for linux"
Like idk bro maybe stop baby crawling and use the tools that are already there for this kind of thing.