Skip to content

Commit b48abe1

Browse files
committed
Add restart countdown to OOBS
1 parent d70e514 commit b48abe1

7 files changed

Lines changed: 53 additions & 2 deletions

File tree

shell/locales/en_GB.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"oobs_confirm": "Confirm",
5454
"oobs_continue": "Continue",
5555
"oobs_finish": "Finish",
56+
"oobs_restart": "Restart",
5657

5758
"oobs_l10n_localeVariation": "Language region/variation",
5859
"oobs_l10n_keyboardLayout": "Keyboard layout",

shell/locales/fr_FR.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"oobs_confirm": "Confirmer",
5454
"oobs_continue": "Continuer",
5555
"oobs_finish": "Finir",
56+
"oobs_restart": "Redémarrer",
5657

5758
"oobs_l10n_localeVariation": "Région/variation linguistique",
5859
"oobs_l10n_keyboardLayout": "Disposition du clavier",

shell/oobs/installfinish.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
<div>
1616
<h1 translate>oobs_installFinish_title</h1>
1717
<p translate>oobs_installFinish_description</p>
18-
<!-- TODO: Add auto-restart countdown -->
18+
<p class="oobs_installFinish_countdown"></p>
1919
</div>
2020
</div>
2121
<aui-buttons aui-mode="end" class="oobs_options">
22-
<!-- TODO: Add button for restarting -->
22+
<button class="oobs_installFinish_restart" translate>oobs_restart</button>
2323
</aui-buttons>
2424
</div>
2525
</div>

shell/oobs/oobs.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@
7979
margin-inline-end: 0;
8080
}
8181

82+
.oobs_installFinish_countdown {
83+
text-align: center;
84+
font-size: 4rem;
85+
font-weight: bold;
86+
}
87+
8288
@media (max-width: 800px) {
8389
#oobs .oobs_step {
8490
padding: 0.5rem;

shell/oobs/oobs.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,22 @@ export function init() {
731731
$g.sel(".oobs_installConfirm_confirm").on("click", function() {
732732
processInstallation().then(function() {
733733
selectStep("installfinish");
734+
735+
var countdownValue = 10;
736+
737+
$g.sel(".oobs_installFinish_countdown").setText(_format(countdownValue));
738+
739+
var countdownInterval = setInterval(function countdown() {
740+
countdownValue--;
741+
742+
$g.sel(".oobs_installFinish_countdown").setText(_format(countdownValue));
743+
744+
if (countdownValue == 0) {
745+
clearInterval(countdownInterval);
746+
747+
gShell.call("power_restart");
748+
}
749+
}, 1_000);
734750
}).catch(function(error) {
735751
console.error(error);
736752

@@ -740,6 +756,10 @@ export function init() {
740756
});
741757
});
742758

759+
$g.sel(".oobs_installFinish_restart").on("click", function() {
760+
gShell.call("power_restart");
761+
});
762+
743763
$g.sel(".oobs_userProfile_next").on("click", function() {
744764
checkDisplayName();
745765
});

src/ipc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ ipcMain.handle("power_shutDown", function(event, data) {
100100
return Promise.resolve();
101101
});
102102

103+
ipcMain.handle("power_restart", function(event, data) {
104+
system.restart();
105+
106+
return Promise.resolve();
107+
});
108+
103109
ipcMain.handle("power_sleep", function(event, data) {
104110
system.sleep();
105111

src/system.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ exports.getScreenResolution = function() {
194194
};
195195

196196
exports.shutDown = function() {
197+
console.log("Shut down called");
198+
197199
if (!flags.isRealHardware) {
198200
electron.app.exit(0);
199201

@@ -203,7 +205,22 @@ exports.shutDown = function() {
203205
return exports.executeCommand("sudo", ["shutdown", "-h", "now"]);
204206
};
205207

208+
exports.restart = function() {
209+
console.log("Restart called");
210+
211+
if (!flags.isRealHardware) {
212+
electron.app.relaunch();
213+
electron.app.exit(0);
214+
215+
return Promise.resolve();
216+
}
217+
218+
return exports.executeCommand("sudo", ["reboot"]);
219+
};
220+
206221
exports.sleep = function() {
222+
console.log("Sleep called");
223+
207224
if (!flags.isRealHardware) {
208225
return Promise.resolve();
209226
}

0 commit comments

Comments
 (0)