Retrieve a Theme's name ?

Post your Gambas programming questions here.
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Retrieve a Theme's name ?

Post by BruceSteers »

Doctor Watson wrote: Tuesday 2nd March 2021 1:54pm I see that that there’s a lot of activity regarding my question. Thanks for that, but this surpasses my humble Gambas programming knowledge.
Steve, I tried the gsettings and they work fine but then, what can I do with it?
Bruce, I tried your Public Sub, but it didn’t give a result.
To make sure, I put a Label on a Form and then ran:

Public Sub Form_Open()
Dim sTheme As String
sTheme = "this should be replaced with the Theme's name"
Shell "dconf read /org/$XDG_SESSION_DESKTOP/desktop/interface/gtk-theme" To sTheme
Label1.Text = RTrim(sTheme)
If Label1.text = "" Then Label1.text = "Failed to read Theme name"
End


And the result was "Failed to read Theme name".
I also tried the other 2 dconf lines but again the results are empty strings.
So I think it’s better that I stay with something I can handle for the moment, unless someone finds a magic solution.
But perhaps in the future ………...
nothing is ever that easy ;)
the best one to use is $XDG_CURRENT_DESKTOP but it's upper case.
open a terminal and type "import" to see a list of available environment variables.

the expression ${XDG_CURRENT_DESKTOP,,} turns it into lower case but it is a "bash" instruction.
Gambas uses sh not bash by default. :?

so you need to set bash as the shell to use (a simple addition to the start of the code)

try this..
Public Sub Form_Open()

System.Shell = System,.Find("bash")

Dim sTheme As String
sTheme = "this should be replaced with the Theme's name"
Shell "dconf read /org/${XDG_CURRENT_DESKTOP,,}/desktop/interface/gtk-theme" To sTheme 
Label1.Text = RTrim(sTheme)
If Label1.text = "" Then Label1.text = "Failed to read Theme name"
End

If at first you don't succeed , try doing something differently.
BruceS
Doctor Watson
Posts: 84
Joined: Wednesday 22nd August 2018 7:55am

Re: Retrieve a Theme's name ?

Post by Doctor Watson »

Hi Bruce,
I added System.Shell = System,.Find("bash")
and got an error Unexpected ‘,’
Removed the offending naughty ‘,’ and it runs fine.
BUT … result is still an empty string.
Last edited by Doctor Watson on Wednesday 3rd March 2021 11:45am, edited 1 time in total.
Old african saying:
You eat an elephant one small bite at a time.
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

Re: Retrieve a Theme's name ?

Post by stevedee »

Doctor Watson wrote: Tuesday 2nd March 2021 1:54pm I see that that there’s a lot of activity regarding my question. Thanks for that, but this surpasses my humble Gambas programming knowledge.
Don't worry about it Doc, sometimes forum Threads/Topics take on a life of their own, even though the original poster may have moved on.
Steve, I tried the gsettings and they work fine but then, what can I do with it?
Well, probably not a lot. What you need is some universal way of determining the current selected theme on any Linux system. The gsettings commands may work on your system but they don't work on either my Peppermint or Lubuntu systems.

GSettings is a Linux system configuration interface which is supposed to work with back-end systems like dconf. But I really have very little understanding of how various Linux distributions use or work with these tools.
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Retrieve a Theme's name ?

Post by BruceSteers »

Right well I'm changing my reply to...

NO you cannot get the theme name easily.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
PJBlack
Posts: 184
Joined: Tuesday 9th June 2020 10:26pm
Location: Florstadt, Hessen, Germany

Re: Retrieve a Theme's name ?

Post by PJBlack »

im not really following that discussion ... but may this is helpfull?
Attachments
Demo.gambas.tar.gz
(1.13 KiB) Downloaded 259 times
Doctor Watson
Posts: 84
Joined: Wednesday 22nd August 2018 7:55am

Re: Retrieve a Theme's name ?

Post by Doctor Watson »

No, it doesn’t seem to be something straightforward, if even experienced gurus are left struggling with it .
Anyway, this goes way beyond my current programming capabilities.
I’m going to try to get my project running first, the embellishments can wait for the time being.
Bruce & Steve, many thanks for your time and effort.
PJBlack, I’ll have a look ASAP.
Old african saying:
You eat an elephant one small bite at a time.
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Retrieve a Theme's name ?

Post by BruceSteers »

Doctor Watson wrote: Thursday 4th March 2021 9:55am No, it doesn’t seem to be something straightforward, if even experienced gurus are left struggling with it .
Anyway, this goes way beyond my current programming capabilities.
I’m going to try to get my project running first, the embellishments can wait for the time being.
Bruce & Steve, many thanks for your time and effort.
PJBlack, I’ll have a look ASAP.
Like we tried to say dude , it's actually easier to make your own borders :)
there are so many different linux versions all running different ways, the main ones seem to keep to the standards but others do not and thus makes it impossible to get the info you want.

Steve: if you open the gambas system info page does it report the correct theme there?
I'm pretty sure even gambas gets it wrong in some cases.

On a lot of my systems gambas cannot seem to use the right icon theme. even if set gnome icon theme in my system settings and gambas settings, Fedora, Suse and others all do not display it.

But you can look at it this way , If Steve wants Peppermint that's a bit rubbish at following the standards then so be it, no standard borders for him ;)

there are various controls in the gb.gui.base component that are all hand written unlike the gb.form components that rely on the toolkit themes.

GridView for example ,
the gridview offers much more border configurability and should also hold more to your border settings despite the gui toolkit in use as it's hand made and not a toolkit control.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

Re: Retrieve a Theme's name ?

Post by stevedee »

BruceSteers wrote: Thursday 4th March 2021 5:41pm ...If Steve wants Peppermint that's a bit rubbish at following the standards then so be it, no standard borders for him ;)
...Jeux sans frontières
Steve: if you open the gambas system info page does it report the correct theme there?
[System]
Gambas=3.15.2
OperatingSystem=Linux
Kernel=5.4.0-66-generic
Architecture=x86_64
Distribution=Peppermint 10 Ten
Desktop=LXDE
Theme=gtk
Language=en_GB.UTF-8
Memory=15258M

[Libraries]
Cairo=libcairo.so.2.11510.0
Curl=libcurl.so.4.5.0
DBus=libdbus-1.so.3.19.4
GDK2=libgdk-x11-2.0.so.0.2400.32
GDK3=libgdk-3.so.0.2200.30
GStreamer=libgstreamer-1.0.so.0.1405.0
GTK+2=libgtk-x11-2.0.so.0.2400.32
GTK+3=libgtk-3.so.0.2200.30
OpenGL=libGL.so.1.0.0
Poppler=libpoppler.so.73.0.0
Poppler=libpoppler.so.90.0.0
QT4=libQtCore.so.4.8.7
QT5=libQt5Core.so.5.9.5
SDL=libSDL-1.2.so.0.11.4
SQLite=libsqlite3.so.0.8.6

[Environment]
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
DEFAULTS_PATH=/usr/share/gconf/Peppermint.default.path
DESKTOP_SESSION=Peppermint
DISPLAY=:0.0
GB_GUI=gb.qt5
GDMSESSION=Peppermint
GDM_LANG=en_GB
GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1
HOME=<home>
LANG=en_GB.UTF-8
LANGUAGE=en_GB.UTF-8
LC_ALL=en_GB.UTF-8
LOGNAME=<user>
MANDATORY_PATH=/usr/share/gconf/Peppermint.mandatory.path
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
PWD=<home>
QT_ACCESSIBILITY=1
QT_LOGGING_RULES=*.debug=false
QT_QPA_PLATFORMTHEME=gtk2
SHELL=/bin/bash
SHLVL=0
SSH_AGENT_PID=1143
SSH_AUTH_SOCK=/tmp/ssh-NTAk1Sfnxb0B/agent.1061
TZ=:/etc/localtime
USER=<user>
XAUTHORITY=<home>/.Xauthority
XDG_CONFIG_DIRS=/etc/xdg/peppermint:/etc/xdg
XDG_CONFIG_HOME=<home>/.config
XDG_CURRENT_DESKTOP=LXDE
XDG_DATA_DIRS=/etc/xdg/peppermint:/usr/local/share:/usr/share:/usr/share/gdm:/var/lib/menu-xdg
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/<user>
XDG_MENU_PREFIX=xfce-
XDG_RUNTIME_DIR=/run/user/1000
XDG_SEAT=seat0
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
XDG_SESSION_DESKTOP=Peppermint
XDG_SESSION_ID=c2
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
XDG_SESSION_TYPE=x11
XDG_VTNR=7
_LXSESSION_PID=1061
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Retrieve a Theme's name ?

Post by BruceSteers »

Steve wrote: [System]
Gambas=3.15.2
OperatingSystem=Linux
Kernel=5.4.0-66-generic
Architecture=x86_64
Distribution=Peppermint 10 Ten
Desktop=LXDE
Theme=gtk
Language=en_GB.UTF-8
Memory=15258M
See on mint for me...
Theme=clearlooks

There is no easy way.
If at first you don't succeed , try doing something differently.
BruceS
Post Reply