MacBook-OBS-Linux/obs-performance-script.sh
28allday 4d04b06d41 Initial commit: FaceTime HD camera driver and OBS performance scripts
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 18:15:22 +00:00

105 lines
No EOL
3.8 KiB
Bash
Executable file

#!/bin/bash
# OBS Performance Script for Linux Mint Cinnamon
# Fixed version for newer Cinnamon versions
# Color codes for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
echo -e "${GREEN}OBS Performance Optimizer for Linux Mint Cinnamon${NC}"
echo "=================================================="
# Check if OBS is installed
if ! command -v obs-studio &> /dev/null && ! command -v flatpak run com.obsproject.Studio &> /dev/null; then
echo -e "${RED}Error: OBS Studio not found!${NC}"
echo "Install with: sudo apt install obs-studio"
echo "Or: flatpak install flathub com.obsproject.Studio"
exit 1
fi
# Detect OBS installation type
if command -v obs-studio &> /dev/null; then
OBS_COMMAND="obs-studio"
elif flatpak list | grep -q "com.obsproject.Studio"; then
OBS_COMMAND="flatpak run com.obsproject.Studio"
else
OBS_COMMAND="obs" # fallback
fi
# Store original settings (using correct keys for newer Cinnamon)
echo -e "${YELLOW}Saving current desktop settings...${NC}"
# Check Cinnamon version and use appropriate settings
if gsettings list-keys org.cinnamon.desktop.wm.preferences | grep -q "compositor-manager"; then
# Newer Cinnamon
ORIGINAL_COMPOSITOR=$(gsettings get org.cinnamon.desktop.wm.preferences compositor-manager 2>/dev/null || echo "true")
COMPOSITOR_KEY="org.cinnamon.desktop.wm.preferences compositor-manager"
else
# Try muffin settings
ORIGINAL_COMPOSITOR="true"
COMPOSITOR_KEY=""
fi
ORIGINAL_UNREDIRECT=$(gsettings get org.cinnamon.muffin unredirect-fullscreen-windows 2>/dev/null || echo "false")
echo "Unredirect: $ORIGINAL_UNREDIRECT"
# Apply performance settings
echo -e "\n${YELLOW}Applying performance optimizations...${NC}"
# Disable effects using available methods
if [ -n "$COMPOSITOR_KEY" ]; then
gsettings set $COMPOSITOR_KEY false 2>/dev/null && echo -e "${GREEN}✓ Compositor disabled${NC}"
else
# Alternative: disable effects
gsettings set org.cinnamon enable-effects false 2>/dev/null && echo -e "${GREEN}✓ Desktop effects disabled${NC}"
fi
# Set unredirect for fullscreen
gsettings set org.cinnamon.muffin unredirect-fullscreen-windows true 2>/dev/null && echo -e "${GREEN}✓ Fullscreen unredirect enabled${NC}"
# Alternative compositor control for Cinnamon
if command -v cinnamon-settings &> /dev/null; then
# Try to disable vsync through muffin dconf settings
dconf write /org/cinnamon/muffin/sync-to-vblank false 2>/dev/null
fi
# Set CPU governor to performance if available
if [ -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ]; then
echo -e "\n${YELLOW}Setting CPU to performance mode (may require password)${NC}"
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo -e "${GREEN}✓ CPU performance mode set${NC}"
fi
fi
# Launch OBS with optimized environment
echo -e "\n${GREEN}Launching OBS with optimized settings...${NC}"
echo "==========================================="
echo "Using command: $OBS_COMMAND"
# Run OBS with performance environment variables
env vblank_mode=0 \
__GL_SYNC_TO_VBLANK=0 \
__GL_THREADED_OPTIMIZATIONS=1 \
PULSE_LATENCY_MSEC=30 \
$OBS_COMMAND
# Restore original settings after OBS closes
echo -e "\n${YELLOW}OBS closed. Restoring original settings...${NC}"
if [ -n "$COMPOSITOR_KEY" ]; then
gsettings set $COMPOSITOR_KEY "$ORIGINAL_COMPOSITOR" 2>/dev/null
else
gsettings set org.cinnamon enable-effects true 2>/dev/null
fi
gsettings set org.cinnamon.muffin unredirect-fullscreen-windows "$ORIGINAL_UNREDIRECT" 2>/dev/null
# Restore vsync if it was modified
dconf write /org/cinnamon/muffin/sync-to-vblank true 2>/dev/null
echo -e "${GREEN}✓ Desktop settings restored${NC}"
echo -e "${GREEN}Done!${NC}"