diff options
Diffstat (limited to 'X11/eww/scripts')
-rwxr-xr-x | X11/eww/scripts/mails | 7 | ||||
-rwxr-xr-x | X11/eww/scripts/music_info | 97 | ||||
-rwxr-xr-x | X11/eww/scripts/open_apps | 42 | ||||
-rwxr-xr-x | X11/eww/scripts/open_folders | 33 | ||||
-rwxr-xr-x | X11/eww/scripts/open_links | 31 | ||||
-rwxr-xr-x | X11/eww/scripts/sys_info | 78 | ||||
-rwxr-xr-x | X11/eww/scripts/weather_info | 147 |
7 files changed, 435 insertions, 0 deletions
diff --git a/X11/eww/scripts/mails b/X11/eww/scripts/mails new file mode 100755 index 0000000..974d00a --- /dev/null +++ b/X11/eww/scripts/mails | |||
@@ -0,0 +1,7 @@ | |||
1 | #!/bin/python | ||
2 | |||
3 | import imaplib | ||
4 | obj = imaplib.IMAP4_SSL('imap.gmail.com',993) | ||
5 | obj.login('username@gmail.com','PASSWORD') # write your email and password | ||
6 | obj.select() | ||
7 | print(len(obj.search(None, 'UnSeen')[1][0].split())) | ||
diff --git a/X11/eww/scripts/music_info b/X11/eww/scripts/music_info new file mode 100755 index 0000000..e5a7283 --- /dev/null +++ b/X11/eww/scripts/music_info | |||
@@ -0,0 +1,97 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | ## Get data | ||
4 | STATUS="$(mpc status)" | ||
5 | COVER="/tmp/.music_cover.jpg" | ||
6 | MUSIC_DIR="$HOME/Music" | ||
7 | |||
8 | ## Get status | ||
9 | get_status() { | ||
10 | if [[ $STATUS == *"[playing]"* ]]; then | ||
11 | echo "" | ||
12 | else | ||
13 | echo "喇" | ||
14 | fi | ||
15 | } | ||
16 | |||
17 | ## Get song | ||
18 | get_song() { | ||
19 | song=`mpc -f %title% current` | ||
20 | if [[ -z "$song" ]]; then | ||
21 | echo "Offline" | ||
22 | else | ||
23 | echo "$song" | ||
24 | fi | ||
25 | } | ||
26 | |||
27 | ## Get artist | ||
28 | get_artist() { | ||
29 | artist=`mpc -f %artist% current` | ||
30 | if [[ -z "$artist" ]]; then | ||
31 | echo "Offline" | ||
32 | else | ||
33 | echo "$artist" | ||
34 | fi | ||
35 | } | ||
36 | |||
37 | ## Get time | ||
38 | get_time() { | ||
39 | time=`mpc status | grep "%)" | awk '{print $4}' | tr -d '(%)'` | ||
40 | if [[ -z "$time" ]]; then | ||
41 | echo "0" | ||
42 | else | ||
43 | echo "$time" | ||
44 | fi | ||
45 | } | ||
46 | get_ctime() { | ||
47 | ctime=`mpc status | grep "#" | awk '{print $3}' | sed 's|/.*||g'` | ||
48 | if [[ -z "$ctime" ]]; then | ||
49 | echo "0:00" | ||
50 | else | ||
51 | echo "$ctime" | ||
52 | fi | ||
53 | } | ||
54 | get_ttime() { | ||
55 | ttime=`mpc -f %time% current` | ||
56 | if [[ -z "$ttime" ]]; then | ||
57 | echo "0:00" | ||
58 | else | ||
59 | echo "$ttime" | ||
60 | fi | ||
61 | } | ||
62 | |||
63 | ## Get cover | ||
64 | get_cover() { | ||
65 | ffmpeg -i "${MUSIC_DIR}/$(mpc current -f %file%)" "${COVER}" -y &> /dev/null | ||
66 | STATUS=$? | ||
67 | |||
68 | # Check if the file has a embbeded album art | ||
69 | if [ "$STATUS" -eq 0 ];then | ||
70 | echo "$COVER" | ||
71 | else | ||
72 | echo "images/music.png" | ||
73 | fi | ||
74 | } | ||
75 | |||
76 | ## Execute accordingly | ||
77 | if [[ "$1" == "--song" ]]; then | ||
78 | get_song | ||
79 | elif [[ "$1" == "--artist" ]]; then | ||
80 | get_artist | ||
81 | elif [[ "$1" == "--status" ]]; then | ||
82 | get_status | ||
83 | elif [[ "$1" == "--time" ]]; then | ||
84 | get_time | ||
85 | elif [[ "$1" == "--ctime" ]]; then | ||
86 | get_ctime | ||
87 | elif [[ "$1" == "--ttime" ]]; then | ||
88 | get_ttime | ||
89 | elif [[ "$1" == "--cover" ]]; then | ||
90 | get_cover | ||
91 | elif [[ "$1" == "--toggle" ]]; then | ||
92 | mpc -q toggle | ||
93 | elif [[ "$1" == "--next" ]]; then | ||
94 | { mpc -q next; get_cover; } | ||
95 | elif [[ "$1" == "--prev" ]]; then | ||
96 | { mpc -q prev; get_cover; } | ||
97 | fi | ||
diff --git a/X11/eww/scripts/open_apps b/X11/eww/scripts/open_apps new file mode 100755 index 0000000..57d3718 --- /dev/null +++ b/X11/eww/scripts/open_apps | |||
@@ -0,0 +1,42 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | ## Open Applications | ||
4 | FILE="$HOME/.cache/eww_launch.dashboard" | ||
5 | CFG="$HOME/.config/eww/dashboard" | ||
6 | EWW=`which eww` | ||
7 | |||
8 | close_dash() { | ||
9 | ${EWW} --config "$CFG" close \ | ||
10 | background profile system clock uptime music github \ | ||
11 | reddit twitter youtube weather apps mail logout sleep reboot poweroff folders | ||
12 | rm -rf "$FILE" | ||
13 | } | ||
14 | |||
15 | if [[ "$1" == "--ff" ]]; then | ||
16 | close_dash && firefox & | ||
17 | |||
18 | elif [[ "$1" == "--tg" ]]; then | ||
19 | close_dash && telegram-desktop & | ||
20 | |||
21 | elif [[ "$1" == "--dc" ]]; then | ||
22 | close_dash && discord & | ||
23 | |||
24 | elif [[ "$1" == "--tr" ]]; then | ||
25 | close_dash && alacritty --working-directory ~ & | ||
26 | |||
27 | elif [[ "$1" == "--fm" ]]; then | ||
28 | close_dash && thunar ~ & | ||
29 | |||
30 | elif [[ "$1" == "--ge" ]]; then | ||
31 | close_dash && geany & | ||
32 | |||
33 | elif [[ "$1" == "--cd" ]]; then | ||
34 | close_dash && code & | ||
35 | |||
36 | elif [[ "$1" == "--gp" ]]; then | ||
37 | close_dash && gimp & | ||
38 | |||
39 | elif [[ "$1" == "--vb" ]]; then | ||
40 | close_dash && virtualbox & | ||
41 | |||
42 | fi | ||
diff --git a/X11/eww/scripts/open_folders b/X11/eww/scripts/open_folders new file mode 100755 index 0000000..c5a5628 --- /dev/null +++ b/X11/eww/scripts/open_folders | |||
@@ -0,0 +1,33 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | ## Open folders in thunar | ||
4 | FILE="$HOME/.cache/eww_launch.dashboard" | ||
5 | CFG="$HOME/.config/eww/dashboard" | ||
6 | EWW=`which eww` | ||
7 | |||
8 | close_dash() { | ||
9 | ${EWW} --config "$CFG" close \ | ||
10 | background profile system clock uptime music github \ | ||
11 | reddit twitter youtube weather apps mail logout sleep reboot poweroff folders | ||
12 | rm -rf "$FILE" | ||
13 | } | ||
14 | |||
15 | if [[ "$1" == "--dl" ]]; then | ||
16 | close_dash && thunar ~/Downloads & | ||
17 | |||
18 | elif [[ "$1" == "--docs" ]]; then | ||
19 | close_dash && thunar ~/Documents & | ||
20 | |||
21 | elif [[ "$1" == "--music" ]]; then | ||
22 | close_dash && thunar ~/Music & | ||
23 | |||
24 | elif [[ "$1" == "--pics" ]]; then | ||
25 | close_dash && thunar ~/Pictures & | ||
26 | |||
27 | elif [[ "$1" == "--cfg" ]]; then | ||
28 | close_dash && thunar ~/.config & | ||
29 | |||
30 | elif [[ "$1" == "--local" ]]; then | ||
31 | close_dash && thunar ~/.local/share & | ||
32 | |||
33 | fi | ||
diff --git a/X11/eww/scripts/open_links b/X11/eww/scripts/open_links new file mode 100755 index 0000000..a338847 --- /dev/null +++ b/X11/eww/scripts/open_links | |||
@@ -0,0 +1,31 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | ## Open links in firefox | ||
4 | FILE="$HOME/.cache/eww_launch.dashboard" | ||
5 | CFG="$HOME/.config/eww/dashboard" | ||
6 | EWW=`which eww` | ||
7 | cmd="firefox --new-tab" | ||
8 | |||
9 | close_dash() { | ||
10 | ${EWW} --config "$CFG" close \ | ||
11 | background profile system clock uptime music github \ | ||
12 | reddit twitter youtube weather apps mail logout sleep reboot poweroff folders | ||
13 | rm -rf "$FILE" | ||
14 | } | ||
15 | |||
16 | if [[ "$1" == "--mail" ]]; then | ||
17 | close_dash && ${cmd} "https://mail.google.com" | ||
18 | |||
19 | elif [[ "$1" == "--gh" ]]; then | ||
20 | close_dash && ${cmd} "https://github.com" | ||
21 | |||
22 | elif [[ "$1" == "--rd" ]]; then | ||
23 | close_dash && ${cmd} "https://reddit.com" | ||
24 | |||
25 | elif [[ "$1" == "--tw" ]]; then | ||
26 | close_dash && ${cmd} "https://twitter.com" | ||
27 | |||
28 | elif [[ "$1" == "--yt" ]]; then | ||
29 | close_dash && ${cmd} "https://youtube.com" | ||
30 | |||
31 | fi | ||
diff --git a/X11/eww/scripts/sys_info b/X11/eww/scripts/sys_info new file mode 100755 index 0000000..a168be3 --- /dev/null +++ b/X11/eww/scripts/sys_info | |||
@@ -0,0 +1,78 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | ## Files and Data | ||
4 | PREV_TOTAL=0 | ||
5 | PREV_IDLE=0 | ||
6 | cpuFile="/tmp/.cpu_usage" | ||
7 | |||
8 | ## Get CPU usage | ||
9 | get_cpu() { | ||
10 | if [[ -f "${cpuFile}" ]]; then | ||
11 | fileCont=$(cat "${cpuFile}") | ||
12 | PREV_TOTAL=$(echo "${fileCont}" | head -n 1) | ||
13 | PREV_IDLE=$(echo "${fileCont}" | tail -n 1) | ||
14 | fi | ||
15 | |||
16 | CPU=(`cat /proc/stat | grep '^cpu '`) # Get the total CPU statistics. | ||
17 | unset CPU[0] # Discard the "cpu" prefix. | ||
18 | IDLE=${CPU[4]} # Get the idle CPU time. | ||
19 | |||
20 | # Calculate the total CPU time. | ||
21 | TOTAL=0 | ||
22 | |||
23 | for VALUE in "${CPU[@]:0:4}"; do | ||
24 | let "TOTAL=$TOTAL+$VALUE" | ||
25 | done | ||
26 | |||
27 | if [[ "${PREV_TOTAL}" != "" ]] && [[ "${PREV_IDLE}" != "" ]]; then | ||
28 | # Calculate the CPU usage since we last checked. | ||
29 | let "DIFF_IDLE=$IDLE-$PREV_IDLE" | ||
30 | let "DIFF_TOTAL=$TOTAL-$PREV_TOTAL" | ||
31 | let "DIFF_USAGE=(1000*($DIFF_TOTAL-$DIFF_IDLE)/$DIFF_TOTAL+5)/10" | ||
32 | echo "${DIFF_USAGE}" | ||
33 | else | ||
34 | echo "?" | ||
35 | fi | ||
36 | |||
37 | # Remember the total and idle CPU times for the next check. | ||
38 | echo "${TOTAL}" > "${cpuFile}" | ||
39 | echo "${IDLE}" >> "${cpuFile}" | ||
40 | } | ||
41 | |||
42 | ## Get Used memory | ||
43 | get_mem() { | ||
44 | printf "%.0f\n" $(free -m | grep Mem | awk '{print ($3/$2)*100}') | ||
45 | } | ||
46 | |||
47 | ## Get Brightness | ||
48 | get_blight() { | ||
49 | CARD=`ls /sys/class/backlight | head -n 1` | ||
50 | |||
51 | if [[ "$CARD" == *"intel_"* ]]; then | ||
52 | BNESS=`xbacklight -get` | ||
53 | LIGHT=${BNESS%.*} | ||
54 | else | ||
55 | BNESS=`blight -d $CARD get brightness` | ||
56 | PERC="$(($BNESS*100/255))" | ||
57 | LIGHT=${PERC%.*} | ||
58 | fi | ||
59 | |||
60 | echo "$LIGHT" | ||
61 | } | ||
62 | |||
63 | ## Get Battery | ||
64 | get_battery() { | ||
65 | BAT=CMB0 | ||
66 | cat /sys/class/power_supply/${BAT}/capacity | ||
67 | } | ||
68 | |||
69 | ## Execute accordingly | ||
70 | if [[ "$1" == "--cpu" ]]; then | ||
71 | get_cpu | ||
72 | elif [[ "$1" == "--mem" ]]; then | ||
73 | get_mem | ||
74 | elif [[ "$1" == "--blight" ]]; then | ||
75 | get_blight | ||
76 | elif [[ "$1" == "--bat" ]]; then | ||
77 | get_battery | ||
78 | fi | ||
diff --git a/X11/eww/scripts/weather_info b/X11/eww/scripts/weather_info new file mode 100755 index 0000000..6fee821 --- /dev/null +++ b/X11/eww/scripts/weather_info | |||
@@ -0,0 +1,147 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | ## Collect data | ||
4 | cache_dir="$HOME/.cache/eww/weather" | ||
5 | cache_weather_stat=${cache_dir}/weather-stat | ||
6 | cache_weather_degree=${cache_dir}/weather-degree | ||
7 | cache_weather_quote=${cache_dir}/weather-quote | ||
8 | cache_weather_hex=${cache_dir}/weather-hex | ||
9 | cache_weather_icon=${cache_dir}/weather-icon | ||
10 | |||
11 | ## Weather data | ||
12 | KEY="YOUR_KEY" | ||
13 | ID="CITY_ID" | ||
14 | UNIT="metric" # Available options : 'metric' or 'imperial' | ||
15 | |||
16 | ## Make cache dir | ||
17 | if [[ ! -d "$cache_dir" ]]; then | ||
18 | mkdir -p ${cache_dir} | ||
19 | fi | ||
20 | |||
21 | ## Get data | ||
22 | get_weather_data() { | ||
23 | weather=`curl -sf "http://api.openweathermap.org/data/2.5/weather?APPID="$KEY"&id="$ID"&units="$UNIT""` | ||
24 | echo ${weather} | ||
25 | |||
26 | if [ ! -z "$weather" ]; then | ||
27 | weather_temp=`echo "$weather" | jq ".main.temp" | cut -d "." -f 1` | ||
28 | weather_icon_code=`echo "$weather" | jq -r ".weather[].icon" | head -1` | ||
29 | weather_description=`echo "$weather" | jq -r ".weather[].description" | head -1 | sed -e "s/\b\(.\)/\u\1/g"` | ||
30 | |||
31 | #Big long if statement of doom | ||
32 | if [ "$weather_icon_code" == "50d" ]; then | ||
33 | weather_icon=" " | ||
34 | weather_quote="Forecast says it's misty \nMake sure you don't get lost on your way..." | ||
35 | weather_hex="#84afdb" | ||
36 | elif [ "$weather_icon_code" == "50n" ]; then | ||
37 | weather_icon=" " | ||
38 | weather_quote="Forecast says it's a misty night \nDon't go anywhere tonight or you might get lost..." | ||
39 | weather_hex="#84afdb" | ||
40 | elif [ "$weather_icon_code" == "01d" ]; then | ||
41 | weather_icon=" " | ||
42 | weather_quote="It's a sunny day, gonna be fun! \nDon't go wandering all by yourself though..." | ||
43 | weather_hex="#ffd86b" | ||
44 | elif [ "$weather_icon_code" == "01n" ]; then | ||
45 | weather_icon=" " | ||
46 | weather_quote="It's a clear night \nYou might want to take a evening stroll to relax..." | ||
47 | weather_hex="#fcdcf6" | ||
48 | elif [ "$weather_icon_code" == "02d" ]; then | ||
49 | weather_icon=" " | ||
50 | weather_quote="It's cloudy, sort of gloomy \nYou'd better get a book to read..." | ||
51 | weather_hex="#adadff" | ||
52 | elif [ "$weather_icon_code" == "02n" ]; then | ||
53 | weather_icon=" " | ||
54 | weather_quote="It's a cloudy night \nHow about some hot chocolate and a warm bed?" | ||
55 | weather_hex="#adadff" | ||
56 | elif [ "$weather_icon_code" == "03d" ]; then | ||
57 | weather_icon=" " | ||
58 | weather_quote="It's cloudy, sort of gloomy \nYou'd better get a book to read..." | ||
59 | weather_hex="#adadff" | ||
60 | elif [ "$weather_icon_code" == "03n" ]; then | ||
61 | weather_icon=" " | ||
62 | weather_quote="It's a cloudy night \nHow about some hot chocolate and a warm bed?" | ||
63 | weather_hex="#adadff" | ||
64 | elif [ "$weather_icon_code" == "04d" ]; then | ||
65 | weather_icon=" " | ||
66 | weather_quote="It's cloudy, sort of gloomy \nYou'd better get a book to read..." | ||
67 | weather_hex="#adadff" | ||
68 | elif [ "$weather_icon_code" == "04n" ]; then | ||
69 | weather_icon=" " | ||
70 | weather_quote="It's a cloudy night \nHow about some hot chocolate and a warm bed?" | ||
71 | weather_hex="#adadff" | ||
72 | elif [ "$weather_icon_code" == "09d" ]; then | ||
73 | weather_icon=" " | ||
74 | weather_quote="It's rainy, it's a great day! \nGet some ramen and watch as the rain falls..." | ||
75 | weather_hex="#6b95ff" | ||
76 | elif [ "$weather_icon_code" == "09n" ]; then | ||
77 | weather_icon=" " | ||
78 | weather_quote=" It's gonna rain tonight it seems \nMake sure your clothes aren't still outside..." | ||
79 | weather_hex="#6b95ff" | ||
80 | elif [ "$weather_icon_code" == "10d" ]; then | ||
81 | weather_icon=" " | ||
82 | weather_quote="It's rainy, it's a great day! \nGet some ramen and watch as the rain falls..." | ||
83 | weather_hex="#6b95ff" | ||
84 | elif [ "$weather_icon_code" == "10n" ]; then | ||
85 | weather_icon=" " | ||
86 | weather_quote=" It's gonna rain tonight it seems \nMake sure your clothes aren't still outside..." | ||
87 | weather_hex="#6b95ff" | ||
88 | elif [ "$weather_icon_code" == "11d" ]; then | ||
89 | weather_icon="" | ||
90 | weather_quote="There's storm for forecast today \nMake sure you don't get blown away..." | ||
91 | weather_hex="#ffeb57" | ||
92 | elif [ "$weather_icon_code" == "11n" ]; then | ||
93 | weather_icon="" | ||
94 | weather_quote="There's gonna be storms tonight \nMake sure you're warm in bed and the windows are shut..." | ||
95 | weather_hex="#ffeb57" | ||
96 | elif [ "$weather_icon_code" == "13d" ]; then | ||
97 | weather_icon=" " | ||
98 | weather_quote="It's gonna snow today \nYou'd better wear thick clothes and make a snowman as well!" | ||
99 | weather_hex="#e3e6fc" | ||
100 | elif [ "$weather_icon_code" == "13n" ]; then | ||
101 | weather_icon=" " | ||
102 | weather_quote="It's gonna snow tonight \nMake sure you get up early tomorrow to see the sights..." | ||
103 | weather_hex="#e3e6fc" | ||
104 | elif [ "$weather_icon_code" == "40d" ]; then | ||
105 | weather_icon=" " | ||
106 | weather_quote="Forecast says it's misty \nMake sure you don't get lost on your way..." | ||
107 | weather_hex="#84afdb" | ||
108 | elif [ "$weather_icon_code" == "40n" ]; then | ||
109 | weather_icon=" " | ||
110 | weather_quote="Forecast says it's a misty night \nDon't go anywhere tonight or you might get lost..." | ||
111 | weather_hex="#84afdb" | ||
112 | else | ||
113 | weather_icon=" " | ||
114 | weather_quote="Sort of odd, I don't know what to forecast \nMake sure you have a good time!" | ||
115 | weather_hex="#adadff" | ||
116 | fi | ||
117 | echo "$weather_icon" > ${cache_weather_icon} | ||
118 | echo "$weather_description" > ${cache_weather_stat} | ||
119 | echo "$weather_temp""°C" > ${cache_weather_degree} | ||
120 | echo -e "$weather_quote" > ${cache_weather_quote} | ||
121 | echo "$weather_hex" > ${cache_weather_hex} | ||
122 | else | ||
123 | echo "Weather Unavailable" > ${cache_weather_stat} | ||
124 | echo " " > ${cache_weather_icon} | ||
125 | echo -e "Ah well, no weather huh? \nEven if there's no weather, it's gonna be a great day!" > ${cache_weather_quote} | ||
126 | echo "-" > ${cache_weather_degree} | ||
127 | echo "#adadff" > ${tcache_weather_hex} | ||
128 | fi | ||
129 | } | ||
130 | |||
131 | ## Execute | ||
132 | if [[ "$1" == "--getdata" ]]; then | ||
133 | get_weather_data | ||
134 | elif [[ "$1" == "--icon" ]]; then | ||
135 | cat ${cache_weather_icon} | ||
136 | elif [[ "$1" == "--temp" ]]; then | ||
137 | cat ${cache_weather_degree} | ||
138 | elif [[ "$1" == "--hex" ]]; then | ||
139 | cat ${cache_weather_hex} | ||
140 | elif [[ "$1" == "--stat" ]]; then | ||
141 | cat ${cache_weather_stat} | ||
142 | elif [[ "$1" == "--quote" ]]; then | ||
143 | cat ${cache_weather_quote} | head -n1 | ||
144 | elif [[ "$1" == "--quote2" ]]; then | ||
145 | cat ${cache_weather_quote} | tail -n1 | ||
146 | fi | ||
147 | |||