-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwp
executable file
·135 lines (126 loc) · 4.5 KB
/
wp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash
# wp: a wrapper script mostly for pywal and fetch oneliners
# Note - most wallpaper-changing functions are mac-specific (for nowf)
# Since this a everyday use script, I personally expect it and unique_space.sh to be in ~/.bin.
# If you want it somewhere else, you may have to change some paths (e.g. /opt/bin)
LOC="$HOME/.bin"
if [[ $(dirname $(realpath $0)) != $LOC ]]; then
printf "This script is meant to be called manually by the user, so\n"
printf "it and its counterpart unique_space.sh should be run from ~/.bin directory.\n"
printf "If you don't want them there, you should change the hardcoded paths to\n"
printf "~/.bin/unique_space.sh in this file ($0) and call it from the cli\n"
printf "to make sure everything works.\n"
exit 1
fi
_usage() {
printf "wp: Tool for on-the-fly colorscheme changes.\n"
printf "Usage:\n"
printf "\twp --clean \t\t\tClear out manually-cached pywal files (e.g. colors_1.sh)\n"
printf "\twp -w|--wallpaper FILE\t\tSet wallpaper to FILE and cache colors\n"
printf "\twp --wo|--wallpaper-only FILE\tJust set wallpaper to FILE\n"
printf "\twp -n|--new \t\t\tNew iTerm window with default profile\n"
printf "\twp -r|--reload \t\t\tLoad space-specific colorscheme\n"
printf "\twp -b|--both FILE\t\tSet wallpaper and reload colors\n"
printf "\twp -c|--copy ID_src ID2_dest\tCopy sequences_ID_src to sequences_ID_dest\n"
printf "\twp -f|--file ID\t\t\tAttempt to load .cache/wal/sequences_ID\n"
printf "\t\t\t\t\t\tNote - reloading too soon might not work for complex images\n"
printf "\n"
printf "\twp -t|--transparency REAL\tSet transparency of terminal (0.0 to 1.0)\n"
printf "\twp --tg|--transparency-get\tGet the current terminal's transparency (0.0 to 1.0)\n"
printf "\twp --pixelate\t\t\tSet background of term to pixelated version of current wallpaper\n"
printf "\t\t\t\t\t\t- requires iTerm2 on mac\n"
printf "\t\t\t\t\t\t- requires ffmpeg with frei0r\n"
# todo complete day/night/toggle
}
case "$1" in
--clean)
~/.bin/unique_space.sh --clean
;;
-w|--wallpaper)
~/.bin/unique_space.sh -w "$2"
;;
-wo|--wallpaper-only)
if [[ -z "$2" ]]; then echo "Required: wallpaper" && exit 1; fi
FILE="$(realpath "$2")"
if [[ ! -f "$FILE" ]]; then exit 1; fi
osascript -e "tell application \"Finder\" to set desktop picture to POSIX file \"$FILE\""
;;
-n|--new)
~/.bin/unique_space.sh -n
;;
-c|--copy)
~/.bin/unique_space.sh --copy $2 $3
;;
-r|--reload)
~/.bin/unique_space.sh -r
;;
-b|--both)
$0 -w "$2"
sleep 1
$0 -r
;;
-f|--file)
cat ~/.cache/wal/sequences_"$2"
;;
--pixelate)
~/.bin/pxl-bg $(~/.bin/unique_space.sh --get-wallpaper)
;;
-t|--transparency)
osascript -e "tell application \"iTerm\" to tell current window to tell current session to set transparency to $2"
;;
--tg|--transparency-get)
# NOTE - cmd+u makes an iTerm window opaque?
osascript -e 'tell application "iTerm" to tell current window to tell current session to get transparency'
;;
--day)
# Instead should progressively set Flux temp higher to ease transition
killall Flux &> /dev/null
# if Flux doesn't set to dark mode, don't need this toggle
#khd -p "cmd + alt + ctrl - t"
export NIGHT=0
#return 0
;;
--night)
open -a Flux
# change colorshemes (?) and wallpapers
export NIGHT=1
#return 0
;;
--toggle)
if [[ -z "$NIGHT" ]]; then
export NIGHT=1
fi
if [[ "$NIGHT" ]]; then
NIGHT=1
day
else
NIGHT=0
night
fi
;;
--bonsai)
~/.bin/bonsai.sh
;;
--coffee)
~/.bin/coffee.sh
;;
--termcolors)
# Display terminal ANSI colors
# Print numbers
echo -en " \t"
for i in {0..7}; do echo -en " ${i} \t"; done; echo
# Print regular colors
echo -en "reg:\t"
for i in {0..7}; do echo -en "\033[0;3${i}m▉▉▉▉▉▉▉\t"; done; echo; echo
# Print alternate colors
echo -en "alt:\t"
for i in {0..7}; do echo -en "\033[1;3${i}m▉▉▉▉▉▉▉\t"; done; echo
;;
-h|--help)
_usage
;;
*)
printf "Not supported: ""$1\n"
_usage
;;
esac