Eclectic Media Git dmenu-tweet / 4ed0e46
Added setup and key enrollment scripts * Setup script (./setup.sh): - checks for dependencies (dmenu & bash-send-tweet) - invokes key enrollment script - copies repository to required paths - checks for path existence in .bashrc, and attempts to add it automatically - if i3wm is installed, automatically tries to add a binding for the script ($mod+Shift+t) * Key Enrollment Script (./utils/enroll.sh): - Gets API keys from user - ensures file is secure and only readable by the user - copies subsequent '.twitterkeys' file to bash-send-tweet library Ariana Giroux 10 days ago
2 changed file(s) with 103 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 #! /bin/bash
1
2 BIN_PATH="$HOME/.local/bin"
3 LIB_PATH="$HOME/.local/lib"
4
5 subcommand_output () {
6 tput setaf 3
7 while read -e line; do
8 echo "... $line"
9 done
10 tput sgr0
11 }
12
13
14 echo -e "\nEnsuring dependencies are installed!\n"
15 if ! command -v dmenu &> /dev/null; then
16 echo "Please ensure that dmenu is installed!"
17 exit 1
18 fi
19
20 if ! ls lib | grep 'bash-send-tweet' &> /dev/null; then
21 echo "bash-send-tweet submodule not cloned! Rectifying!"
22 git submodule update --init --recursive | subcommand_output
23 fi
24
25 echo "Dependencies satisfied!" | subcommand_output
26 sleep 0.5
27
28
29 echo -e "\nEnrolling twitter keys!\n"
30 ./utils/enroll.sh | subcommand_output
31
32 if ! [[ $? == 0 ]]; then
33 echo "Failed to enroll twitter keys! Exiting!"
34 exit 1
35 fi
36 sleep 0.5
37
38
39 echo -e "\nCopying bin files to executable path! [~/.local/bin/]"
40 mkdir -p $BIN_PATH &> /dev/null # ensure path exists
41 cp bin/dmenu-tweet $BIN_PATH/
42 sleep 0.5
43
44
45 echo -e "\nCopying lib files to library path! [~/.local/lib/]"
46 mkdir -p $LIB_PATH &> /dev/null # ensure path exists
47 rm -rf "$LIB_PATH/bash-send-tweet" &> /dev/null
48 cp -r lib/bash-send-tweet $LIB_PATH/
49
50
51 # ADD TO PATH
52 if ! cat ~/.bashrc | grep "local/bin" &> /dev/null || cat ~/.bashrc | grep "dmenu-tweet" &> /dev/null; then
53 echo -e "\nAdding paths to .bashrc...\n"
54 echo 'export PATH=$PATH:~/.local/bin/dmenu-tweet'
55 fi
56
57
58 # ADD i3 BINDINGS
59 if [[ -f ~/.config/i3/config ]]; then
60 if ! cat ~/.config/i3/config | grep "dmenu-tweet" &>/dev/null; then
61 echo -e "\nDetected i3wm but no bindings for dmenu-tweet!\n"
62 tput setaf 3; read -p '... Do you want to add $mod+Shift+t as a binding for dmenu-tweet? [y/N]: '; tput sgr0
63 if [[ "$REPLY" == 'y' ]]; then
64 echo 'bindsym $mod+Shift+t exec --no-startup-id "dmenu-tweet"' >> ~/.config/i3/config
65 fi
66 fi
67 fi
68
69 echo -e "\n\nDone!"
0 #! /bin/bash
1
2 echo "Securely enrolling twitter API keys... Follow the on screen prompts!"
3
4 echo "CONSUMER KEY:"
5 read
6 # read -p '-> ' CONSUMER_KEY
7
8 echo "CONSUMER SECRET:"
9 read
10 # read -p '-> ' CONSUMER_SECRET
11
12 echo "ACCESS TOKEN:"
13 read
14 # read -p '-> ' ACCESS_TOKEN
15
16 echo "ACCESS TOKEN_SECRET:"
17 read
18 # read -p '-> ' ACCESS_TOKEN_SECRET
19
20 echo Creating the .twitterkeys file!
21 echo "CONSUMER_KEY='$CONSUMER_KEY'" > .twitterkeys
22 echo "CONSUMER_SECRET='$CONSUMER_SECRET'" >> .twitterkeys
23 echo "ACCESS_TOKEN='$ACCESS_TOKEN'" >> .twitterkeys
24 echo "ACCESS_TOKEN_SECRET='$ACCESS_TOKEN_SECRET'" >> .twitterkeys
25
26 echo "Ensuring privacy of the file..."
27 chmod 0600 .twitterkeys
28
29 echo "Moving .twitterkeys file to lib/bash-send-tweet..."
30 mv .twitterkeys lib/bash-send-tweet/.twitterkeys
31
32 echo "Done!"