Skip to content

Instantly share code, notes, and snippets.

@abdelghanyMh
Created July 20, 2021 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abdelghanyMh/abf9e915fd417a8160c447b5e6c4733d to your computer and use it in GitHub Desktop.
Save abdelghanyMh/abf9e915fd417a8160c447b5e6c4733d to your computer and use it in GitHub Desktop.
switch between dark mode and light mode in Linux mint cinnamon
#!/usr/bin/python3
import sys
from gi.repository import Gio
import time
# for light theme ./dark_light.py light
# for dark theme ./dark_light.py dark
# if no theme has been specified scripte will stop
if len(sys.argv) == 1:
print("\n")
set_theme = input("Please specify mode ! (light/dark):")
print("\n")
else:
# get Command Line Argument
set_theme = str(sys.argv[1])
print("\n")
print("\nwindows borders:" +
Gio.Settings(schema="org.cinnamon.desktop.wm.preferences").get_string("theme"))
# print("Icons: "+Gio.Settings(schema="org.cinnamon.desktop.interface").get_string("icon-theme"))
print("Controls: "+Gio.Settings(schema="org.cinnamon.desktop.interface").get_string("gtk-theme"))
print("Desktop: "+Gio.Settings(schema="org.cinnamon.theme").get_string("name"))
print("\n")
# dark mode values to apply
dark_mode = {
"windows_borders": 'Mint-Y-Dark',
"controls": 'Mint-Y-Dark-Pink',
"desktop": 'Mint-Y-Dark-Pink'
}
# light mode values to apply
light_mode = {
"windows_borders": 'Mint-Y',
"controls": 'Mint-X-Pink',
"desktop": 'Mint-X-Pink'
}
# switch from dark/light
if set_theme == 'light':
print("\n")
print("switching to Light mode!")
print("\n")
settings = Gio.Settings(schema="org.cinnamon.desktop.interface")
time.sleep(2)
settings.set_string("gtk-theme", light_mode["controls"])
time.sleep(2)
Gio.Settings(schema="org.cinnamon.desktop.wm.preferences").set_string(
"theme", light_mode["windows_borders"])
time.sleep(2)
Gio.Settings(schema="org.cinnamon.theme").set_string(
"name", light_mode["desktop"])
time.sleep(2)
elif set_theme == 'dark':
print("\n")
print("switching to dark mode!")
print("\n")
settings = Gio.Settings(schema="org.cinnamon.desktop.interface")
time.sleep(2)
settings.set_string("gtk-theme", dark_mode["controls"])
time.sleep(2)
Gio.Settings(schema="org.cinnamon.desktop.wm.preferences").set_string(
"theme", dark_mode["windows_borders"])
time.sleep(2)
Gio.Settings(schema="org.cinnamon.theme").set_string(
"name", dark_mode["desktop"])
time.sleep(2)
print("\n")
print("\nwindows borders:" +
Gio.Settings(schema="org.cinnamon.desktop.wm.preferences").get_string("theme"))
print("Controls: "+Gio.Settings(schema="org.cinnamon.desktop.interface").get_string("gtk-theme"))
print("Desktop: "+Gio.Settings(schema="org.cinnamon.theme").get_string("name"))
print("\n")
# sys used to get the parametres
# with out time scripte wont work properly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment