Skip to content

Commit be67574

Browse files
committed
Updated scripts
1 parent 417dbcd commit be67574

4 files changed

+18
-12
lines changed

crestfallen-git.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
import subprocess
55
import os
66

7-
# constants
8-
gitProjectsList = [
9-
'/home/thegeekylad/Projects/traders-toolkit',
10-
'/home/thegeekylad/Projects/hackoberfest20/GreenLight',
11-
'/home/thegeekylad/Projects/hackoberfest20/Java-A-Z'
12-
]
7+
# getting projects
8+
gitProjectsList = []
9+
projects_file = open(str(Path.home()) + "/.config/py-crestfallen-git/projects", "r")
10+
for line in projects_file:
11+
gitProjectsList.append(line.strip())
1312

1413
projectCount = 0
1514
for path in gitProjectsList:

crestfallen-git.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# DO THIS INSIDE .bash_profile
22
# echo $XAUTHORITY > cresfallen-git-xauthority
33

4-
shouldSuspend=$(XAUTHORITY=$(cat /home/thegeekylad/.config-cresfallen-git) DISPLAY=":0" python3 /home/thegeekylad/Projects/py-crestfallen-git/crestfallen-git.py)
4+
shouldSuspend=$(XAUTHORITY=$(cat /home/$1/.config/py-cresfallen-git/xauth-cred) DISPLAY=":0" runuser $1 -c "python3 /opt/py-crestfallen-git/crestfallen-git.py")
55
if [ -z "$shouldSuspend" ];
66
then
77
echo 'Suspending...'

crestfallen-install.py

Whitespace-only changes.

install.sh

+12-5
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,25 @@ echo "----------------------------------------------"
22
echo "Crestfallen Git Installer"
33
echo "----------------------------------------------"
44

5+
# vars
6+
project_dir=/opt/py-crestfallen-git
7+
me=$(whoami)
8+
59
# initializing project dir
6-
echo "[*] Copying project files to /opt/crestfallen-git ..."
7-
sudo rm -rf /opt/crestfallen-git
8-
project_dir=/opt/crestfallen-git
10+
echo "[*] Setting up config directory as ~/.config/py-crestfallen-git ..."
11+
mkdir /home/$(whoami)/.config /home/$(whoami)/.config/py-crestfallen-git
12+
echo $XAUTHORITY > /home/$(whoami)/.config/py-crestfallen-git/xauth-cred
13+
touch /home/$(whoami)/.config/py-crestfallen-git/projects
14+
echo "[*] Copying project files to $project_dir ..."
15+
sudo rm -rf $project_dir
916
sudo mkdir $project_dir
1017
sudo cp ./crestfallen-git.py ./crestfallen-git.sh ./README.md $project_dir
1118

1219
# setup config file for xauthority dump
1320
echo "[*] Backing up .bash_profile --> .bash_profile.bkp ..."
1421
cp /home/$(whoami)/.bash_profile /home/$(whoami)/.bash_profile.bkp
1522
echo "[*] Patching .bash_profile to cache \$XAUTHORITY ..."
16-
echo "echo \$XAUTHORITY > .config-cresfallen-git" >> "/home/$(whoami)/.bash_profile"
23+
echo "echo \$XAUTHORITY > /home/$(whoami)/.config/cresfallen-git/xauth-cred" >> "/home/$(whoami)/.bash_profile"
1724

1825
# backup handler.sh
1926
echo "[*] Backing up /etc/acpi/handler.sh --> /etc/acpi/hander.sh.bkp ..."
@@ -32,7 +39,7 @@ do
3239
done < "$input"
3340
c=$((c+1))
3441
echo "[*] Patching /etc/acpi/handler.sh to intercept power button press ..."
35-
sudo sed -i $c' i\ '$project_dir'/crestfallen-git.sh' /etc/acpi/handler.sh
42+
sudo sed -i $c' i\ '$project_dir'/crestfallen-git.sh '$me /etc/acpi/handler.sh
3643

3744
# restart acpid
3845
echo "[*] Restarting acpid.service ..."

0 commit comments

Comments
 (0)