Added configurable python script
This commit is contained in:
parent
3f86d47e45
commit
a10a8aa4ca
|
@ -1,17 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
echo Installing dotfiles...
|
|
||||||
|
|
||||||
# Get current directory
|
|
||||||
wd=$(dirname -- $(dirname -- $( readlink -f -- $0; ); );)
|
|
||||||
|
|
||||||
# Bash
|
|
||||||
ln -sf $wd/bash/.bash_logout $HOME/
|
|
||||||
ln -sf $wd/bash/.profile $HOME/
|
|
||||||
ln -sf $wd/bash/.bashrc $HOME/
|
|
||||||
|
|
||||||
# Etc
|
|
||||||
ln -sf $wd/etc/.selected_editor $HOME/
|
|
||||||
|
|
||||||
# Git
|
|
||||||
ln -sf $wd/git/.gitconfig $HOME/
|
|
|
@ -1,10 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
echo Importing GNOME configuration...
|
|
||||||
|
|
||||||
# Get current directory
|
|
||||||
wd=$(dirname -- $(dirname -- $( readlink -f -- $0; ); );)
|
|
||||||
|
|
||||||
dconf load /org/gnome/shell/extensions/dash-to-panel/ < $wd/gnome/extensions/dash-to-panel.dconf
|
|
||||||
dconf load /org/gnome/shell/extensions/cpupower/ < $wd/gnome/extensions/cpupower.dconf
|
|
||||||
|
|
8
_scripts/gnome-install-extension.sh
Executable file
8
_scripts/gnome-install-extension.sh
Executable file
|
@ -0,0 +1,8 @@
|
||||||
|
VERSION_TAG=$(curl -Lfs "https://extensions.gnome.org/extension-query/?search=$1" | jq '.extensions[0] | .shell_version_map | map(.pk) | max')
|
||||||
|
wget -O $1.zip "https://extensions.gnome.org/download-extension/$1.shell-extension.zip?version_tag=$VERSION_TAG" -q
|
||||||
|
gnome-extensions install --force $1.zip -q
|
||||||
|
if ! gnome-extensions list | grep --quiet $1; then
|
||||||
|
busctl --user call org.gnome.Shell.Extensions /org/gnome/Shell/Extensions org.gnome.Shell.Extensions InstallRemoteExtension s $1
|
||||||
|
fi
|
||||||
|
gnome-extensions enable $1
|
||||||
|
rm $1.zip
|
|
@ -1,17 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
echo Installing GNOME extensions...
|
|
||||||
|
|
||||||
array=( cpupower@mko-sl.de dash-to-panel@jderose9.github.com )
|
|
||||||
|
|
||||||
for i in "${array[@]}"
|
|
||||||
do
|
|
||||||
VERSION_TAG=$(curl -Lfs "https://extensions.gnome.org/extension-query/?search=${i}" | jq '.extensions[0] | .shell_version_map | map(.pk) | max')
|
|
||||||
wget -O ${i}.zip "https://extensions.gnome.org/download-extension/${i}.shell-extension.zip?version_tag=$VERSION_TAG"
|
|
||||||
gnome-extensions install --force ${i}.zip
|
|
||||||
if ! gnome-extensions list | grep --quiet ${i}; then
|
|
||||||
busctl --user call org.gnome.Shell.Extensions /org/gnome/Shell/Extensions org.gnome.Shell.Extensions InstallRemoteExtension s ${i}
|
|
||||||
fi
|
|
||||||
gnome-extensions enable ${i}
|
|
||||||
rm ${i}.zip
|
|
||||||
done
|
|
74
_scripts/import.py
Executable file
74
_scripts/import.py
Executable file
|
@ -0,0 +1,74 @@
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import yaml
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
cwd = Path(__file__).parent.parent
|
||||||
|
|
||||||
|
variables = {
|
||||||
|
"$home": str(Path.home())
|
||||||
|
}
|
||||||
|
|
||||||
|
def replace_variables(string: str):
|
||||||
|
for variable in variables:
|
||||||
|
string = string.replace(variable, variables[variable])
|
||||||
|
return string
|
||||||
|
|
||||||
|
def get_files(folder: Path, files: list[str]) -> set[Path]:
|
||||||
|
result = set()
|
||||||
|
for file in files:
|
||||||
|
if not (folder / file).exists():
|
||||||
|
for d in (folder).glob(file):
|
||||||
|
result.add(d)
|
||||||
|
else:
|
||||||
|
result.add(folder / file)
|
||||||
|
return result
|
||||||
|
|
||||||
|
# Setup dotfiles
|
||||||
|
|
||||||
|
def set_dotfiles(folder: str, config: dict):
|
||||||
|
all_files = set()
|
||||||
|
for where in config:
|
||||||
|
files = get_files(cwd / folder, config[where]).difference(all_files)
|
||||||
|
for file in files:
|
||||||
|
where_file = Path(replace_variables(where)) / file.relative_to(cwd / folder)
|
||||||
|
if where_file.exists():
|
||||||
|
where_file.unlink()
|
||||||
|
where_file.symlink_to(file)
|
||||||
|
all_files.update(files)
|
||||||
|
|
||||||
|
# Install GNOME extensions
|
||||||
|
|
||||||
|
def install_gnome_extension(ext):
|
||||||
|
p = subprocess.Popen(f"{cwd / '_scripts' / 'gnome-install-extension.sh'} {ext}", shell=True)
|
||||||
|
p.wait()
|
||||||
|
|
||||||
|
# Import GNOME settings
|
||||||
|
|
||||||
|
def import_gnome_config(file: str, path: str):
|
||||||
|
dconf = cwd / "gnome" / (file+".dconf");
|
||||||
|
p = subprocess.Popen(f"dconf load {path} < {dconf}", shell=True)
|
||||||
|
p.wait()
|
||||||
|
|
||||||
|
dotfiles = cwd / "dotfiles.yml"
|
||||||
|
if dotfiles.exists():
|
||||||
|
config = yaml.safe_load(dotfiles.read_text())
|
||||||
|
if config:
|
||||||
|
print("Installing dotfiles...")
|
||||||
|
for folder in config:
|
||||||
|
print(f" - {folder}")
|
||||||
|
set_dotfiles(folder, config[folder])
|
||||||
|
|
||||||
|
gnome = cwd / "gnome.yml"
|
||||||
|
if gnome.exists():
|
||||||
|
config = yaml.safe_load(gnome.read_text())
|
||||||
|
if "extensions" in config:
|
||||||
|
print("Installing GNOME extensions...")
|
||||||
|
for ext in config["extensions"]:
|
||||||
|
print(f" - {ext}")
|
||||||
|
install_gnome_extension(ext)
|
||||||
|
if "import" in config:
|
||||||
|
print("Importing GNOME settings...")
|
||||||
|
for file in config["import"]:
|
||||||
|
print(f" - {file}")
|
||||||
|
import_gnome_config(file, config["import"][file])
|
|
@ -1,5 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
echo Installing applications...
|
|
||||||
|
|
||||||
flatpak install com.mattjakeman.ExtensionManager
|
|
|
@ -25,4 +25,3 @@ fi
|
||||||
if [ -d "$HOME/.local/bin" ] ; then
|
if [ -d "$HOME/.local/bin" ] ; then
|
||||||
PATH="$HOME/.local/bin:$PATH"
|
PATH="$HOME/.local/bin:$PATH"
|
||||||
fi
|
fi
|
||||||
. "$HOME/.cargo/env"
|
|
||||||
|
|
11
dotfiles.yml
Executable file
11
dotfiles.yml
Executable file
|
@ -0,0 +1,11 @@
|
||||||
|
bash:
|
||||||
|
$home:
|
||||||
|
- .bashrc
|
||||||
|
- .bash_logout
|
||||||
|
- .profile
|
||||||
|
etc:
|
||||||
|
$home:
|
||||||
|
- "*"
|
||||||
|
git:
|
||||||
|
$home:
|
||||||
|
- .gitconfig
|
Loading…
Reference in a new issue