Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script to backup and restore KDE configs. #102

Open
irthomasthomas opened this issue Oct 7, 2023 · 0 comments
Open

Script to backup and restore KDE configs. #102

irthomasthomas opened this issue Oct 7, 2023 · 0 comments
Labels
linux Linux notes tools links

Comments

@irthomasthomas
Copy link
Owner

irthomasthomas commented Oct 7, 2023

#!/bin/bash

# Backup function
backup_config_files() {
    backup_dir="backup_$(date +'%Y%m%d%H%M%S')"
    mkdir "$backup_dir"

    # Panel
    cp ~/.config/plasma-org.kde.plasma.desktop-appletsrc "$backup_dir"

    # Appearance
    # Global Theme
    cp ~/.config/kdeglobals "$backup_dir"
    cp ~/.config/kscreenlockerrc "$backup_dir"
    cp ~/.config/kwinrc "$backup_dir"
    cp ~/.config/gtkrc "$backup_dir"
    cp ~/.config/gtkrc-2.0 "$backup_dir"
    cp -R ~/.config/gtk-4.0 "$backup_dir"
    cp -R ~/.config/gtk-3.0 "$backup_dir"
    cp ~/.config/ksplashrc "$backup_dir"
    # Application Style
    cp ~/.config/kdeglobals "$backup_dir"
    # Plasma Style
    cp ~/.config/plasmarc "$backup_dir"
    # Colors
    cp ~/.config/kdeglobals "$backup_dir"
    cp ~/.config/Trolltech.conf "$backup_dir"
    # Window decorations
    cp ~/.config/breezerc "$backup_dir"
    cp ~/.config/kwinrc "$backup_dir"
    # Fonts
    cp ~/.config/kdeglobals "$backup_dir"
    cp ~/.config/kcmfonts "$backup_dir"
    # Icons
    cp ~/.config/kdeglobals "$backup_dir"
    # Cursors
    cp ~/.config/kcminputrc "$backup_dir"
    # Launch Feedback
    cp ~/.config/klaunchrc "$backup_dir"
    # Font management
    cp ~/.config/kfontinstuirc "$backup_dir"
    # Splash screen
    cp ~/.config/ksplashrc "$backup_dir"

    # Workspace
    # Desktop behavior
    # General behavior
    cp ~/.config/plasmarc "$backup_dir"
    # Screen Edges
    cp ~/.config/kwinrc "$backup_dir"
    # Desktop Effects
    cp ~/.config/kwinrc "$backup_dir"
    cp ~/.config/kglobalshortcutsrc "$backup_dir"
    # Touch screen
    # Screen Locking
    cp ~/.config/kscreenlockerrc "$backup_dir"
    # Virtual desktops
    # Activities
    cp ~/.config/kactivitymanagerdrc "$backup_dir"
    cp ~/.config/kactivitymanagerd-switcher "$backup_dir"
    cp ~/.config/kactivitymanagerd-statsrc "$backup_dir"
    cp ~/.config/kactivitymanagerd-pluginsrc "$backup_dir"
    cp ~/.config/kglobalshortcutsrc "$backup_dir"
    cp ~/.config/plasma-org.kde.plasma.desktop-appletsrc "$backup_dir"
    # Window Management
    # Window behavior
    cp ~/.config/kwinrc "$backup_dir"
    # Window Rules
    cp ~/.config/kwinrulesrc "$backup_dir"
    # Task switcher
    # KWin scripts
    cp ~/.config/kwinrc "$backup_dir"

    # Shortcuts
    # Custom Shortcuts
    cp ~/.config/khotkeysrc "$backup_dir"
    # Global Shortcuts
    cp ~/.config/kglobalshortcutsrc "$backup_dir"

    # Startup and Shutdown
    # Login screen
    # Autostart
    # Background Services
    cp ~/.config/kded5rc "$backup_dir"
    # Desktop Session
    cp ~/.config/ksmserverrc "$backup_dir"

    # Search
    # KRunner
    cp ~/.config/krunnerrc "$backup_dir"
    # File Search
    cp ~/.config/baloofilerc "$backup_dir"
    # Web Search Keywords

    # System Monitor
    # Page Settings
    cp -R ~/.local/share/plasma-systemmonitor "$backup_dir"

    # Personalization
    # Notifications
    cp ~/.config/plasmanotifyrc "$backup_dir"
    # Users
    # Regional Settings
    # Language
    # Formats
    cp ~/.config/plasma-localerc "$backup_dir"
    # Spell Check
    # Date & Time
    cp ~/.config/ktimezonedrc "$backup_dir"
    # Accessibility
    cp ~/.config/kaccessrc "$backup_dir"
    # Applications
    # File associations
    cp ~/.config/mimeapps.list "$backup_dir"
    # Locations
    # Launch Feedback
    # Default Applications
    cp ~/.config/mimeapps.list "$backup_dir"
    # KDE Wallet
    # Online Accounts
    # User Feedback
    cp ~/.config/PlasmaUserFeedback "$backup_dir"

    # Network
    # Connections
    sudo cp -R /etc/NetworkManager/system-connections "$backup_dir"
    # Settings
    # Proxy
    # Connection Preferences
    # SSL Preferences
    # Cache
    # Cookies
    # Browser Identification
    # Windows Shares

    # Hardware
    # Input Devices
    # Keyboard
    # Hardware
    cp ~/.config/kcminputrc "$backup_dir"
    # layout
    cp ~/.config/kxkbrc "$backup_dir"
    # Advanced
    cp ~/.config/kxkbrc "$backup_dir"
    # Mouse
    # Game Controller
    # Touchpad
    cp ~/.config/touchpadxlibinputrc "$backup_dir"
    cp ~/.config/kcminputrc "$backup_dir"
    # Display and Monitor
    # Compositor
    # Gamma
    cp ~/.config/kgammarc "$backup_dir"
    # Night Color
    cp ~/.config/kwinrc "$backup_dir"
    # Audio
    # Power Management
    # Energy Saving
    cp ~/.config/powermanagementprofilesrc "$backup_dir"
    # Bluetooth
    cp ~/.config/bluedevilglobalrc "$backup_dir"
    # KDE Connect
    cp -R ~/.config/kdeconnect "$backup_dir"
    # Removable Storage
    cp ~/.config/device_automounter_kcmrc "$backup_dir"
    cp ~/.config/kded5rc "$backup_dir"
    cp ~/.config/kded_device_automounterrc "$backup_dir"

    echo "Backup created in $backup_dir"
}

# Restore function
restore_config_files() {
    backup_dir=$1

    # Panel
    cp "$backup_dir"/plasma-org.kde.plasma.desktop-appletsrc ~/.config/

    # Appearance
    # Global Theme
    cp "$backup_dir"/kdeglobals ~/.config/
    cp "$backup_dir"/kscreenlockerrc ~/.config/
    cp "$backup_dir"/kwinrc ~/.config/
    cp "$backup_dir"/gtkrc ~/.config/
    cp "$backup_dir"/gtkrc-2.0 ~/.config/
    cp -R "$backup_dir"/gtk-4.0 ~/.config/
    cp -R "$backup_dir"/gtk-3.0 ~/.config/
    cp "$backup_dir"/ksplashrc ~/.config/
    # Application Style
    cp "$backup_dir"/kdeglobals ~/.config/
    # Plasma Style
    cp "$backup_dir"/plasmarc ~/.config/
    # Colors
    cp "$backup_dir"/kdeglobals ~/.config/
    cp "$backup_dir"/Trolltech.conf ~/.config/
    # Window decorations
    cp "$backup_dir"/breezerc ~/.config/
    cp "$backup_dir"/kwinrc ~/.config/
    # Fonts
    cp "$backup_dir"/kdeglobals ~/.config/
    cp "$backup_dir"/kcmfonts ~/.config/
    # Icons
    cp "$backup_dir"/kdeglobals ~/.config/
    # Cursors
    cp "$backup_dir"/kcminputrc ~/.config/
    # Launch Feedback
    cp "$backup_dir"/klaunchrc ~/.config/
    # Font management
    cp "$backup_dir"/kfontinstuirc ~/.config/
    # Splash screen
    cp "$backup_dir"/ksplashrc ~/.config/

    # Workspace
    # Desktop behavior
    # General behavior
    cp "$backup_dir"/plasmarc ~/.config/
    # Screen Edges
    cp "$backup_dir"/kwinrc ~/.config/
    # Desktop Effects
    cp "$backup_dir"/kwinrc ~/.config/
    cp "$backup_dir"/kglobalshortcutsrc ~/.config/
    # Touch screen
    # Screen Locking
    cp "$backup_dir"/kscreenlockerrc ~/.config/
    # Virtual desktops
    # Activities
    cp "$backup_dir"/kactivitymanagerdrc ~/.config/
    cp "$backup_dir"/kactivitymanagerd-switcher ~/.config/
    cp "$backup_dir"/kactivitymanagerd-statsrc ~/.config/
    cp "$backup_dir"/kactivitymanagerd-pluginsrc ~/.config/
    cp "$backup_dir"/kglobalshortcutsrc ~/.config/
    cp "$backup_dir"/plasma-org.kde.plasma.desktop-appletsrc ~/.config/
    # Window Management
    # Window behavior
    cp "$backup_dir"/kwinrc ~/.config/
    # Window Rules
    cp "$backup_dir"/kwinrulesrc ~/.config/
    # Task switcher
    # KWin scripts
    cp "$backup_dir"/kwinrc ~/.config/

    # Shortcuts
    # Custom Shortcuts
    cp "$backup_dir"/khotkeysrc ~/.config/
    # Global Shortcuts
    cp "$backup_dir"/kglobalshortcutsrc ~/.config/

    # Startup and Shutdown
    # Login screen
    # Autostart
    # Background Services
    cp "$backup_dir"/kded5rc ~/.config/
    # Desktop Session
    cp "$backup_dir"/ksmserverrc ~/.config/

    # Search
    # KRunner
    cp "$backup_dir"/krunnerrc ~/.config/
    # File Search
    cp "$backup_dir"/baloofilerc ~/.config/
    # Web Search Keywords

    # System Monitor
    # Page Settings
    cp -R "$backup_dir"/plasma-systemmonitor/* ~/.local/share/plasma-systemmonitor/

    # Personalization
    # Notifications
    cp "$backup_dir"/plasmanotifyrc ~/.config/
    # Users
    # Regional Settings
    # Language
    # Formats
    cp "$backup_dir"/plasma-localerc ~/.config/
    # Spell Check
    # Date & Time
    cp "$backup_dir"/ktimezonedrc ~/.config/
    # Accessibility
    cp "$backup_dir"/kaccessrc ~/.config/
    # Applications
    # File associations
    cp "$backup_dir"/mimeapps.list ~/.config/
    # Locations
    # Launch Feedback
    # Default Applications
    cp "$backup_dir"/mimeapps.list ~/.config/
    # KDE Wallet
    # Online Accounts
    # User Feedback
    cp "$backup_dir"/PlasmaUserFeedback ~/.config/

    # Network
    # Connections
    sudo cp -R "$backup_dir"/system-connections /etc/NetworkManager/
    # Settings
    # Proxy
    # Connection Preferences
    # SSL Preferences
    # Cache
    # Cookies
    # Browser Identification
    # Windows Shares

    # Hardware
    # Input Devices
    # Keyboard
    # Hardware
    cp "$backup_dir"/kcminputrc ~/.config/
    # layout
    cp "$backup_dir"/kxkbrc ~/.config/
    # Advanced
    cp "$backup_dir"/kxkbrc ~/.config/
    # Mouse
    # Game Controller
    # Touchpad
    cp "$backup_dir"/touchpadxlibinputrc ~/.config/
    cp "$backup_dir"/kcminputrc ~/.config/
    # Display and Monitor
    # Compositor
    # Gamma
    cp "$backup_dir"/kgammarc ~/.config/
    # Night Color
    cp "$backup_dir"/kwinrc ~/.config/
    # Audio
    # Power Management
    # Energy Saving
    cp "$backup_dir"/powermanagementprofilesrc ~/.config/
    # Bluetooth
    cp "$backup_dir"/bluedevilglobalrc ~/.config/
    # KDE Connect
    cp -R "$backup_dir"/kdeconnect ~/.config/
    # Removable Storage
    cp "$backup_dir"/device_automounter_kcmrc ~/.config/
    cp "$backup_dir"/kded5rc ~/.config/
    cp "$backup_dir"/kded_device_automounterrc ~/.config/

    echo "Config files restored from $backup_dir"
}

# Main menu
echo "Welcome to KDE config backup and restore script"
echo "Please select an option:"
echo "1. Backup config files"
echo "2. Restore config files"
echo "3. Exit"
read -p "Enter your choice: " choice

case $choice in
    1)
        backup_config_files
        ;;
    2)
        read -p "Enter the directory name of the backup: " backup_dir
        restore_config_files "$backup_dir"
        ;;
    3)
        exit 0
        ;;
    *)
        echo "Invalid choice. Exiting..."
        exit 1
        ;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linux Linux notes tools links
Projects
None yet
Development

No branches or pull requests

1 participant