Skip to content

Commit c034918

Browse files
committed
Refactor replace_panel_layout() to start/stop keyboard LED with other panel services
1 parent b97c272 commit c034918

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

mate-tweak

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -703,14 +703,16 @@ class MateTweak:
703703
return confirmed
704704

705705
def replace_panel_layout(self, new_layout, called_from_api=False):
706-
leds_enabled = self.get_bool('org.mate.peripherals-keyboard-xkb.general', None, 'duplicate-leds')
707706
icon_size = self.get_string('org.mate.panel.menubar', None, 'icon-size')
708707
item_icon_size = self.get_string('org.mate.panel.menubar', None, 'item-icon-size')
709708

710709
print('Switching to: ' + new_layout)
710+
# Shutdown panel processes before switching
711711
self.kill_process('mate-panel')
712712
if self.dock and self.process_running(self.dock):
713713
self.kill_process(self.dock)
714+
if self.keyboard_led_enabled:
715+
self.set_bool('org.mate.peripherals-keyboard-xkb.general', None, 'duplicate-leds', False)
714716

715717
if not called_from_api:
716718
self.update_panel_layout_ui(new_layout)
@@ -763,9 +765,6 @@ class MateTweak:
763765
if not called_from_api:
764766
self.update_window_controls()
765767

766-
if leds_enabled:
767-
self.set_bool('org.mate.peripherals-keyboard-xkb.general', None, 'duplicate-leds', False)
768-
769768
# Reset panel configuration to defaults.
770769
self.reset_dconf_path('/org/mate/panel/objects/')
771770
self.reset_dconf_path('/org/mate/panel/toplevels/')
@@ -815,6 +814,8 @@ class MateTweak:
815814
# Set the new layout
816815
subprocess.call(['mate-panel', '--reset'], stdout=DEVNULL, stderr=DEVNULL)
817816
subprocess.call(['mate-panel', '--layout', new_layout], stdout=DEVNULL, stderr=DEVNULL)
817+
if self.keyboard_led_enabled:
818+
self.set_bool('org.mate.peripherals-keyboard-xkb.general', None, 'duplicate-leds', True)
818819
self.reload_panel()
819820

820821
# Brisk Menu remains running.
@@ -873,10 +874,6 @@ class MateTweak:
873874
self.set_dconf_value('/org/compiz/profiles/mate/plugins/core/vsize', '1')
874875
print('Set ' + str(num_workspaces) + ' workspaces for ' + self.current_wm)
875876

876-
if leds_enabled:
877-
time.sleep(1)
878-
self.set_bool('org.mate.peripherals-keyboard-xkb.general', None, 'duplicate-leds', True)
879-
880877
# Make sure the correct panel name is set
881878
if not called_from_api:
882879
widget = self.builder.get_object('combobox_panels')

0 commit comments

Comments
 (0)