Add transparency and lock

This commit is contained in:
Astatin3
2024-10-31 10:42:53 -06:00
parent 0597b0db04
commit 2e62807074
6 changed files with 375 additions and 21 deletions
+26
View File
@@ -1,19 +1,45 @@
use egui::Key;
use std::fs::{exists, File};
use std::path::Path;
use std::process::Command;
use std::thread;
const LOCK_FILEPATH: &str = "/tmp/.raylock.lock";
pub fn sway_lock_input() {
thread::spawn(move || {
let _ = Command::new("swaymsg").args(["mode", "lock"]).spawn();
let _ = Command::new("swaymsg")
.args(["input", "type:touchpad", "events", "disabled"])
.spawn();
});
}
pub fn sway_unlock_input() {
thread::spawn(move || {
let _ = Command::new("swaymsg").args(["mode", "default"]).spawn();
let _ = Command::new("swaymsg")
.args(["input", "type:touchpad", "events", "enabled"])
.spawn();
});
}
pub fn create_lock() {
let _ = File::create(LOCK_FILEPATH).unwrap();
}
pub fn is_locked() -> bool {
Path::exists(Path::new(LOCK_FILEPATH))
}
pub fn remove_lock() {
if !is_locked() {
return;
}
std::fs::remove_file(Path::new(LOCK_FILEPATH));
}
pub fn format_key(key: Key, shift_pressed: bool) -> String {
match key {
// Letters