Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
feat: ubuntu >22.10 show compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianKominovic committed Aug 27, 2023
1 parent 224cf2d commit 8ed1ff6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition = "2021"
tauri-build = { version = "1.2", features = [] }

[dependencies]
tauri = { version = "1.2", features = [ "window-unminimize", "window-minimize", "http-all", "dialog-all", "fs-remove-dir", "fs-read-dir", "fs-write-file", "fs-create-dir", "fs-read-file", "clipboard-all", "global-shortcut-all", "notification-all", "path-all", "shell-open", "window-center", "window-close", "window-set-focus", "window-start-dragging"] }
tauri = { version = "1.2", features = [ "window-all", "http-all", "dialog-all", "fs-remove-dir", "fs-read-dir", "fs-write-file", "fs-create-dir", "fs-read-file", "clipboard-all", "global-shortcut-all", "notification-all", "path-all", "shell-open"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
portable-pty = "0.8.1"
Expand Down
25 changes: 22 additions & 3 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,16 @@ async fn cmd(command: String) -> Result<String, String> {

#[tauri::command]
async fn show_app() {
// wmctrl -l | grep -E 'sittly$'
// Get current workspace
// xdotool get_desktop
let workspace_args = ["get_desktop"];
let workspace_output = Command::new("xdotool")
.args(workspace_args)
.output()
.unwrap_or_else(|_| panic!("Failed to execute command"));
let workspace_stdout = String::from_utf8(workspace_output.stdout).unwrap();

// Get all windows
let window_list_args = ["-l"];
let window_list_output = Command::new("wmctrl")
.args(window_list_args)
Expand All @@ -146,9 +155,19 @@ async fn show_app() {

let window_id = window_list_item.split("\n").collect::<Vec<&str>>()[0];

let args: [&str; 2] = ["windowactivate", window_id];
// Bring sittly window to current desktop

Command::new("xdotool")
.args(args)
.args([
"set_desktop_for_window",
window_id,
workspace_stdout.as_str(),
])
.output()
.unwrap_or_else(|_| panic!("Failed to execute command"));

Command::new("xdotool")
.args(["windowactivate", window_id])
.output()
.unwrap_or_else(|_| panic!("Failed to execute command"));
}
Expand Down
12 changes: 1 addition & 11 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,7 @@
"writeFile": true
},
"window": {
"all": false,
"close": true,
"hide": false,
"show": false,
"maximize": false,
"minimize": true,
"unmaximize": false,
"unminimize": true,
"startDragging": true,
"center": true,
"setFocus": true
"all": true
},
"dialog": {
"all": true
Expand Down
7 changes: 4 additions & 3 deletions src/devtools/api/app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { invoke } from "@tauri-apps/api";
import { appWindow } from "@tauri-apps/api/window";
import { appWindow, LogicalPosition } from "@tauri-apps/api/window";

/**
* Quit the app. Kill the process.
Expand All @@ -16,8 +16,9 @@ export function hideApp() {
/**
* Show the app.
*/
export function showApp() {
return invoke("show_app");
export async function showApp() {
await centerApp();
await invoke("show_app");
}

/**
Expand Down

0 comments on commit 8ed1ff6

Please sign in to comment.