Created
July 20, 2021 15:38
-
-
Save abdelghanyMh/abf9e915fd417a8160c447b5e6c4733d to your computer and use it in GitHub Desktop.
switch between dark mode and light mode in Linux mint cinnamon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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