Retrieve a Theme's name ?

Post your Gambas programming questions here.
User avatar
BruceSteers
Posts: 441
Joined: Thursday 23rd July 2020 5:20pm

Re: Retrieve a Theme's name ?

Post by BruceSteers » Wednesday 03rd March 2021 3:04am

Doctor Watson wrote:
Tuesday 02nd 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

Wishing well
Bruce

If at first you don't succeed , try it differently.

Online
Doctor Watson
Posts: 32
Joined: Wednesday 22nd August 2018 7:55am

Re: Retrieve a Theme's name ?

Post by Doctor Watson » Wednesday 03rd March 2021 10:24am

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 03rd 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: 403
Joined: Monday 20th March 2017 6:06pm

Re: Retrieve a Theme's name ?

Post by stevedee » Wednesday 03rd March 2021 10:53am

Doctor Watson wrote:
Tuesday 02nd 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: 441
Joined: Thursday 23rd July 2020 5:20pm

Re: Retrieve a Theme's name ?

Post by BruceSteers » Wednesday 03rd March 2021 1:57pm

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

NO you cannot get the theme name easily.
Wishing well
Bruce

If at first you don't succeed , try it differently.

User avatar
PJBlack
Posts: 120
Joined: Tuesday 09th June 2020 10:26pm
Location: Florstadt, Hessen, Germany

Re: Retrieve a Theme's name ?

Post by PJBlack » Wednesday 03rd March 2021 8:01pm

im not really following that discussion ... but may this is helpfull?
Attachments
Demo.gambas.tar.gz
(1.13 KiB) Downloaded 23 times

Online
Doctor Watson
Posts: 32
Joined: Wednesday 22nd August 2018 7:55am

Re: Retrieve a Theme's name ?

Post by Doctor Watson » Thursday 04th 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.
Old african saying:
You eat an elephant one small bite at a time.

User avatar
BruceSteers
Posts: 441
Joined: Thursday 23rd July 2020 5:20pm

Re: Retrieve a Theme's name ?

Post by BruceSteers » Thursday 04th March 2021 5:41pm

Doctor Watson wrote:
Thursday 04th 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.
Wishing well
Bruce

If at first you don't succeed , try it differently.

User avatar
stevedee
Posts: 403
Joined: Monday 20th March 2017 6:06pm

Re: Retrieve a Theme's name ?

Post by stevedee » Thursday 04th March 2021 7:07pm

BruceSteers wrote:
Thursday 04th 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: 441
Joined: Thursday 23rd July 2020 5:20pm

Re: Retrieve a Theme's name ?

Post by BruceSteers » Thursday 04th March 2021 9:20pm

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.
Wishing well
Bruce

If at first you don't succeed , try it differently.

Post Reply