This commit is contained in:
Stephan Raabe
2024-03-07 15:51:34 +01:00
parent 1fe8a3bc7a
commit f3cc851979
99 changed files with 280 additions and 1423 deletions
+5
View File
@@ -16,4 +16,9 @@ fi
sed -i "s|HOME|${HOME}|g" $HOME/dotfiles/apps/ml4w-welcome.desktop
cp $HOME/dotfiles/apps/ml4w-welcome.desktop $HOME/.local/share/applications
echo ":: ML4W Welcome App installed successfully"
sed -i "s|HOME|${HOME}|g" $HOME/dotfiles/apps/ml4w-dotfiles-settings.desktop
cp $HOME/dotfiles/apps/ml4w-dotfiles-settings.desktop $HOME/.local/share/applications
echo ":: ML4W Dotfiles Settings App installed successfully"
echo
+3 -23
View File
@@ -31,29 +31,9 @@ else
echo "bluetooth.service activated successfully."
fi
if [ -d ~/dotfiles/hypr/settings/modules/waybar/defaults ] ;then
rm -rf ~/dotfiles/hypr/settings/modules/waybar/defaults
echo "~/dotfiles/hypr/settings/modules/waybar/defaults removed."
fi
if [ -d ~/dotfiles/hypr/settings/modules/sddm ] ;then
rm -rf ~/dotfiles/hypr/settings/modules/sddm
echo "~/dotfiles/hypr/settings/modules/sddm removed."
fi
if [ -d ~/dotfiles/hypr/settings/modules/appearance/wallpaper ] ;then
rm -rf ~/dotfiles/hypr/settings/modules/appearance/wallpaper
echo "~/dotfiles/hypr/settings/modules/appearance/wallpaper removed."
fi
if [ -d ~/dotfiles/hypr/settings/modules/system/swaylock ] ;then
rm -rf ~/dotfiles/hypr/settings/modules/system/swaylock
echo "~/dotfiles/hypr/settings/modules/system/swaylock removed."
fi
if [ -d ~/dotfiles/hypr/settings/modules/waybar/bluetooth ] ;then
rm -rf ~/dotfiles/hypr/settings/modules/waybar/bluetooth
echo "~/dotfiles/hypr/settings/modules/waybar/bluetooth removed."
if [ -d ~/dotfiles/hypr/settings/ ] ;then
rm -rf ~/dotfiles/hypr/settings
echo "~/dotfiles/hypr/settings removed."
fi
# Create default folder structure
+1 -1
View File
@@ -8,7 +8,7 @@ echo ""
# Check for required packages
echo ":: Checking that required packages for the installation are installed..."
_installPackagesPacman "rsync" "gum" "figlet";
_installPackagesPacman "rsync" "gum" "figlet" "python";
echo ""
# Double check rsync
+153
View File
@@ -0,0 +1,153 @@
# __ __ _ _ ___ __ _
# | \/ | | | || \ \ / / _ __ ___ ___| |_ ___ _ __ ___
# | |\/| | | | || |\ \ /\ / / | '__/ _ \/ __| __/ _ \| '__/ _ \
# | | | | |__|__ _\ V V / | | | __/\__ \ || (_) | | | __/
# |_| |_|_____| |_| \_/\_/ |_| \___||___/\__\___/|_| \___|
#
import sys
import subprocess
import os
import json
import pathlib
import shutil
# Get script path
pathname = os.path.dirname(sys.argv[0])
class ML4WRestore:
waybar_themes = [
"ml4w-minimal",
"ml4w",
"ml4w-blur",
"ml4w-blur-bottom",
"ml4w-bottom"
]
defaults = {
"waybar_timeformat": "%H:%M",
"waybar_dateformat": "%a",
"waybar_custom_timedateformat": "",
"waybar_workspaces": 5,
"rofi_bordersize": 3,
"waybar_toggle": True,
"waybar_network": True,
"waybar_chatgpt": True,
"waybar_systray": True,
"waybar_screenlock": True,
"waybar_window": True,
"hypridle_hyprlock_timeout": 600,
"hypridle_dpms_timeout": 680,
"hypridle_suspend_timeout": 1800
}
path_name = pathname # Path of Application
homeFolder = os.path.expanduser('~') # Path to home folder
dotfiles = homeFolder + "/dotfiles/"
settings = {}
def __init__(self):
# Load settings.json
settings_file = open(self.dotfiles + ".settings/settings.json")
settings_arr = json.load(settings_file)
for row in settings_arr:
self.settings[row["key"]] = row["value"]
self.loadSwitchAll("waybar_network","network")
self.loadSwitchAll("waybar_systray","tray")
self.loadSwitchAll("waybar_window","hyprland/window")
self.loadSwitchAll("waybar_screenlock","idle_inhibitor")
self.loadSwitch("waybar_chatgpt","custom/chatgpt")
# Waybar Workspaces
if "waybar_workspaces" in self.settings:
value = int(self.settings["waybar_workspaces"])
text = ' "*": ' + str(value)
self.replaceInFileNext("waybar/modules.json", "// START WORKSPACES", text)
print (":: waybar_workspaces restored")
# Rofi BorderSize
if "rofi_bordersize" in self.settings:
value = int(self.settings["rofi_bordersize"])
text = "* { border-width: " + str(value) + "px; }"
self.overwriteFile(".settings/rofi-border.rasi",text)
print (":: rofi_bordersize restored")
# Time/DateFormat
if "waybar_timeformat" in self.settings:
timeformat = self.settings["waybar_timeformat"]
else:
timeformat = self.defaults["waybar_timeformat"]
if "waybar_dateformat" in self.settings:
dateformat = self.settings["waybar_dateformat"]
else:
dateformat = self.defaults["waybar_dateformat"]
if "waybar_custom_timedateformat" in self.settings:
custom_format = self.settings["waybar_custom_timedateformat"]
else:
custom_format = self.defaults["waybar_custom_timedateformat"]
if custom_format != "":
timedate = ' "format": "{:' + custom_format + '}",'
self.replaceInFileNext("waybar/modules.json", "TIMEDATEFORMAT", timedate)
else:
timedate = ' "format": "{:' + timeformat + ' - ' + dateformat + '}",'
self.replaceInFileNext("waybar/modules.json", "TIMEDATEFORMAT", timedate)
print (":: timedate format restored")
def loadSwitch(self,k,m):
if k in self.settings:
if not self.settings[k]:
self.replaceInFile("waybar/modules.json",'"' + m + '"',' //"' + m + '",')
print (":: " + k + " restored")
def loadSwitchAll(self,k,m):
if k in self.settings:
if not self.settings[k]:
for t in self.waybar_themes:
self.replaceInFile("waybar/themes/" + t + "/config",'"' + m + '"',' //"' + m + '",')
print (":: " + k + " restored")
# Overwrite Text in File
def overwriteFile(self, f, text):
file=open(self.dotfiles + f,"w+")
file.write(text)
file.close()
# Replace Text in File
def replaceInFile(self, f, search, replace):
file = open(self.dotfiles + f, 'r')
lines = file.readlines()
count = 0
found = 0
# Strips the newline character
for l in lines:
count += 1
if search in l:
found = count
if found > 0:
lines[found - 1] = replace + "\n"
with open(self.dotfiles + f, 'w') as file:
file.writelines(lines)
# Replace Text in File
def replaceInFileNext(self, f, search, replace):
file = open(self.dotfiles + f, 'r')
lines = file.readlines()
count = 0
found = 0
# Strips the newline character
for l in lines:
count += 1
if search in l:
found = count
if found > 0:
lines[found] = replace + "\n"
with open(self.dotfiles + f, 'w') as file:
file.writelines(lines)
ml4wrestore = ML4WRestore()
+13 -137
View File
@@ -102,74 +102,74 @@ _startRestore() {
if [[ $restoreselect == *"~/dotfiles/.bashrc"* ]] || [[ $restoreselect == *"All"* ]] ; then
if [ -f ~/dotfiles/.bashrc ]; then
cp ~/dotfiles/.bashrc ~/dotfiles-versions/$version/
echo ".bashrc restored!"
echo ":: .bashrc restored!"
fi
fi
if [[ $restoreselect == *"~/dotfiles/.settings"* ]] || [[ $restoreselect == *"All"* ]] ; then
if [ -d ~/dotfiles/.settings ]; then
rsync -a -I ~/dotfiles/.settings/ ~/dotfiles-versions/$version/.settings/
echo ".settings restored!"
echo ":: .settings restored!"
fi
fi
if [[ $profile == *"Hyprland"* ]]; then
if [[ $restoreselect == *"~/dotfiles/hypr/hypridle.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then
if [ -f ~/dotfiles/hypr/hypridle.conf ]; then
cp ~/dotfiles/hypr/hypridle.conf ~/dotfiles-versions/$version/hypr/
echo "Hyprland hypridle.conf restored!"
echo ":: Hyprland hypridle.conf restored!"
fi
fi
if [[ $restoreselect == *"~/dotfiles/hypr/conf/custom.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then
if [ -f ~/dotfiles/hypr/conf/custom.conf ]; then
cp ~/dotfiles/hypr/conf/custom.conf ~/dotfiles-versions/$version/hypr/conf/
echo "Hyprland custom.conf restored!"
echo ":: Hyprland custom.conf restored!"
fi
fi
if [[ $restoreselect == *"~/dotfiles/hypr/conf/keyboard.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then
if [ -f ~/dotfiles/hypr/conf/keyboard.conf ]; then
cp ~/dotfiles/hypr/conf/keyboard.conf ~/dotfiles-versions/$version/hypr/conf/
echo "Hyprland keyboard.conf restored!"
echo ":: Hyprland keyboard.conf restored!"
fi
fi
if [[ $restoreselect == *"~/dotfiles/hypr/conf/monitor.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then
if [ -f ~/dotfiles/hypr/conf/monitor.conf ]; then
cp ~/dotfiles/hypr/conf/monitor.conf ~/dotfiles-versions/$version/hypr/conf/
echo "Hyprland monitor.conf restored!"
echo ":: Hyprland monitor.conf restored!"
fi
fi
if [[ $restoreselect == *"~/dotfiles/hypr/conf/keybinding.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then
if [ -f ~/dotfiles/hypr/conf/keybinding.conf ]; then
cp ~/dotfiles/hypr/conf/keybinding.conf ~/dotfiles-versions/$version/hypr/conf/
echo "Hyprland keybinding.conf restored!"
echo ":: Hyprland keybinding.conf restored!"
fi
fi
if [[ $restoreselect == *"~/dotfiles/hypr/conf/environment.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then
if [ -f ~/dotfiles/hypr/conf/environment.conf ]; then
cp ~/dotfiles/hypr/conf/environment.conf ~/dotfiles-versions/$version/hypr/conf/
echo "Hyprland environment.conf restored!"
echo ":: Hyprland environment.conf restored!"
fi
fi
if [[ $restoreselect == *"~/dotfiles/hypr/conf/windowrule.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then
if [ -f ~/dotfiles/hypr/conf/windowrule.conf ]; then
cp ~/dotfiles/hypr/conf/windowrule.conf ~/dotfiles-versions/$version/hypr/conf/
echo "Hyprland windowrule.conf restored!"
echo ":: Hyprland windowrule.conf restored!"
fi
fi
if [[ $restoreselect == *"~/dotfiles/hypr/conf/animation.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then
if [ -f ~/dotfiles/hypr/conf/animation.conf ]; then
cp ~/dotfiles/hypr/conf/animation.conf ~/dotfiles-versions/$version/hypr/conf/
echo "Hyprland animation.conf restored!"
echo ":: Hyprland animation.conf restored!"
fi
fi
if [[ $restoreselect == *"~/dotfiles/hypr/conf/decoration.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then
if [ -f ~/dotfiles/hypr/conf/decoration.conf ]; then
cp ~/dotfiles/hypr/conf/decoration.conf ~/dotfiles-versions/$version/hypr/conf/
echo "Hyprland decoration.conf restored!"
echo ":: Hyprland decoration.conf restored!"
fi
fi
if [[ $restoreselect == *"~/dotfiles/hypr/conf/window.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then
if [ -f ~/dotfiles/hypr/conf/window.conf ]; then
cp ~/dotfiles/hypr/conf/window.conf ~/dotfiles-versions/$version/hypr/conf/
echo "Hyprland window.conf restored!"
echo ":: Hyprland window.conf restored!"
fi
fi
fi
@@ -177,7 +177,7 @@ _startRestore() {
if [[ $restoreselect == *"~/dotfiles/qtile/autostart.sh"* ]] || [[ $restoreselect == *"All"* ]] ; then
if [ -f ~/dotfiles/qtile/autostart.sh ]; then
cp ~/dotfiles/qtile/autostart.sh ~/dotfiles-versions/$version/qtile/
echo "Qtile autostart.sh restored!"
echo ":: Qtile autostart.sh restored!"
fi
fi
fi
@@ -195,130 +195,6 @@ echo -e "${NONE}"
echo "PLEASE NOTE: Restoring is not possible with version < 2.6 of the dotfiles."
echo "In that case, please use the automated backup or create your own backup manually."
echo ""
_showRestoreOptions
# Restore Waybar Workspaces
targetFile="$HOME/dotfiles-versions/$version/waybar/modules.json"
settingsFile="$HOME/dotfiles/.settings/waybar_workspaces"
if [ -f $settingsFile ] ;then
startMarker="START WORKSPACE"
endMarker="END WORKSPACES"
customtext="$(cat $settingsFile)"
_replaceInFile "$startMarker" "$endMarker" "$customtext" "$targetFile"
echo "Waybar Workspaces restored."
fi
# Restore Waybar Appslabel
targetFile="$HOME/dotfiles-versions/$version/waybar/modules.json"
settingsFile="$HOME/dotfiles/.settings/waybar_appslabel"
if [ -f $settingsFile ] ;then
startMarker="START APPS LABEL"
endMarker="END APPS LABEL"
customtext="$(cat $settingsFile)"
_replaceInFile "$startMarker" "$endMarker" "$customtext" "$targetFile"
echo "Waybar Appslabel restored."
fi
# Restore Waybar ChatGPT
targetFile="$HOME/dotfiles/waybar/modules.json"
settingsFile="$HOME/dotfiles/.settings/waybar_chatgpt"
if [ -f $settingsFile ] ;then
startMarker="START CHATGPT TOOGLE"
endMarker="END CHATGPT TOOGLE"
customtext="$(cat $settingsFile)"
_replaceInFile "$startMarker" "$endMarker" "$customtext" "$targetFile"
echo "Waybar ChatGPT restored."
fi
# Restore Waybar Systray
targetFile1="$HOME/dotfiles-versions/$version/waybar/themes/ml4w/config"
targetFile2="$HOME/dotfiles-versions/$version/waybar/themes/ml4w-blur/config"
targetFile3="$HOME/dotfiles-versions/$version/waybar/themes/ml4w-blur-bottom/config"
targetFile4="$HOME/dotfiles-versions/$version/waybar/themes/ml4w-bottom/config"
targetFile5="$HOME/dotfiles-versions/$version/waybar/themes/ml4w-minimal/config"
settingsFile="$HOME/dotfiles/.settings/waybar_systray"
if [ -f $settingsFile ] ;then
startMarker="START TRAY TOOGLE"
endMarker="END TRAY TOOGLE"
customtext="$(cat $settingsFile)"
_replaceInFile "$startMarker" "$endMarker" "$customtext" "$targetFile1"
_replaceInFile "$startMarker" "$endMarker" "$customtext" "$targetFile2"
_replaceInFile "$startMarker" "$endMarker" "$customtext" "$targetFile3"
_replaceInFile "$startMarker" "$endMarker" "$customtext" "$targetFile4"
_replaceInFile "$startMarker" "$endMarker" "$customtext" "$targetFile5"
echo "Waybar Systray restored."
fi
# Restore Waybar Network
targetFile1="$HOME/dotfiles-versions/$version/waybar/themes/ml4w/config"
targetFile2="$HOME/dotfiles-versions/$version/waybar/themes/ml4w-blur/config"
targetFile3="$HOME/dotfiles-versions/$version/waybar/themes/ml4w-blur-bottom/config"
targetFile4="$HOME/dotfiles-versions/$version/waybar/themes/ml4w-bottom/config"
targetFile5="$HOME/dotfiles-versions/$version/waybar/themes/ml4w-minimal/config"
settingsFile="$HOME/dotfiles/.settings/waybar_network"
if [ -f $settingsFile ] ;then
startMarker="START NETWORK TOOGLE"
endMarker="END NETWORK TOOGLE"
customtext="$(cat $settingsFile)"
_replaceInFile "$startMarker" "$endMarker" "$customtext" "$targetFile1"
_replaceInFile "$startMarker" "$endMarker" "$customtext" "$targetFile2"
_replaceInFile "$startMarker" "$endMarker" "$customtext" "$targetFile3"
_replaceInFile "$startMarker" "$endMarker" "$customtext" "$targetFile4"
_replaceInFile "$startMarker" "$endMarker" "$customtext" "$targetFile5"
echo "Waybar Network restored."
fi
# Restore Waybar Idle
targetFile1="$HOME/dotfiles/waybar/themes/ml4w/config"
targetFile2="$HOME/dotfiles/waybar/themes/ml4w-blur/config"
targetFile3="$HOME/dotfiles/waybar/themes/ml4w-blur-bottom/config"
targetFile4="$HOME/dotfiles/waybar/themes/ml4w-bottom/config"
targetFile5="$HOME/dotfiles-versions/$version/waybar/themes/ml4w-minimal/config"
settingsFile="$HOME/dotfiles/.settings/waybar_swaylock"
if [ -f $settingsFile ] ;then
startMarker="START IDLE TOOGLE"
endMarker="END IDLE TOOGLE"
customtext="$(cat $settingsFile)"
_replaceInFile "$startMarker" "$endMarker" "$customtext" "$targetFile1"
_replaceInFile "$startMarker" "$endMarker" "$customtext" "$targetFile2"
_replaceInFile "$startMarker" "$endMarker" "$customtext" "$targetFile3"
_replaceInFile "$startMarker" "$endMarker" "$customtext" "$targetFile4"
_replaceInFile "$startMarker" "$endMarker" "$customtext" "$targetFile5"
echo "Waybar Idle restored."
fi
# Restore Waybar nmapplet
targetFile="$HOME/dotfiles-versions/$version/hypr/conf/autostart.conf"
settingsFile="$HOME/dotfiles/.settings/waybar_nmapplet"
if [ -f $settingsFile ] ;then
startMarker="START NM APPLET"
endMarker="END NM APPLET"
customtext="$(cat $settingsFile)"
_replaceInFile "$startMarker" "$endMarker" "$customtext" "$targetFile"
echo "nm-applet restored."
fi
# Restore Keyboard natural_scroll
targetFile="$HOME/dotfiles-versions/$version/hypr/conf/keyboard.conf"
settingsFile="$HOME/dotfiles/.settings/keyboard_naturalscroll"
if [ -f $settingsFile ] ;then
findMarker="natural_scroll"
customtext="$(cat $settingsFile)"
_replaceLineInFile "$findMarker" "$customtext" "$targetFile"
echo "keyboard natural_scroll restored."
fi
# Restore Start Swaylock
targetFile="$HOME/dotfiles/hypr/scripts/lockscreentime.sh"
settingsFile="$HOME/dotfiles/.settings/hypr_lockscreen"
if [ -f $settingsFile ] ;then
startMarker="START SWAYIDLE"
endMarker="END SWAYIDLE"
customtext="$(cat $settingsFile)"
_replaceInFile "$startMarker" "$endMarker" "$customtext" "$targetFile"
echo "Swaylock start restored."
fi
echo ""
fi
+4
View File
@@ -0,0 +1,4 @@
echo -e "${GREEN}"
figlet "Restore Settings"
echo -e "${NONE}"
python .install/restore.py