Skip to content

Commit

Permalink
Make run in background
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsparrow committed Jan 26, 2024
1 parent ca6263a commit 745b641
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 18 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
---
name: Build
on: push
name: Release
on:
push:
tags:
- 'v*'
jobs:
app:
name: Build Desktop App
Expand All @@ -24,3 +27,13 @@ jobs:
npm install
npm run tauri -- build --verbose
working-directory: ./semdesk-app

- name: Release with Notes
uses: softprops/action-gh-release@v1
with:
files: |
target/release/bundle/deb/*.deb
target/release/bundle/deb/*.AppImage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

5 changes: 1 addition & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
dbus
openssl_3
librsvg
libayatana-appindicator
];

packages = with pkgs; [
Expand All @@ -33,15 +34,11 @@
webkitgtk
librsvg
(python3.withPackages(ps: with ps; [ torch ]))
libayatana-appindicator
];
in
{
devShell = pkgs.mkShell {
buildInputs = packages;
nativeBuildInputs = with pkgs; [
pkg-config
];

shellHook =
''
Expand Down
38 changes: 26 additions & 12 deletions semdesk-app/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use actix_web::rt::System;
use std::thread;

use semdesk_api::run_server;
use tauri::{CustomMenuItem, SystemTray, SystemTrayMenu, SystemTrayMenuItem, SystemTrayEvent};
use tauri::Manager;
use tauri::{CustomMenuItem, SystemTray, SystemTrayEvent, SystemTrayMenu, SystemTrayMenuItem};

// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
Expand All @@ -26,20 +26,28 @@ fn main() {

tauri::Builder::default()
.system_tray(tray)
.on_window_event(|event| match event.event() {
tauri::WindowEvent::CloseRequested { api, .. } => {
event.window().hide().unwrap();
api.prevent_close();
}
_ => {}
})
.on_system_tray_event(|app, event| match event {
SystemTrayEvent::MenuItemClick { id, .. } => match id.as_str() {
"quit" => {
std::process::exit(0);
}
"show_hide" => {
match app.get_window("main") {
Some(window) => match window.is_visible().unwrap() {
true => window.hide().unwrap(),
false => window.show().unwrap()
},
_ => ()
}
}
"show_hide" => match app.get_window("main") {
Some(window) => match window.is_visible().unwrap() {
true => window.hide().unwrap(),
false => {
window.show().unwrap();
window.set_focus().unwrap()
}
},
_ => ()
},
_ => {}
},
_ => {}
Expand All @@ -54,6 +62,12 @@ fn main() {
Ok(())
})
.invoke_handler(tauri::generate_handler![greet])
.run(tauri::generate_context!())
.expect("error while running tauri application");
.build(tauri::generate_context!())
.expect("error while running tauri application")
.run(|_app_handle, event| match event {
tauri::RunEvent::ExitRequested { api, .. } => {
api.prevent_exit();
}
_ => {}
});
}

0 comments on commit 745b641

Please sign in to comment.