@@ -551,6 +551,9 @@ def pageRpi(self):
551
551
self .Bind (wx .EVT_TOOL , self .OnToolbacklightInstall , toolbacklightInstall )
552
552
toolbacklightSet = self .toolbar5 .AddTool (505 , _ ('Set backlight' ), wx .Bitmap (self .currentdir + "/data/brightness.png" ))
553
553
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 )
554
557
555
558
powerLabel = wx .StaticText (self .raspSettings , label = _ ('Shutdown Management' ))
556
559
@@ -596,10 +599,6 @@ def pageRpi(self):
596
599
self .raspSettings .SetSizer (sizer )
597
600
598
601
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 )
603
602
604
603
if os .path .exists ('/usr/share/applications/openplotter-brightness.desktop' ):
605
604
self .toolbar5 .ToggleTool (504 ,True )
@@ -608,6 +607,9 @@ def pageRpi(self):
608
607
self .toolbar5 .ToggleTool (504 ,False )
609
608
self .toolbar5 .EnableTool (505 ,False )
610
609
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
+
611
613
try : shutdown = eval (self .conf .get ('GENERAL' , 'shutdown' ))
612
614
except : shutdown = {}
613
615
if shutdown :
@@ -638,6 +640,7 @@ def pageRpi(self):
638
640
self .toolbar5 .EnableTool (503 ,False )
639
641
self .toolbar5 .EnableTool (504 ,False )
640
642
self .toolbar5 .EnableTool (505 ,False )
643
+ self .toolbar5 .EnableTool (506 ,False )
641
644
self .toolbar8 .EnableTool (801 ,False )
642
645
self .toolbar8 .EnableTool (806 ,False )
643
646
self .toolbar9 .EnableTool (901 ,False )
@@ -787,6 +790,35 @@ def OnToolbacklightSet(self,e):
787
790
subprocess .call (['pkill' , '-f' , 'rpi-backlight-gui' ])
788
791
subprocess .Popen ('rpi-backlight-gui' )
789
792
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
+
790
822
def OnToolGpio (self ,e ):
791
823
dlg = GpioMap ()
792
824
res = dlg .ShowModal ()
0 commit comments