feat: Add user install script and automatic desktop autostart synchronization
This commit is contained in:
parent
20a8c2f53e
commit
3a84ec5a78
2 changed files with 75 additions and 0 deletions
53
install.sh
Executable file
53
install.sh
Executable file
|
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
echo "============================================="
|
||||
echo " Installing vrec Screen Recorder "
|
||||
echo "============================================="
|
||||
|
||||
# Compile release binaries
|
||||
echo "[1/4] Compiling release binaries..."
|
||||
cargo build --release
|
||||
|
||||
BIN_DIR="$HOME/.local/bin"
|
||||
APP_DIR="$HOME/.local/share/applications"
|
||||
|
||||
mkdir -p "$BIN_DIR"
|
||||
mkdir -p "$APP_DIR"
|
||||
|
||||
echo "[2/4] Installing binaries to $BIN_DIR..."
|
||||
install -m 755 target/release/vrec-daemon "$BIN_DIR/vrec-daemon"
|
||||
install -m 755 target/release/vrec-ui "$BIN_DIR/vrec-ui"
|
||||
|
||||
echo "[3/4] Creating application launcher..."
|
||||
cat > "$APP_DIR/vrec.desktop" << EOF
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=vrec Screen Recorder
|
||||
Comment=Fast GPU Hardware Screen Recorder & Instant Replay
|
||||
Exec=vrec-ui --menu
|
||||
Icon=media-record
|
||||
Terminal=false
|
||||
Categories=AudioVideo;Recorder;
|
||||
Keywords=screen;recorder;replay;capture;
|
||||
EOF
|
||||
|
||||
echo "[4/4] Verifying PATH..."
|
||||
if [[ ":$PATH:" != *":$BIN_DIR:"* ]]; then
|
||||
echo "Notice: $BIN_DIR is not in your PATH. Consider adding:"
|
||||
echo ' export PATH="$HOME/.local/bin:$PATH"'
|
||||
fi
|
||||
|
||||
echo "============================================="
|
||||
echo " vrec successfully installed! "
|
||||
echo "============================================="
|
||||
echo "You can now run:"
|
||||
echo " vrec-daemon # Starts background recording engine"
|
||||
echo " vrec-ui --menu # Opens the HUD overlay menu"
|
||||
echo " vrec-ui --record # Toggles normal recording"
|
||||
echo " vrec-ui --save # Saves instant replay"
|
||||
echo ""
|
||||
echo "Tip: You can bind 'vrec-ui --menu' or 'vrec-ui --save' in Hyprland config (hyprland.conf):"
|
||||
echo ' bind = ALT, Z, exec, vrec-ui --menu'
|
||||
echo ' bind = CONTROL SHIFT, R, exec, vrec-ui --save'
|
||||
echo "============================================="
|
||||
|
|
@ -62,6 +62,28 @@ impl VrecConfig {
|
|||
}
|
||||
let data = serde_json::to_string_pretty(self)?;
|
||||
fs::write(path, data)?;
|
||||
let _ = self.update_autostart();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn update_autostart(&self) -> Result<(), std::io::Error> {
|
||||
let mut autostart_dir = dirs::config_dir().unwrap_or_else(|| PathBuf::from("."));
|
||||
autostart_dir.push("autostart");
|
||||
let desktop_file = autostart_dir.join("vrec.desktop");
|
||||
|
||||
if self.autostart {
|
||||
fs::create_dir_all(&autostart_dir)?;
|
||||
let content = "[Desktop Entry]\n\
|
||||
Type=Application\n\
|
||||
Name=vrec Screen Recorder\n\
|
||||
Comment=Hardware-accelerated screen recorder and instant replay\n\
|
||||
Exec=sh -c \"vrec-daemon & vrec-ui\"\n\
|
||||
Terminal=false\n\
|
||||
Categories=AudioVideo;Recorder;\n";
|
||||
fs::write(desktop_file, content)?;
|
||||
} else if desktop_file.exists() {
|
||||
let _ = fs::remove_file(desktop_file);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue