@@ -422,7 +422,7 @@ function initGreeter() {
422
422
} ;
423
423
// Prevent losing hardware keyboard focus on the terminal when using touch keyboard
424
424
window . onmouseup = ( e ) => {
425
- window . term [ window . currentTerm ] . term . focus ( ) ;
425
+ if ( window . keyboard . linkedToTerm ) window . term [ window . currentTerm ] . term . focus ( ) ;
426
426
} ;
427
427
window . term [ 0 ] . term . writeln ( "\033[1m" + `Welcome to eDEX-UI v${ electron . remote . app . getVersion ( ) } - Electron v${ process . versions . electron } ` + "\033[0m" ) ;
428
428
@@ -515,6 +515,184 @@ window.focusShellTab = (number) => {
515
515
}
516
516
} ;
517
517
518
+ // Settings editor
519
+ window . openSettings = ( ) => {
520
+ // Build lists of available keyboards, themes, monitors
521
+ let keyboards , themes , monitors ;
522
+ fs . readdirSync ( keyboardsDir ) . forEach ( kb => {
523
+ if ( ! kb . endsWith ( ".json" ) ) return ;
524
+ kb = kb . replace ( ".json" , "" ) ;
525
+ if ( kb === window . settings . keyboard ) return ;
526
+ keyboards += `<option>${ kb } </option>` ;
527
+ } ) ;
528
+ fs . readdirSync ( themesDir ) . forEach ( th => {
529
+ if ( ! th . endsWith ( ".json" ) ) return ;
530
+ th = th . replace ( ".json" , "" ) ;
531
+ if ( th === window . settings . theme ) return ;
532
+ themes += `<option>${ th } </option>` ;
533
+ } ) ;
534
+ for ( let i = 0 ; i < electron . remote . screen . getAllDisplays ( ) . length ; i ++ ) {
535
+ if ( i !== window . settings . monitor ) monitors += `<option>${ i } </option>` ;
536
+ }
537
+
538
+ // Unlink the tactile keyboard from the terminal emulator to allow filling in the settings fields
539
+ window . keyboard . detach ( ) ;
540
+
541
+ new Modal ( {
542
+ type : "custom" ,
543
+ title : `Settings <i>(v${ electron . remote . app . getVersion ( ) } )</i>` ,
544
+ html : `<table id="settingsEditor">
545
+ <tr>
546
+ <th>Key</th>
547
+ <th>Description</th>
548
+ <th>Value</th>
549
+ </tr>
550
+ <tr>
551
+ <td>shell</td>
552
+ <td>The program to run as a terminal emulator</td>
553
+ <td><input type="text" id="settingsEditor-shell" value="${ window . settings . shell } "></td>
554
+ </tr>
555
+ <tr>
556
+ <td>cwd</td>
557
+ <td>Working Directory to start in</td>
558
+ <td><input type="text" id="settingsEditor-cwd" value="${ window . settings . cwd } "></td>
559
+ </tr>
560
+ <tr>
561
+ <td>env</td>
562
+ <td>Custom shell environment override</td>
563
+ <td><input type="text" id="settingsEditor-env" value="${ window . settings . env } "></td>
564
+ </tr>
565
+ <tr>
566
+ <td>keyboard</td>
567
+ <td>On-screen keyboard layout code</td>
568
+ <td><select id="settingsEditor-keyboard">
569
+ <option>${ window . settings . keyboard } </option>
570
+ ${ keyboards }
571
+ </select></td>
572
+ </tr>
573
+ <tr>
574
+ <td>theme</td>
575
+ <td>Name of the theme to load</td>
576
+ <td><select id="settingsEditor-theme">
577
+ <option>${ window . settings . theme } </option>
578
+ ${ themes }
579
+ </select></td>
580
+ </tr>
581
+ <tr>
582
+ <td>audio</td>
583
+ <td>Activate audio sound effects</td>
584
+ <td><select id="settingsEditor-audio">
585
+ <option>${ window . settings . audio } </option>
586
+ <option>${ ! window . settings . audio } </option>
587
+ </select></td>
588
+ </tr>
589
+ <tr>
590
+ <td>extraAudio</td>
591
+ <td>Enable extra audio FX (requires audio: true)</td>
592
+ <td><select id="settingsEditor-extraAudio">
593
+ <option>${ window . settings . extraAudio } </option>
594
+ <option>${ ! window . settings . extraAudio } </option>
595
+ </select></td>
596
+ </tr>
597
+ <tr>
598
+ <td>port</td>
599
+ <td>Local port to use for UI-shell connection</td>
600
+ <td><input type="number" id="settingsEditor-port" value="${ window . settings . port } "></td>
601
+ </tr>
602
+ <tr>
603
+ <td>pingAddr</td>
604
+ <td>IPv4 address to test Internet connectivity</td>
605
+ <td><input type="text" id="settingsEditor-pingAddr" value="${ window . settings . pingAddr || "1.1.1.1" } "></td>
606
+ </tr>
607
+ <tr>
608
+ <td>monitor</td>
609
+ <td>Which monitor to spawn the UI in (defaults to primary display)</td>
610
+ <td><select id="settingsEditor-monitor">
611
+ ${ ( typeof window . settings . monitor !== "undefined" ) ? "<option>" + window . settings . monitor + "</option>" : "" }
612
+ ${ monitors }
613
+ </select></td>
614
+ </tr>
615
+ <tr>
616
+ <td>nointro</td>
617
+ <td>Skip the intro boot log and logo</td>
618
+ <td><select id="settingsEditor-nointro">
619
+ <option>${ window . settings . nointro } </option>
620
+ <option>${ ! window . settings . nointro } </option>
621
+ </select></td>
622
+ </tr>
623
+ <tr>
624
+ <td>iface</td>
625
+ <td>Override the interface used for network monitoring</td>
626
+ <td><input type="text" id="settingsEditor-iface" value="${ window . settings . iface } "></td>
627
+ </tr>
628
+ <tr>
629
+ <td>allowWindowed</td>
630
+ <td>Allow using F11 key to set the UI in windowed mode</td>
631
+ <td><select id="settingsEditor-allowWindowed">
632
+ <option>${ window . settings . allowWindowed } </option>
633
+ <option>${ ! window . settings . allowWindowed } </option>
634
+ </select></td>
635
+ </tr>
636
+ <tr>
637
+ <td>excludeSelfFromToplist</td>
638
+ <td>Exclude eDEX from top processes monitoring</td>
639
+ <td><select id="settingsEditor-excludeSelfFromToplist">
640
+ <option>${ window . settings . excludeSelfFromToplist } </option>
641
+ <option>${ ! window . settings . excludeSelfFromToplist } </option>
642
+ </select></td>
643
+ </tr>
644
+ <tr>
645
+ <td>experimentalFeatures</td>
646
+ <td>Toggle Chrome's experimental web features (DANGEROUS)</td>
647
+ <td><select id="settingsEditor-experimentalFeatures">
648
+ <option>${ window . settings . experimentalFeatures } </option>
649
+ <option>${ ! window . settings . experimentalFeatures } </option>
650
+ </select></td>
651
+ </tr>
652
+ </table>
653
+ <h6 id="settingsEditorStatus">Loaded values from memory</h6>
654
+ <br>` ,
655
+ buttons : [
656
+ { label : "Open in External Editor" , action :`electron.shell.openExternal('file://${ settingsFile } ')` } ,
657
+ { label : "Save to Disk" , action : "window.writeSettingsFile()" } ,
658
+ { label : "Reload UI" , action : "window.location.reload(true);" } ,
659
+ { label : "Restart eDEX" , action : "electron.remote.app.relaunch();electron.remote.app.quit();" }
660
+ ]
661
+ } , ( ) => {
662
+ // Link the keyboard back to the terminal
663
+ window . keyboard . attach ( ) ;
664
+ } ) ;
665
+ } ;
666
+
667
+ window . writeSettingsFile = ( ) => {
668
+ window . settings = {
669
+ shell : document . getElementById ( "settingsEditor-shell" ) . value || window . settings . shell ,
670
+ cwd : document . getElementById ( "settingsEditor-cwd" ) . value || window . settings . cwd ,
671
+ env : document . getElementById ( "settingsEditor-env" ) . value || window . settings . env ,
672
+ keyboard : document . getElementById ( "settingsEditor-keyboard" ) . value || window . settings . keyboard ,
673
+ theme : document . getElementById ( "settingsEditor-theme" ) . value || window . settings . theme ,
674
+ audio : Boolean ( document . getElementById ( "settingsEditor-audio" ) . value ) || window . settings . audio ,
675
+ extraAudio : Boolean ( document . getElementById ( "settingsEditor-extraAudio" ) . value ) || window . settings . extraAudio ,
676
+ pingAddr : document . getElementById ( "settingsEditor-pingAddr" ) . value || window . settings . pingAddr ,
677
+ port : Number ( document . getElementById ( "settingsEditor-port" ) . value ) || window . settings . port ,
678
+ monitor : Number ( document . getElementById ( "settingsEditor-monitor" ) . value ) || window . settings . monitor ,
679
+ nointro : Boolean ( document . getElementById ( "settingsEditor-nointro" ) . value ) || window . settings . nointro ,
680
+ iface : document . getElementById ( "settingsEditor-iface" ) . value || window . settings . iface ,
681
+ allowWindowed : Boolean ( document . getElementById ( "settingsEditor-allowWindowed" ) . value ) || window . settings . allowWindowed ,
682
+ excludeSelfFromToplist : Boolean ( document . getElementById ( "settingsEditor-excludeSelfFromToplist" ) . value ) || window . settings . excludeSelfFromToplist ,
683
+ experimentalFeatures : Boolean ( document . getElementById ( "settingsEditor-experimentalFeatures" ) . value ) || window . settings . experimentalFeatures
684
+ } ;
685
+
686
+ Object . keys ( window . settings ) . forEach ( key => {
687
+ if ( window . settings [ key ] === "undefined" ) {
688
+ delete window . settings [ key ] ;
689
+ }
690
+ } ) ;
691
+
692
+ fs . writeFileSync ( settingsFile , JSON . stringify ( window . settings , "" , 4 ) ) ;
693
+ document . getElementById ( "settingsEditorStatus" ) . innerText = "New values written to settings.json file at " + new Date ( ) . toTimeString ( ) ;
694
+ } ;
695
+
518
696
// Global keyboard shortcuts
519
697
const globalShortcut = electron . remote . globalShortcut ;
520
698
globalShortcut . unregisterAll ( ) ;
@@ -525,6 +703,13 @@ function registerKeyboardShortcuts() {
525
703
electron . remote . getCurrentWindow ( ) . webContents . toggleDevTools ( ) ;
526
704
} ) ;
527
705
706
+ // Open settings
707
+ globalShortcut . register ( "CommandOrControl+Shift+s" , ( ) => {
708
+ if ( ! document . getElementById ( "settingsEditor" ) ) {
709
+ window . openSettings ( ) ;
710
+ }
711
+ } ) ;
712
+
528
713
// Copy and paste shortcuts
529
714
530
715
if ( process . platform === "darwin" ) {
0 commit comments