Skip to content

Commit b62b125

Browse files
authored
Fix no theme change error when auto-started (#36)
- Remove unnecessary modules - Fix function arguments which lead to no change in theme during startup and when next theme button is clicked at the indicator
1 parent a97b280 commit b62b125

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

src/ThemeManager/common.py

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def create_logfile():
7373
CONFIG_DIR = os.path.expanduser('~/.config/theme-manager/')
7474
CONFIG_FILE = os.path.join(CONFIG_DIR+'config.cfg')
7575
UI_PATH = _path+"/ui/"
76+
theme_styles = ["name-mode-color", "name-color-mode"]
7677

7778
# Used as a decorator to run things in the background
7879
def _async(func):

src/ThemeManager/gui.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
gi.require_version("Gtk", "3.0")
3535
from gi.repository import Gtk, Gio
3636

37-
from ThemeManager.common import APP, CONFIG_FILE, LOCALE_DIR, UI_PATH, __version__, _async, TMBackend
37+
from ThemeManager.common import APP, CONFIG_FILE, LOCALE_DIR, UI_PATH, __version__, theme_styles, _async, TMBackend
3838
from ThemeManager.indicator import TMIndicator
3939
from ThemeManager.DesktopTheme import desktop_theme
4040
# from ThemeManager.LoginTheme import login_theme
@@ -112,7 +112,7 @@ def __init__(self, application):
112112

113113
# Combo box
114114
theme_style_store = Gtk.ListStore(str)
115-
self.theme_styles = ["name-mode-color", "name-color-mode"]
115+
self.theme_styles = theme_styles
116116
for style in self.theme_styles:
117117
theme_style_store.append([style])
118118
self.theme_name_style_combo = self.builder.get_object("theme_name_style_combo")

src/ThemeManager/indicator.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from gi.repository import Gtk
3434

3535
from ThemeManager.about_window import AboutWindow
36-
from ThemeManager.common import APP, LOCALE_DIR, LOGFILE, UI_PATH
36+
from ThemeManager.common import APP, LOCALE_DIR, LOGFILE, UI_PATH, theme_styles
3737
from ThemeManager.tm_daemon import TMState_monitor
3838
from ThemeManager.DesktopTheme import desktop_theme
3939

@@ -60,6 +60,7 @@ def __init__(self):
6060

6161
self.destop_manager = desktop_theme()
6262
self.daemon = TMState_monitor()
63+
self.theme_styles = theme_styles
6364
self.daemon.startdaemons()
6465

6566
# create menu
@@ -100,7 +101,7 @@ def __create_menu(self):
100101
def next_theme(self, *args):
101102
module_logger.info("User requested change using Next button from indicator.")
102103
self.state = self.daemon.manager.get_state_info()
103-
self.nexttheme = self.daemon.manager.prep_theme_variants(self.state)
104+
self.nexttheme = self.daemon.manager.prep_theme_variants(self.state, self.theme_styles)
104105
self.daemon.destop_manager.set_desktop_theme(self.state, self.nexttheme)
105106

106107
def show_logs(self, widget):

src/ThemeManager/tm_daemon.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,13 @@
2121
#
2222

2323
# import the necessary modules!
24-
from curses import wrapper
2524
import gettext
2625
import locale
2726
import logging
2827

29-
from threading import Thread
3028
from time import sleep
3129

32-
from ThemeManager.common import APP, LOCALE_DIR, _async, TMBackend
30+
from ThemeManager.common import APP, LOCALE_DIR, theme_styles, _async, TMBackend
3331
from ThemeManager.DesktopTheme import desktop_theme
3432

3533

@@ -46,6 +44,7 @@ class TMState_monitor():
4644
def __init__(self):
4745
module_logger.debug("Initiaing Theme Manager daemon.")
4846
self.manager = TMBackend()
47+
self.theme_styles = theme_styles
4948
self.destop_manager = desktop_theme()
5049
self.last_state = 'Unknown'
5150

@@ -67,14 +66,14 @@ def on_statechange(self):
6766
module_logger.debug("Old state: "+self.last_state)
6867
if self.last_state != currentstate:
6968
self.last_state = currentstate
70-
self.nexttheme = self.manager.prep_theme_variants(self.state)
69+
self.nexttheme = self.manager.prep_theme_variants(self.state, self.theme_styles)
7170
self.destop_manager.set_desktop_theme(self.state, self.nexttheme)
7271
sleep(60) # check once in a minute whether the state is changed
7372

7473
def on_autouser_request(self):
7574
module_logger.info("Starting auto-change at regular interval.")
7675
while True:
7776
self.state = self.manager.get_state_info()
78-
self.nexttheme = self.manager.prep_theme_variants(self.state)
77+
self.nexttheme = self.manager.prep_theme_variants(self.state, self.theme_styles)
7978
self.destop_manager.set_desktop_theme(self.state, self.nexttheme)
8079
sleep(self.manager.theme_interval_in_sec)

0 commit comments

Comments
 (0)