Skip to content

Commit

Permalink
Code refinements and added budgie support
Browse files Browse the repository at this point in the history
  • Loading branch information
imhemish committed May 3, 2021
1 parent a20ab2c commit be36297
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 16 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Desktop Linux Themer is intended to be used by beginners on Linux to theme their
# Installation
The following steps should be followed for downloading:
- Make sure that you are using a desktop environment listed here:
GNOME, XFCE, Cinnamon
If you are on vanilla Ubuntu, Xubuntu, Linux Mint Cinnamon, Linux Mint XFCE, Zorin OS, Zorin OS Lite, vanilla Fedora, Fedora XFCE spin, Fedora Cinnamon spin, vanilla RHEL, Manjaro XFCE, Manjaro GNOME, Manjaro Cinnamon or any other distro using this desktop environment, you are good to go.
GNOME, XFCE, Cinnamon, Budgie
If you are on vanilla Ubuntu, Ubuntu-Budgie, Xubuntu, Linux Mint Cinnamon, Linux Mint XFCE, Zorin OS, Zorin OS Lite, vanilla Fedora, Fedora XFCE spin, Fedora Cinnamon spin, vanilla RHEL, Manjaro XFCE, Manjaro GNOME, Manjaro Cinnamon, Manjaro Budgie or any other distro using this desktop environment, you are good to go.
- Make sure that you have Python 3 installed on your system. (Most GNU/Linux distros have python3 preinstalled.)
To check if it is installed or not, simply open Terminal and type "python3" (without quotes) and press Enter. If you see a message that the command was not found or something wrong happened, it means that if you don't have Python3 installed. If you see something like this:
```bash
Expand All @@ -22,13 +22,14 @@ If on Ubuntu or Debian or distros based on these two: open terminal and type "su
If on Fedora or Red Hat Enterprise Linux or distros based on these: open terminal and type "sudo dnf install tk tcl python3-tk python3-pip -y" (without quotes) and press enter and put in your account password and wait for the installation to complete.
If on Arch Linux or Manjaro or Garuda or distros based on Arch: open terminal and type "sudo pacman -S tk tcl python3-tk python3-pip -y" (without quotes) and press enter and put in your account password and wait for the installation to complete.
- Then in terminal, (for all distros) type "sudo pip install pysimplegui" (without quotes) and type in your account password and wait for the installation to complete.
- Download the latest installer script from release page: https://github.com/hemish04082005/desktop_linux_themer/releases/ and open terminal and navigate to folder containing the downloaded script using "cd" command and then type "sudo ./installer.sh" (without quotes) and put in your account password and wait for the installation to succeeed. Finally, you have installed it!
- Additional step for GNOME users: Make sure that user-theme extension is installed through https://extensions.gnome.org/extension/19/user-themes/ and enabled too.
- Download the latest installer script by clicking this link: https://github.com/hemish04082005/desktop_linux_themer/releases/latest/download/installer.sh and open terminal and navigate to folder containing the downloaded script using "cd" command and then type "sudo ./installer.sh" (without quotes). If you get an error claiming "Command not found", type this in terminal "chmod +x installer.sh" (without quotest). Then, put in your account password and wait for the installation to succeeed. Finally, you have installed it!
- Additional step for GNOME and Budgie users: Make sure that user-theme extension is installed through https://extensions.gnome.org/extension/19/user-themes/ and enabled too.

# Usage:
Use applications menu/whisker menu/start menu/gnome app drawer or anything like start menu on your desktop and search for "Desktop Linux Themer" and launch the application.
Then use it to switch GTK, Window Manager, Desktop, Icons, Cursors theme through drop down menus and buttons provided.

# To do:
- add lxde desktop support
- provide mechanism for downloading and installing popular themes within the application
- make installation simple
2 changes: 1 addition & 1 deletion desktop_linux_themer/desktop_linux_themer.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Version=1.1
Type=Application
Name=Desktop Linux Themer
Comment=Theme GNOME, Cinnamon and XFCE
Comment=Theme GNOME, Cinnamon, Budgie and XFCE
Icon=preferences-desktop-theme
Exec=/usr/bin/env python3 /usr/bin/desktop_linux_themer.py
Actions=
Expand Down
2 changes: 2 additions & 0 deletions desktop_linux_themer/desktop_linux_themer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
]
if themerobj.memCurrentSession in themerobj.XFCEsessions: # Beacuse we dont have desktop themes in xfce, xfce interface is guided by gtk.
Layout.pop(3)
if themerobj.memCurrentSession in themerobj.GNOMEsessions or themerobj.memCurrentSession in themerobj.BudgieSessions: # Budgie and GNOME don't respect window manager theme and rely on GTK for window manager
Layout.pop(2)
Window = sg.Window("Linux Themer", Layout)
while True:
event, values = Window.read()
Expand Down
50 changes: 39 additions & 11 deletions desktop_linux_themer/lib_desktop_linux_themer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ def sanitiseString(suppliedArg):
return temp

# To do:
# chech gnome user themes extension and enable it
# check gnome user themes extension and enable it
# if the user is root, then instead of /root use /usr/share/themes and usr/share/icons
# Add support for lxde

class themer(object):

Expand All @@ -32,9 +33,10 @@ class themer(object):
XFCEsessions = ["Xubuntu", "XFCE", "xfce", "Xfce"]
GNOMEsessions = ["Ubuntu", "Ubuntu on Wayland", "Ubuntu on Xorg", "GNOME", "GNOME on Wayland", "GNOME on Xorg", "gnome", "Gnome"]
CinnamonSessions = ["Cinnamon", "Cinnnamon (Software Rendering)", "cinnamon", "CINNAMON", "X-Cinnamon"]
BudgieSessions = ["Budgie", "Budgie:GNOME"]

def confPath(self, arg):
return str(os.path.join(self.confPathRoot, (arg+".conf")))
# def confPath(self, arg):
# return str(os.path.join(self.confPathRoot, (arg+".conf")))

@staticmethod
def createDirIfNotExists(path):
Expand Down Expand Up @@ -107,7 +109,7 @@ def checkXfceCompatibility(self, path): # Xfce compatibility means xfwm themes
def checkGtkCompatibility(self, path):
return self.checkThemeCompatibility(path)["gtk"]

def checkMetacityCompatibility(self, path): # metacity is primarily for gnome and cinnamon
def checkMetacityCompatibility(self, path): # metacity is primarily for cinnamon
return self.checkThemeCompatibility(path)["metacity"]

def update(self):
Expand Down Expand Up @@ -152,7 +154,7 @@ def update(self):
if value in anothertemplist:
self.WMthemes[key] = str(value)

if self.memCurrentSession in self.CinnamonSessions or self.memCurrentSession in self.GNOMEsessions:
if self.memCurrentSession in self.CinnamonSessions:
templist = list(self.memThemes.values())
anothertemplist = list(filter(self.checkMetacityCompatibility, templist))
for key, value in self.memThemes.items():
Expand All @@ -173,6 +175,12 @@ def update(self):
for key, value in self.memThemes.items():
if value in anothertemplist:
self.desktopThemes[key] = str(value)
if self.memCurrentSession in self.BudgieSessions: # Budgie's themeing works the same as GNOME
templist = list(self.memThemes.values())
anothertemplist = list(filter(self.checkGnomeCompatibility, templist))
for key, value in self.memThemes.items():
if value in anothertemplist:
self.desktopThemes[key] = str(value)
# ---------------------------

# ----- Icons --------
Expand All @@ -197,6 +205,8 @@ def getCurrentIconTheme(self):
self.update()
if (self.memCurrentSession in self.GNOMEsessions) == True:
tempTheme = os.popen("gsettings get org.gnome.desktop.interface icon-theme").readline().rstrip()
elif (self.memCurrentSession in self.BudgieSessions) == True: # same as gnome
tempTheme = os.popen("gsettings get org.gnome.desktop.interface icon-theme").readline().rstrip()
elif (self.memCurrentSession in self.XFCEsessions) == True:
tempTheme = str(os.popen("xfconf-query -lvc xsettings -p /Net/IconThemeName").readline().rstrip()).split("Name ")[1]
elif (self.memCurrentSession in self.CinnamonSessions) == True:
Expand All @@ -209,6 +219,8 @@ def getCurrentGtkTheme(self):
self.update()
if (self.memCurrentSession in self.GNOMEsessions) == True:
tempTheme = os.popen("gsettings get org.gnome.desktop.interface gtk-theme").readline().rstrip()
elif (self.memCurrentSession in self.BudgieSessions) == True:
tempTheme = os.popen("gsettings get org.gnome.desktop.interface gtk-theme").readline().rstrip() #same as gnome
elif (self.memCurrentSession in self.XFCEsessions) == True:
tempTheme = str(os.popen("xfconf-query -lvc xsettings -p /Net/ThemeName").readline().rstrip()).split("Name ")[1]
elif (self.memCurrentSession in self.CinnamonSessions) == True:
Expand All @@ -221,6 +233,8 @@ def getCurrentWMtheme(self):
self.update()
if (self.memCurrentSession in self.GNOMEsessions) == True:
tempTheme = os.popen("gsettings get org.gnome.desktop.wm.preferences theme").readline().rstrip()
elif (self.memCurrentSession in self.BudgieSessions) == True: # same as gnome
tempTheme = os.popen("gsettings get org.gnome.desktop.wm.preferences theme").readline().rstrip()
elif (self.memCurrentSession in self.XFCEsessions) == True:
tempTheme = str(os.popen("xfconf-query -lvc xfwm4 -p /general/theme").readline().rstrip()).split("/theme ")[1]
elif (self.memCurrentSession in self.CinnamonSessions) == True:
Expand All @@ -233,6 +247,8 @@ def getCurrentCursorTheme(self):
self.update()
if (self.memCurrentSession in self.GNOMEsessions) == True:
tempTheme = os.popen("gsettings get org.gnome.desktop.interface cursor-theme").readline().rstrip()
elif (self.memCurrentSession in self.BudgieSessions) == True: #same as gnome
tempTheme = os.popen("gsettings get org.gnome.desktop.interface cursor-theme").readline().rstrip()
elif (self.memCurrentSession in self.XFCEsessions) == True:
tempTheme = str(os.popen("xfconf-query -lvc xsettings -p /Gtk/CursorThemeName").readline().rstrip()).split("Name ")[1]
elif (self.memCurrentSession in self.CinnamonSessions) == True:
Expand All @@ -245,6 +261,8 @@ def getCurrentDesktopTheme(self):
self.update()
if (self.memCurrentSession in self.GNOMEsessions) == True:
tempTheme = os.popen("gsettings get org.gnome.shell.extensions.user-theme name").readline().rstrip()
elif (self.memCurrentSession in self.BudgieSessions) == True: # same as gnome
tempTheme = os.popen("gsettings get org.gnome.shell.extensions.user-theme name").readline().rstrip()
elif (self.memCurrentSession in self.XFCEsessions) == True:
return self.getCurrentGtkTheme() # XFCE does not have any desktop theme of its own and everything including panel depend on gtk theme
elif (self.memCurrentSession in self.CinnamonSessions) == True:
Expand All @@ -256,6 +274,8 @@ def getCurrentDesktopTheme(self):
def changeGtkTheme(self, suppliedArg):
if self.memCurrentSession in self.GNOMEsessions:
stream = os.popen("gsettings set org.gnome.desktop.interface gtk-theme '{}'".format(suppliedArg))
elif self.memCurrentSession in self.BudgieSessions: # same as gnome
stream = os.popen("gsettings set org.gnome.desktop.interface gtk-theme '{}'".format(suppliedArg))
elif self.memCurrentSession in self.XFCEsessions:
stream = os.popen("xfconf-query -c xsettings -p /Net/ThemeName -s '{}'".format(suppliedArg))
elif self.memCurrentSession in self.CinnamonSessions:
Expand All @@ -267,6 +287,8 @@ def changeGtkTheme(self, suppliedArg):
def changeIconTheme(self, suppliedArg):
if self.memCurrentSession in self.GNOMEsessions:
stream = os.popen("gsettings set org.gnome.desktop.interface icon-theme '{}'".format(suppliedArg))
elif self.memCurrentSession in self.BudgieSessions: # same as gnome
stream = os.popen("gsettings set org.gnome.desktop.interface icon-theme '{}'".format(suppliedArg))
elif self.memCurrentSession in self.XFCEsessions:
stream = os.popen("xfconf-query -c xsettings -p /Net/IconThemeName -s '{}'".format(suppliedArg))
elif self.memCurrentSession in self.CinnamonSessions:
Expand All @@ -278,6 +300,8 @@ def changeIconTheme(self, suppliedArg):
def changeWMtheme(self, suppliedArg):
if self.memCurrentSession in self.GNOMEsessions:
stream = os.popen("gsettings set org.gnome.desktop.wm.preferences theme '{}'".format(suppliedArg))
elif self.memCurrentSession in self.BudgieSessions: #same as gnome
stream = os.popen("gsettings set org.gnome.desktop.wm.preferences theme '{}'".format(suppliedArg))
elif self.memCurrentSession in self.XFCEsessions:
stream = os.popen("xfconf-query -c xfwm4 -p /general/theme -s '{}'".format(suppliedArg))
elif self.memCurrentSession in self.CinnamonSessions:
Expand All @@ -289,6 +313,8 @@ def changeWMtheme(self, suppliedArg):
def changeCursorTheme(self, suppliedArg):
if self.memCurrentSession in self.GNOMEsessions:
stream = os.popen("gsettings set org.gnome.desktop.interface cursor-theme '{}'".format(suppliedArg))
elif self.memCurrentSession in self.BudgieSessions: # same as gnome
stream = os.popen("gsettings set org.gnome.desktop.interface cursor-theme '{}'".format(suppliedArg))
elif self.memCurrentSession in self.XFCEsessions:
stream = os.popen("xfconf-query -c xsettings -p /Gtk/CursorThemeName -s '{}'".format(suppliedArg))
elif self.memCurrentSession in self.CinnamonSessions:
Expand All @@ -300,6 +326,8 @@ def changeCursorTheme(self, suppliedArg):
def changeDesktopTheme(self, suppliedArg):
if self.memCurrentSession in self.GNOMEsessions:
stream = os.popen("gsettings set org.gnome.shell.extensions.user-theme name '{}'".format(suppliedArg))
elif self.memCurrentSession in self.BudgieSessions: #same as gnome
stream = os.popen("gsettings set org.gnome.shell.extensions.user-theme name '{}'".format(suppliedArg))
elif self.memCurrentSession in self.XFCEsessions:
self.changeGtkTheme(suppliedArg) # XFCE relies on GTK for desktop appearance
stream = os.popen("echo dummycommand")
Expand All @@ -309,12 +337,12 @@ def changeDesktopTheme(self, suppliedArg):
stream = os.popen("echo notFound")
stream.close()

themerobj = themer()
print(themerobj.getCurrentIconTheme())
print(themerobj.getCurrentGtkTheme())
print(themerobj.getCurrentWMtheme())
print(themerobj.getCurrentCursorTheme())
print(themerobj.getCurrentDesktopTheme())
# themerobj = themer()
# print(themerobj.getCurrentIconTheme())
# print(themerobj.getCurrentGtkTheme())
# print(themerobj.getCurrentWMtheme())
# print(themerobj.getCurrentCursorTheme())
# print(themerobj.getCurrentDesktopTheme())
# themerobj.changeGtkTheme("WhiteSur-dark")
# themerobj.changeIconTheme("ePapirus")
# themerobj.changeWMtheme("WhiteSur-dark")
Expand Down

0 comments on commit be36297

Please sign in to comment.