@@ -686,13 +686,13 @@ def on_change_style(self, event):
686686 lxde_conf_dir = os .path .expanduser ("~/.config/lxsession/LXDE" )
687687 lxde_conf_path = os .path .join (lxde_conf_dir , "desktop.conf" )
688688 os .makedirs (lxde_conf_dir , exist_ok = True )
689-
689+
690690 # Read existing or create new
691691 conf_lines = []
692692 if os .path .exists (lxde_conf_path ):
693693 with open (lxde_conf_path , "r" ) as f :
694694 conf_lines = f .readlines ()
695-
695+
696696 # Ensure GTK section exists and update theme name
697697 gtk_section_found = False
698698 for i , line in enumerate (conf_lines ):
@@ -705,20 +705,23 @@ def on_change_style(self, event):
705705 if not gtk_section_found :
706706 conf_lines .append ("[GTK]\\ n" )
707707 conf_lines .append (f"sNet/ThemeName={ gtk_theme } \\ n" )
708-
708+
709709 with open (lxde_conf_path , "w" ) as f :
710710 f .writelines (conf_lines )
711711
712712 # Reload window manager (Openbox) and LXPanel
713713 subprocess .run (
714- ["bash" , "-c" , "export DISPLAY=:1; lxpanelctl restart; openbox --reconfigure" ],
714+ [
715+ "bash" ,
716+ "-c" ,
717+ "export DISPLAY=:1; lxpanelctl restart; openbox --reconfigure" ,
718+ ],
715719 stdout = subprocess .DEVNULL ,
716- stderr = subprocess .DEVNULL
720+ stderr = subprocess .DEVNULL ,
717721 )
718722 except Exception as e :
719723 LogManager .logger .exception (f"Error refreshing GTK applications: { e } " )
720724
721-
722725 def on_run_application (self , event ):
723726 """
724727 Handle the 'run_application' event.
@@ -763,7 +766,7 @@ def on_run_application(self, event):
763766
764767 _ , file_extension = os .path .splitext (entrypoint )
765768
766- if file_extension == ".cpp" :
769+ if file_extension == ".cpp" or entrypoint . endswith ( ".launch.py" ) :
767770 fds = os .listdir ("/dev/pts/" )
768771 console_fd = str (max (map (int , fds [:- 1 ])))
769772
@@ -780,23 +783,37 @@ def on_run_application(self, event):
780783 executable = "/bin/bash" ,
781784 )
782785 returncode = compile_process .wait ()
783- print (returncode )
784786 if returncode != 0 :
785787 raise Exception ("Failed to compile" )
786788
787789 self .unpause_sim ()
788- self .application_process = subprocess .Popen (
789- [
790- "source /workspace/code/install/setup.bash && ros2 run academy academyCode"
791- ],
792- stdin = open ("/dev/pts/" + console_fd , "r" ),
793- stdout = open ("/dev/pts/" + console_fd , "w" ),
794- stderr = sys .stdout ,
795- bufsize = 1024 ,
796- universal_newlines = True ,
797- shell = True ,
798- executable = "/bin/bash" ,
799- )
790+ if entrypoint .endswith (".launch.py" ):
791+ self .application_process = subprocess .Popen (
792+ [
793+ f"source /workspace/code/install/setup.bash && ros2 launch { entrypoint } "
794+ ],
795+ stdin = open ("/dev/pts/" + console_fd , "r" ),
796+ stdout = open ("/dev/pts/" + console_fd , "w" ),
797+ stderr = sys .stdout ,
798+ bufsize = 1024 ,
799+ universal_newlines = True ,
800+ shell = True ,
801+ executable = "/bin/bash" ,
802+ )
803+ else :
804+
805+ self .application_process = subprocess .Popen (
806+ [
807+ "source /workspace/code/install/setup.bash && ros2 run academy academyCode"
808+ ],
809+ stdin = open ("/dev/pts/" + console_fd , "r" ),
810+ stdout = open ("/dev/pts/" + console_fd , "w" ),
811+ stderr = sys .stdout ,
812+ bufsize = 1024 ,
813+ universal_newlines = True ,
814+ shell = True ,
815+ executable = "/bin/bash" ,
816+ )
800817 return
801818
802819 # Pass the linter
0 commit comments