@@ -109,8 +109,7 @@ const cpuPath2 = '/sys/firmware/devicetree/base/model';
109109const settingsPath = '/etc/default/weatherService' ;
110110const rpiSetupStuff = path . join ( __dirname , 'raspberry_pi_setup' ) ;
111111const serviceSrc = rpiSetupStuff + '/weatherService' ;
112- const serviceDst = '/etc/init.d/.' ;
113- const serviceDstFull = '/etc/init.d/weatherService' ;
112+ const serviceDst = '/etc/init.d/weatherService' ;
114113const fontSrc = rpiSetupStuff + '/fonts/' ;
115114const fontDst = '/usr/local/share/fonts/' ;
116115let chromium = 'chromium' ;
@@ -693,7 +692,7 @@ async function checkForGps(): Promise<void> {
693692 console . log ( chalkUp ( ' [pb]• Install [w]ntpd[/w] and [w]ntpq[/w]' ) ) ;
694693
695694 if ( ! hasPpsTools )
696- console . log ( chalkUp ( ' [pb]• Install [w]ppstest [/w]' ) ) ;
695+ console . log ( chalkUp ( ' [pb]• Install [w]pps-tools [/w]' ) ) ;
697696 }
698697 else
699698 console . log ( 'GPS time and location services found ' + chalk . green ( CHECK_MARK ) ) ;
@@ -1107,7 +1106,7 @@ async function doServerBuild(): Promise<void> {
11071106 if ( doAcu || doDht ) {
11081107 showStep ( ) ;
11091108
1110- const args = [ 'i' , '-P' , 'rpi-acu-rite-temperature@3' , 'node-dht-sensor-rp5@0 ' ] ;
1109+ const args = [ 'i' , '-P' , 'rpi-acu-rite-temperature@3' , 'node-dht-sensor' ] ;
11111110
11121111 if ( isRaspberryPi5OrLater )
11131112 args . push ( '--use_libgpiod=true' ) ;
@@ -1145,8 +1144,11 @@ async function doServiceDeployment(): Promise<void> {
11451144
11461145 showStep ( ) ;
11471146 write ( 'Create or redeploy weatherService' + trailingSpace ) ;
1148- await monitorProcess ( spawn ( 'cp' , [ serviceSrc , serviceDst ] , { shell : true } ) , spin , ErrorMode . ANY_ERROR ) ;
1149- await monitorProcess ( spawn ( 'chmod' , [ '+x' , serviceDstFull ] , { shell : true } ) , spin , ErrorMode . ANY_ERROR ) ;
1147+
1148+ const serviceScript = fs . readFileSync ( serviceSrc ) . toString ( ) . replace ( / \/ p i \/ / g, `/${ user } /` ) ;
1149+
1150+ fs . writeFileSync ( serviceDst , serviceScript ) ;
1151+ await monitorProcess ( spawn ( 'chmod' , [ '+x' , serviceDst ] , { shell : true } ) , spin , ErrorMode . ANY_ERROR ) ;
11501152
11511153 const settingsText =
11521154 `# If you edit AWC_PORT below, be sure to update\n# ${ userHome } /${ autostartDst } /autostart` +
@@ -1172,7 +1174,8 @@ async function doServiceDeployment(): Promise<void> {
11721174
11731175 autoScript = autoScript . replace ( 'echo #launch-here' , launchCmd )
11741176 . replace ( / : 8 0 8 0 \b / , ':' + settings . AWC_PORT )
1175- . replace ( 'the-browser' , doFirefox ? 'firefox' : chromium ) ;
1177+ . replace ( 'the-browser' , doFirefox ? 'firefox' : chromium )
1178+ . replace ( / \/ p i \/ / g, `/${ user } /` ) ;
11761179
11771180 fs . writeFileSync ( path . join ( autostartDir , autostartScriptFile ) , autoScript ) ;
11781181
@@ -1182,6 +1185,7 @@ async function doServiceDeployment(): Promise<void> {
11821185 let update = false ;
11831186 let found = false ;
11841187
1188+ // Autostart setup for X11
11851189 try {
11861190 lines = asLines ( fs . readFileSync ( autostartPath ) . toString ( ) ) . filter ( line => ! ! line . trim ( ) ) ;
11871191 }
@@ -1216,36 +1220,68 @@ async function doServiceDeployment(): Promise<void> {
12161220 if ( update )
12171221 fs . writeFileSync ( autostartPath , lines . join ( '\n' ) + '\n' ) ;
12181222
1219- // Extra autostart setup for Wayfire
1220- if ( existsSync ( wayfireIniPath ) ) {
1221- try {
1223+ // Autostart setup for Wayland/Wayfire
1224+ try {
1225+ if ( ! existsSync ( wayfireIniPath ) ) {
1226+ fs . mkdirSync ( path . dirname ( wayfireIniPath ) , { recursive : true } ) ;
1227+ lines = [ ] ;
1228+ }
1229+ else
12221230 lines = asLines ( fs . readFileSync ( wayfireIniPath ) . toString ( ) ) . filter ( line => ! ! line . trimEnd ( ) ) ;
12231231
1224- let autoIndex = lines . findIndex ( l => l . startsWith ( '[autostart]' ) ) ;
1225-
1226- if ( autoIndex < 0 ) {
1227- lines . push ( '' ) ;
1228- lines . push ( '[autostart]' ) ;
1229- autoIndex = lines . length ;
1230- }
1231- else
1232- while ( lines [ ++ autoIndex ] && ! / ^ c l o c k [ 1 2 ] = / . test ( lines [ autoIndex ] ) ) { }
1232+ let autoIndex = lines . findIndex ( l => l . startsWith ( '[autostart]' ) ) ;
12331233
1234- // Prevent duplicate entries, remove old entries
1235- lines = lines . filter ( ( l , i ) => i < autoIndex || ! / ^ c l o c k [ 1 2 ] = / . test ( l ) ) ;
1236- lines . splice ( autoIndex , 0 , 'clock1 = ' + autostartEntry ) ;
1237- fs . writeFileSync ( wayfireIniPath , lines . join ( '\n' ) + '\n' ) ;
1234+ if ( autoIndex < 0 ) {
1235+ lines . push ( '' ) ;
1236+ lines . push ( '[autostart]' ) ;
1237+ autoIndex = lines . length ;
12381238 }
1239- catch ( e ) {
1240- console . error ( chalk . redBright ( 'Error: failed to update .config/wayfire.ini to autostart AW-Clock' ) ) ;
1241- console . error ( chalk . redBright ( ' ' + e . message ) ) ;
1239+ else
1240+ while ( lines [ ++ autoIndex ] && ! / ^ ( ( \s * \[ ) | ( c l o c k [ 1 2 ] = ) ) / . test ( lines [ autoIndex ] ) ) { }
1241+
1242+ // Prevent duplicate entries, remove old entries
1243+ lines = lines . filter ( ( l , i ) => i < autoIndex || ! / ^ c l o c k [ 1 2 ] = / . test ( l ) ) ;
1244+ lines . splice ( autoIndex , 0 , 'clock1 = ' + autostartEntry ) ;
1245+ fs . writeFileSync ( wayfireIniPath , lines . join ( '\n' ) + '\n' ) ;
1246+ }
1247+ catch ( e ) {
1248+ console . error ( chalk . redBright ( 'Error: failed to update .config/wayfire.ini to autostart AW-Clock' ) ) ;
1249+ console . error ( chalk . redBright ( ' ' + e . message ) ) ;
1250+ }
1251+
1252+ // Autostart setup for Wayland/Labwc
1253+ const labwcAutostartPath = path . join ( userHome , '.config/labwc/autostart' ) ;
1254+
1255+ try {
1256+ if ( ! existsSync ( labwcAutostartPath ) ) {
1257+ fs . mkdirSync ( path . dirname ( labwcAutostartPath ) , { recursive : true } ) ;
1258+ lines = [ ] ;
12421259 }
1260+ else
1261+ lines = asLines ( fs . readFileSync ( labwcAutostartPath ) . toString ( ) ) . filter ( line => ! ! line . trimEnd ( ) ) ;
1262+
1263+ const autoIndex = lines . findIndex ( l => / \b a u t o s t a r t _ e x t r a .s h \b / . test ( l ) ) ;
1264+
1265+ if ( autoIndex < 0 )
1266+ lines . push ( autostartEntry ) ;
1267+ else
1268+ lines [ autoIndex ] = autostartEntry ;
1269+
1270+ fs . writeFileSync ( labwcAutostartPath , lines . join ( '\n' ) + '\n' ) ;
1271+ }
1272+ catch ( e ) {
1273+ console . error ( chalk . redBright ( 'Error: failed to update .config/labwc/autostart to autostart AW-Clock' ) ) ;
1274+ console . error ( chalk . redBright ( ' ' + e . message ) ) ;
12431275 }
12441276
12451277 await monitorProcess ( spawn ( 'chown' , 0 , [ sudoUser , autostartDir + '/autostart*' ] ,
12461278 { shell : true } ) , spin , ErrorMode . ANY_ERROR ) ;
12471279 await monitorProcess ( spawn ( 'chmod' , uid , [ '+x' , autostartDir + '/autostart*' ] ,
12481280 { shell : true } ) , spin , ErrorMode . ANY_ERROR ) ;
1281+ await monitorProcess ( spawn ( 'chown' , 0 , [ sudoUser , wayfireIniPath ] ,
1282+ { shell : true } ) , spin , ErrorMode . ANY_ERROR ) ;
1283+ await monitorProcess ( spawn ( 'chown' , 0 , [ sudoUser , labwcAutostartPath ] ,
1284+ { shell : true } ) , spin , ErrorMode . ANY_ERROR ) ;
12491285
12501286 if ( noStop )
12511287 console . log ( backspace + trailingSpace + '\n\nReboot to complete set-up.' ) ;
0 commit comments