Skip to content

Commit 6f36b9d

Browse files
committed
add wayland button
1 parent ea5c6c9 commit 6f36b9d

File tree

3 files changed

+56
-4
lines changed

3 files changed

+56
-4
lines changed

openplotterSettings/data/wayland.png

5.06 KB
Loading

openplotterSettings/openplotterSettings.py

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,9 @@ def pageRpi(self):
551551
self.Bind(wx.EVT_TOOL, self.OnToolbacklightInstall, toolbacklightInstall)
552552
toolbacklightSet = self.toolbar5.AddTool(505, _('Set backlight'), wx.Bitmap(self.currentdir+"/data/brightness.png"))
553553
self.Bind(wx.EVT_TOOL, self.OnToolbacklightSet, toolbacklightSet)
554+
self.toolbar5.AddSeparator()
555+
toolWayland = self.toolbar5.AddCheckTool(506, 'Wayland', wx.Bitmap(self.currentdir+"/data/wayland.png"))
556+
self.Bind(wx.EVT_TOOL, self.OnToolWayland, toolWayland)
554557

555558
powerLabel = wx.StaticText(self.raspSettings, label=_('Shutdown Management'))
556559

@@ -596,10 +599,6 @@ def pageRpi(self):
596599
self.raspSettings.SetSizer(sizer)
597600

598601
if self.platform.isRPI:
599-
self.toolbar5.ToggleTool(503,True)
600-
self.toolbar5.EnableTool(504,True)
601-
self.toolbar8.EnableTool(806,True)
602-
self.toolbar9.EnableTool(905,True)
603602

604603
if os.path.exists('/usr/share/applications/openplotter-brightness.desktop'):
605604
self.toolbar5.ToggleTool(504,True)
@@ -608,6 +607,9 @@ def pageRpi(self):
608607
self.toolbar5.ToggleTool(504,False)
609608
self.toolbar5.EnableTool(505,False)
610609

610+
out = subprocess.check_output('echo $XDG_SESSION_TYPE', shell=True).decode(sys.stdin.encoding)
611+
if 'wayland' in out: self.toolbar5.ToggleTool(506,True)
612+
611613
try: shutdown = eval(self.conf.get('GENERAL', 'shutdown'))
612614
except: shutdown = {}
613615
if shutdown:
@@ -638,6 +640,7 @@ def pageRpi(self):
638640
self.toolbar5.EnableTool(503,False)
639641
self.toolbar5.EnableTool(504,False)
640642
self.toolbar5.EnableTool(505,False)
643+
self.toolbar5.EnableTool(506,False)
641644
self.toolbar8.EnableTool(801,False)
642645
self.toolbar8.EnableTool(806,False)
643646
self.toolbar9.EnableTool(901,False)
@@ -787,6 +790,35 @@ def OnToolbacklightSet(self,e):
787790
subprocess.call(['pkill', '-f', 'rpi-backlight-gui'])
788791
subprocess.Popen('rpi-backlight-gui')
789792

793+
def OnToolWayland(self,e):
794+
if self.toolbar5.GetToolState(506):
795+
msg = _('Wayland will be enabled and X11 disabled. Some programs may not yet work correctly for Wayland.')
796+
msg += _('\n')
797+
msg += _('OpenPlotter will reboot. Are you sure?')
798+
dlg = wx.MessageDialog(None, msg, _('Question'), wx.YES_NO | wx.NO_DEFAULT | wx.ICON_EXCLAMATION)
799+
if dlg.ShowModal() == wx.ID_YES:
800+
subprocess.call([self.platform.admin, 'raspi-config', 'nonint', 'do_wayland', 'W2'])
801+
out = subprocess.check_output('raspi-config nonint get_vnc', shell=True).decode(sys.stdin.encoding)
802+
if '0' in out: self.conf.set('GENERAL', 'forceVNC', '1')
803+
os.system('shutdown -r now')
804+
else:
805+
self.toolbar5.ToggleTool(506,False)
806+
self.ShowStatusBarRED(_('Canceled'))
807+
else:
808+
msg = _('Wayland will be disabled and X11 enabled.')
809+
msg += _('\n')
810+
msg += _('OpenPlotter will reboot. Are you sure?')
811+
dlg = wx.MessageDialog(None, msg, _('Question'), wx.YES_NO | wx.NO_DEFAULT | wx.ICON_EXCLAMATION)
812+
if dlg.ShowModal() == wx.ID_YES:
813+
subprocess.call([self.platform.admin, 'raspi-config', 'nonint', 'do_wayland', 'W1'])
814+
out = subprocess.check_output('raspi-config nonint get_vnc', shell=True).decode(sys.stdin.encoding)
815+
if '0' in out: self.conf.set('GENERAL', 'forceVNC', '1')
816+
os.system('shutdown -r now')
817+
else:
818+
self.toolbar5.ToggleTool(506,True)
819+
self.ShowStatusBarRED(_('Canceled'))
820+
dlg.Destroy()
821+
790822
def OnToolGpio(self,e):
791823
dlg = GpioMap()
792824
res = dlg.ShowModal()

openplotterSettings/startup.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,21 @@ def checkApp(self, startup):
148148
if result: self.add_logger_data(result)
149149

150150
def starting(self):
151+
152+
self.add_logger_data(_('Checking display server...'))
153+
try:
154+
out = subprocess.check_output('echo $XDG_SESSION_TYPE', shell=True).decode(sys.stdin.encoding)
155+
out = out.replace("\n","")
156+
out = out.strip()
157+
self.add_logger_data({'green':'','black':out,'red':''})
158+
if self.mode == 'start':
159+
if self.isRPI:
160+
forceVNC = self.conf.get('GENERAL', 'forceVNC')
161+
if forceVNC == '1':
162+
subprocess.Popen(['sudo', 'raspi-config', 'nonint', 'do_vnc', '0'])
163+
self.conf.set('GENERAL', 'forceVNC', '0')
164+
except Exception as e: self.add_logger_data({'green':'','black':'','red':str(e)})
165+
151166
delay = self.conf.get('GENERAL', 'delay')
152167
if self.mode == 'start':
153168
try:
@@ -270,6 +285,11 @@ def starting(self):
270285
if 'dtoverlay=gpio-shutdown' in data and not '#dtoverlay=gpio-shutdown' in data: self.add_logger_data({'green':'','black':_('enabled'),'red':''})
271286
else: self.add_logger_data({'green':'','black':_('disabled'),'red':''})
272287

288+
forceVNC = self.conf.get('GENERAL', 'forceVNC')
289+
if forceVNC == '1':
290+
subprocess.Popen(['sudo', 'raspi-config', 'nonint', 'do_vnc', '0'])
291+
self.conf.set('GENERAL', 'forceVNC', '0')
292+
273293
self.add_logger_data(_('Checking OpenPlotter autostart...'))
274294
if not os.path.exists(self.conf.home+'/.config/autostart/openplotter-startup.desktop'):
275295
self.add_logger_data({'green':'','black':'','red':_('Autostart is not enabled and most features will not work. Please select "Autostart" in "OpenPlotter Settings"')})

0 commit comments

Comments
 (0)