Skip to content

Commit

Permalink
minor patch, closes the application on pressing 'Esc' key, and closes…
Browse files Browse the repository at this point in the history
… when an action is done
  • Loading branch information
abhiyandhakal committed May 27, 2023
1 parent e90dc0a commit ef0bfc1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "power-menu",
"private": true,
"version": "0.1.0",
"version": "0.1.1",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "power-menu"
version = "0.1.0"
version = "0.1.1"
description = "A power menu for window managers"
authors = ["you"]
license = ""
Expand Down
16 changes: 15 additions & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ fn shutdown() {
Command::new("poweroff")
.spawn()
.expect("failed to power off");
close();
}

#[tauri::command]
Expand All @@ -17,11 +18,21 @@ fn logout() {
.arg("Xorg")
.spawn()
.expect("Failed to log out");
close();
}

#[tauri::command]
fn reboot() {
Command::new("reboot").output().expect("Failed to reboot");
close();
}

#[tauri::command]
fn close() {
Command::new("killall")
.arg("power-menu")
.spawn()
.expect("Failed to exit power-menu");
}

#[tauri::command]
Expand All @@ -30,11 +41,14 @@ fn suspend() {
.arg("suspend")
.spawn()
.expect("Failed to reboot");
close();
}

fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![shutdown, logout, reboot, suspend])
.invoke_handler(tauri::generate_handler![
shutdown, logout, reboot, suspend, close
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "power-menu",
"version": "0.1.0"
"version": "0.1.1"
},
"tauri": {
"allowlist": {
Expand Down
2 changes: 1 addition & 1 deletion src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
}
// quit
else if (e.key === "Escape") {
await appWindow.close();
await invoke("close");
}
});
</script>
Expand Down

0 comments on commit ef0bfc1

Please sign in to comment.