Skip to content
This repository was archived by the owner on Feb 21, 2026. It is now read-only.

Commit 1814e1c

Browse files
author
Snazzie
committed
refactor and update product name
1 parent 8ea09d2 commit 1814e1c

File tree

3 files changed

+37
-48
lines changed

3 files changed

+37
-48
lines changed

src-tauri/src/lib.rs

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,17 @@
1-
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
21
mod plex_handler;
32

43
use plex_handler::toggle_fullscreen;
5-
6-
#[tauri::command]
7-
fn greet(name: &str) -> String {
8-
format!("Hello, {}! You've been greeted from Rust!", name)
9-
}
4+
mod script;
105

116
#[cfg_attr(mobile, tauri::mobile_entry_point)]
127
pub fn run() {
13-
// Fullscreen event listener script
14-
let init_script = "
15-
// Add a fullscreen change event listener to the document
16-
document.addEventListener('fullscreenchange', function(event) {
17-
// Check if the document is in fullscreen mode
18-
const isFullscreen = document.fullscreenElement !== null;
19-
console.log('Fullscreen event detected!', event);
20-
console.log('Fullscreen state:', isFullscreen);
21-
console.log('Fullscreen element:', document.fullscreenElement);
22-
23-
// Send a message to the Tauri app using the invoke system
24-
try {
25-
if (window.__TAURI_INTERNALS__) {
26-
// Get the current window label
27-
const windowLabel = window.__TAURI_INTERNALS__.metadata.currentWindow.label;
28-
console.log('Current window label:', windowLabel);
29-
30-
// Directly invoke the toggle_fullscreen command with window label
31-
window.__TAURI_INTERNALS__.invoke('toggle_fullscreen', {
32-
isFullscreen: isFullscreen,
33-
windowLabel: windowLabel
34-
});
35-
console.log('Invoked toggle_fullscreen with state:', isFullscreen, 'for window:', windowLabel);
36-
} else {
37-
console.error('__TAURI_INTERNALS__ is not available');
38-
}
39-
} catch (e) {
40-
console.error('Error invoking toggle_fullscreen:', e);
41-
}
42-
});
43-
44-
console.log('Plex fullscreen event listener injected');
45-
";
46-
8+
// Fullscreen event listener scrip
479
tauri::Builder::default()
4810
.plugin(tauri_plugin_opener::init())
4911
.plugin(tauri_plugin_store::Builder::default().build())
50-
.invoke_handler(tauri::generate_handler![greet, toggle_fullscreen,])
51-
// Setup hook to inject the script into any new webview window
52-
.setup(|_app| {
53-
println!("Tauri application setup complete.");
54-
Ok(())
55-
})
12+
.invoke_handler(tauri::generate_handler![toggle_fullscreen,])
5613
// Use the initialization script for all webviews
57-
.append_invoke_initialization_script(init_script)
14+
.append_invoke_initialization_script(script::INIT_SCRIPT)
5815
.run(tauri::generate_context!())
5916
.expect("error while running tauri application");
6017
}

src-tauri/src/script.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
pub const INIT_SCRIPT: &str = r#"
2+
// Add a fullscreen change event listener to the document
3+
document.addEventListener('fullscreenchange', function(event) {
4+
// Check if the document is in fullscreen mode
5+
const isFullscreen = document.fullscreenElement !== null;
6+
console.log('Fullscreen event detected!', event);
7+
console.log('Fullscreen state:', isFullscreen);
8+
console.log('Fullscreen element:', document.fullscreenElement);
9+
10+
// Send a message to the Tauri app using the invoke system
11+
try {
12+
if (window.__TAURI_INTERNALS__) {
13+
// Get the current window label
14+
const windowLabel = window.__TAURI_INTERNALS__.metadata.currentWindow.label;
15+
console.log('Current window label:', windowLabel);
16+
17+
// Directly invoke the toggle_fullscreen command with window label
18+
window.__TAURI_INTERNALS__.invoke('toggle_fullscreen', {
19+
isFullscreen: isFullscreen,
20+
windowLabel: windowLabel
21+
});
22+
console.log('Invoked toggle_fullscreen with state:', isFullscreen, 'for window:', windowLabel);
23+
} else {
24+
console.error('__TAURI_INTERNALS__ is not available');
25+
}
26+
} catch (e) {
27+
console.error('Error invoking toggle_fullscreen:', e);
28+
}
29+
});
30+
31+
console.log('Plex fullscreen event listener injected');
32+
"#;

src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://schema.tauri.app/config/2",
3-
"productName": "plexontauri",
3+
"productName": "Plex On Tauri",
44
"version": "0.1.0",
55
"identifier": "com.plexontauri.app",
66
"build": {

0 commit comments

Comments
 (0)