mirror of
https://github.com/Paul-Houser/StartTree.git
synced 2024-11-24 16:23:16 +01:00
init.py is now a bash script: init.sh
This commit is contained in:
parent
a5150b7c0b
commit
b05b6cda4d
@ -24,7 +24,9 @@ To install StartTree for the first time, run the following commands:
|
|||||||
```
|
```
|
||||||
git clone https://github.com/Paul-Houser/StartTree.git
|
git clone https://github.com/Paul-Houser/StartTree.git
|
||||||
cd StartTree
|
cd StartTree
|
||||||
./init.py
|
chmod +x init.sh
|
||||||
|
chmod +x generate.py
|
||||||
|
./init.sh
|
||||||
./generate.py
|
./generate.py
|
||||||
```
|
```
|
||||||
This will create the directory `~/.config/StartTree` containing the default `config.yaml`, as well as generate the html/css, which you can view by pointing your browser at `$HOME/.cache/StartTree/index.html`.
|
This will create the directory `~/.config/StartTree` containing the default `config.yaml`, as well as generate the html/css, which you can view by pointing your browser at `$HOME/.cache/StartTree/index.html`.
|
||||||
|
72
init.py
72
init.py
@ -1,72 +0,0 @@
|
|||||||
#!/bin/python3
|
|
||||||
|
|
||||||
import yaml
|
|
||||||
import os
|
|
||||||
from os.path import expanduser
|
|
||||||
from shutil import copyfile
|
|
||||||
from bs4 import BeautifulSoup
|
|
||||||
import sys
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
# Install dependencies
|
|
||||||
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'bs4'])
|
|
||||||
|
|
||||||
# get home directory
|
|
||||||
home = expanduser("~")
|
|
||||||
|
|
||||||
# get config path
|
|
||||||
config_dir = home + '/.config/StartTree'
|
|
||||||
config_path = home + '/.config/StartTree/config.yaml'
|
|
||||||
|
|
||||||
# get cache path
|
|
||||||
cache_dir = home + '/.cache/StartTree'
|
|
||||||
|
|
||||||
def setup():
|
|
||||||
# check if .config path exists
|
|
||||||
if not os.path.isdir(home + '/.config'):
|
|
||||||
print("The directory '~/.config' does not exist, or you do not have permissions to edit it.")
|
|
||||||
exit()
|
|
||||||
|
|
||||||
if not os.path.isdir(home + '/.cache'):
|
|
||||||
print("The directory '~/.cache' does not exist, or you do not have permissions to edit it.")
|
|
||||||
exit()
|
|
||||||
|
|
||||||
# check if .config/StartTree exists, create it and config if not
|
|
||||||
if not os.path.isdir(config_dir):
|
|
||||||
print("Creating '~/.config/StartTree'...")
|
|
||||||
os.mkdir(config_dir)
|
|
||||||
print("Copying config.yaml")
|
|
||||||
copyfile("./config.yaml", config_path)
|
|
||||||
print("")
|
|
||||||
|
|
||||||
# check if config.yaml exists
|
|
||||||
if not os.path.exists(config_path):
|
|
||||||
print("No config.yaml found in '~/.config/StartTree'")
|
|
||||||
print("Copy the example config with:")
|
|
||||||
print("\tcp ./config.yaml $HOME/.config/StartTree/config.yaml")
|
|
||||||
print("or create your own in that directory.")
|
|
||||||
exit()
|
|
||||||
|
|
||||||
# create directory structure in .cache
|
|
||||||
if not os.path.isdir(cache_dir):
|
|
||||||
print("Creating '" + cache_dir + "'...")
|
|
||||||
os.mkdir(cache_dir)
|
|
||||||
|
|
||||||
print("symlinking themes")
|
|
||||||
os.symlink(os.getcwd() + '/themes', home + '/.cache/StartTree/themes')
|
|
||||||
|
|
||||||
print("Creating '" + cache_dir + "/styles'")
|
|
||||||
os.mkdir(cache_dir + '/styles')
|
|
||||||
|
|
||||||
print("Creating style.css")
|
|
||||||
copyfile("./skeletons/style.css", cache_dir + '/styles/style.css')
|
|
||||||
|
|
||||||
print("Creating Hack.ttf")
|
|
||||||
copyfile("./skeletons/Hack.ttf", cache_dir + '/styles/Hack.ttf')
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
setup()
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
55
init.sh
Executable file
55
init.sh
Executable file
@ -0,0 +1,55 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
config_dir=$HOME/.config/StartTree
|
||||||
|
config_path=$HOME/.config/StartTree/config.yaml
|
||||||
|
cache_dir=$HOME/.cache/StartTree
|
||||||
|
|
||||||
|
pip install --user bs4
|
||||||
|
|
||||||
|
# check if .config path exists
|
||||||
|
if [ ! -d "$HOME/.config" ]; then
|
||||||
|
echo "The directory '~/.config' does not exist, or you do not have permissions to edit it."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check if .cache path exists
|
||||||
|
if [ ! -d "$HOME/.cache" ]; then
|
||||||
|
echo "The directory '~/.cache' does not exist, or you do not have permissions to edit it."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check if .config/StartTree exists, create it and config if not
|
||||||
|
if [ ! -d "$config_dir" ]; then
|
||||||
|
echo "Creating '~/.config/StartTree'..."
|
||||||
|
mkdir $config_dir
|
||||||
|
echo "Copying config.yaml..."
|
||||||
|
cp ./config.yaml $config_path
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check if config.yaml exists
|
||||||
|
if [ ! -f "$config_path" ]; then
|
||||||
|
echo "No config.yaml found in '~/.config/StartTree'"
|
||||||
|
echo "Copy the example config with:"
|
||||||
|
echo "\tcp ./config.yaml $HOME/.config/StartTree/config.yaml"
|
||||||
|
echo "or create your own in that directory."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# create directory structure in .cache
|
||||||
|
if [ ! -d "$cache_dir" ]; then
|
||||||
|
echo "Creating '$cache_dir'..."
|
||||||
|
mkdir $cache_dir
|
||||||
|
|
||||||
|
echo "Symlinking themes..."
|
||||||
|
ln -s $(pwd)/themes $HOME/.cache/StartTree/themes
|
||||||
|
|
||||||
|
echo "Creating '$cache_dir/styles'..."
|
||||||
|
mkdir "$cache_dir/styles"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Creating style.css..."
|
||||||
|
cp "./skeletons/style.css" "$cache_dir/styles/style.css"
|
||||||
|
|
||||||
|
echo "Creating Hack.ttf..."
|
||||||
|
cp "./skeletons/Hack.ttf" "$cache_dir/styles/Hack.ttf"
|
Loading…
Reference in New Issue
Block a user