Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content
This repository was archived by the owner on Mar 3, 2020. It is now read-only.

Commit 6296ba9

Browse files
committed
Adding some pywal stuff
1 parent 25b4c7c commit 6296ba9

4 files changed

Lines changed: 236 additions & 2 deletions

File tree

system/aliases.zsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ alias docker-purge="docker rm -f $(docker ps -qa); docker rmi -f $(docker images
44

55
alias apu="apm update --no-confirm"
66

7-
alias wpu="wal -i $HOME/Pictures/Wallpaper/pywal -e"
7+
alias wpu="/Users/rcreasey/.dotfiles/system/random-wallpaper.sh"
88
test -e "${HOME}/.cache/wal/sequences" && (cat $HOME/.cache/wal/sequences &)
99

1010

system/random-wallpaper.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
DIR=$HOME/Pictures/Wallpaper
4+
COLLECTION_ID=540518
5+
URL=https://source.unsplash.com/collection/$COLLECTION_ID/1440x900
6+
7+
echo "Downloading $URL"
8+
curl -o "$DIR/current.jpg" -J -L "$URL" > /dev/null 2>&1
9+
10+
rm -rf $HOME/.cache/wal
11+
wal -c
12+
wal -i "$DIR/current.jpg" -e --vte

system/set-desktop-mojave.sh

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
#!/usr/bin/env bash
2+
3+
# AUTHOR: Steve Ward [steve@tech-otaku.com]
4+
# URL: https://github.com/tech-otaku/macos-desktop.git
5+
# README: https://github.com/tech-otaku/macos-desktop/blob/master/README.md
6+
7+
# USAGE: [bash] /path/to/set-desktop-mojave.sh <desktop image>
8+
9+
# Where <desktop image> can be...
10+
# HEIF (.heic) images
11+
# mojave = Mojave Dynamic
12+
# light = Mojave Light (Still)
13+
# dark = Mojave Dark (Still)
14+
# solar = Solar Gradients
15+
# non-HEIF (.heic) images e.g.
16+
# "/Library/Desktop Pictures/High Sierra.jpg"
17+
# Other
18+
# default = set the database [$db] to the default
19+
20+
# EXAMPLE: [bash] /path/to/set-desktop-mojave.sh light
21+
22+
23+
24+
# # # # # # # # # # # # # # # # 
25+
# FUNCTION DECLARATIONS
26+
#
27+
28+
# Restore the user's ~/.sqliterc configuration file renamed to ~/.sqliterc-HH:MM:SS.
29+
function restore_sqliterc {
30+
if [ -f ${HOME}/.sqliterc-$timestamp ]; then
31+
mv ${HOME}/.sqliterc-$timestamp ${HOME}/.sqliterc
32+
fi
33+
}
34+
35+
36+
37+
# # # # # # # # # # # # # # # # 
38+
# VARIABLES
39+
#
40+
41+
# db = database name including path
42+
# value = value of the `value` column in the `data` table for new rows
43+
# key = value of the `key` column in the `preferences` table for new rows
44+
# image = the title or filename of the Desktop image
45+
# lastrow[0] = row id of the row in the `data` table with the highest row id
46+
# lastrow[1] = row id of the row in the `preferences` table with the highest row id
47+
48+
db=${HOME}/Library/Application\ Support/Dock/desktoppicture.db
49+
50+
51+
52+
# # # # # # # # # # # # # # # # 
53+
# DISABLE SQLITE3 CONFIG FILE
54+
#
55+
56+
# To avoid unexcpected results the user's ~/.sqliterc configuration file may cause when `sqlite3` is executed, stop it being loaded by temporarily renaming it to ~/.sqliterc-HH:MM:SS
57+
if [ -f ${HOME}/.sqliterc ]; then
58+
timestamp=$(date '+%H-%M-%S')
59+
mv ${HOME}/.sqliterc ${HOME}/.sqliterc-$timestamp
60+
fi
61+
62+
63+
64+
# # # # # # # # # # # # # # # # 
65+
# USAGE CHECKS
66+
#
67+
68+
# Exit with error if OS version is not 10.14
69+
if [ $(system_profiler SPSoftwareDataType | awk '/System Version/ {print $4}' | cut -d . -f 2) -ne 14 ]; then
70+
echo "ERROR: For use with macOS Mojave 10.14.x only."
71+
restore_sqliterc
72+
exit 1
73+
fi
74+
75+
# Exit with error if no Desktop image was passed on the command line.
76+
if [ -z "$1" ]; then
77+
echo "ERROR: No image was specified."
78+
restore_sqliterc
79+
exit 1
80+
fi
81+
82+
# Exit with error if the Desktop image is a file that doesn't exist or an invalid option.
83+
#if [[ "$1" != "default" && "$1" != "mojave" && "$1" != "light" && "$1" != "dark" && "$1" != "solar" ]]; then
84+
if [ "$1" != "default" ] && [ "$1" != "mojave" ] && [ "$1" != "light" ] && [ "$1" != "dark" ] && [ "$1" != "solar" ]; then
85+
re='\.'
86+
if [[ $1 =~ $re ]]; then # $1 contains a . denoting a filename.ext
87+
if ! [ -f "$1" ]; then
88+
echo "ERROR: '$1' doesn't exist."
89+
restore_sqliterc
90+
exit 1
91+
fi
92+
else
93+
echo "ERROR: '$1' is not a valid option."
94+
restore_sqliterc
95+
exit 1
96+
fi
97+
fi
98+
99+
# Exit with error if this is a dual-monitor environment (the `displays` table will have 2 or more rows).
100+
if [ $(sqlite3 "$db" "SELECT COUNT() FROM displays;") -ge 2 ]; then
101+
echo "ERROR: This script should not be used in a dual-monitor environment."
102+
restore_sqliterc
103+
exit 1
104+
fi
105+
106+
# Exit with error if multiple Desktops are configured (the `spaces` table will have 2 or more rows).
107+
# if [ $(sqlite3 "$db" "SELECT COUNT() FROM spaces;") -ge 2 ]; then
108+
# echo "ERROR: This script should not be used when multiple Desktops (Spaces) are configured."
109+
# restore_sqliterc
110+
# exit 1
111+
# fi
112+
113+
114+
115+
# We've got this far, let's close System Preferences – if open – before continuing.
116+
killall System\ Preferences > /dev/null 2>&1 # Write STDOUT and STDERR to /dev/null to supress messages if process isn't running
117+
118+
119+
120+
# # # # # # # # # # # # # # # # 
121+
# SET-UP
122+
#
123+
124+
key=20
125+
case "$1" in
126+
mojave)
127+
value=1
128+
image="Mojave Dynamic"
129+
;;
130+
light)
131+
value=2
132+
image="Mojave Light (Still)"
133+
;;
134+
dark)
135+
value=3
136+
image="Mojave Dark (Still)"
137+
;;
138+
solar)
139+
value="'/Library/Desktop Pictures/Solar Gradients.heic'"
140+
key=1
141+
image="/Library/Desktop Pictures/Solar Gradients.heic"
142+
;;
143+
default)
144+
# Set the database [$db] to the default and exit. Only works if $db is ~/Library/Application\ Support/Dock/desktoppicture.db
145+
if [[ "$db" == $HOME/Library/Application\ Support/Dock/desktoppicture.db ]]; then
146+
! [ -d $HOME/Library/Application\ Support/Dock/backup ] && mkdir $HOME/Library/Application\ Support/Dock/backup
147+
mv "$db" $HOME/Library/Application\ Support/Dock/backup/desktoppicture-$(date '+%H-%M-%S').db # rename the current database [backup/desktoppicture-hh-mm-ss.db] first
148+
killall Dock # As desktoppicture.db no longer exists, this creates a new one with default values
149+
echo "The Desktop image has been set to the default."
150+
restore_sqliterc
151+
exit 0
152+
else
153+
echo "ERROR: The 'default' option is only appropriate when the database is $HOME/Library/Application Support/Dock/desktoppicture.db"
154+
restore_sqliterc
155+
exit 1
156+
fi
157+
;;
158+
*)
159+
value="'$1'"
160+
image="$1"
161+
key=1
162+
;;
163+
esac
164+
165+
166+
167+
# # # # # # # # # # # # # # # # 
168+
# GET LAST ROW IDS
169+
#
170+
171+
# Get the rowid of the last row to be inserted in the `data` table. This will be used to insert new rows later in the script.
172+
lastrow[0]=$(sqlite3 "$db" "SELECT ROWID FROM data ORDER BY ROWID DESC LIMIT 1;")
173+
174+
# if `data` contains 0 rows, lastrow[0] is empty/null so explicitily set lastrow[0] to 0
175+
[ -z "${lastrow[0]}" ] && lastrow[0]=0
176+
177+
# Get the rowid of the last row to be inserted in the `preferences` table. This will be used to insert new rows later in the script.
178+
lastrow[1]=$(sqlite3 "$db" "SELECT ROWID FROM preferences ORDER BY ROWID DESC LIMIT 1;")
179+
180+
# if `preferences` contains 0 rows, lastrow[1] is empty/null so explicitily set lastrow[1] to 0
181+
[ -z "${lastrow[1]}" ] && lastrow[1]=0
182+
183+
184+
185+
# # # # # # # # # # # # # # # # 
186+
# DELETE ALL ROWS
187+
#
188+
189+
# Delete all rows in the `data` table.
190+
sqlite3 "$db" "DELETE FROM data;"
191+
192+
# Delete all rows in the `preferences` table. Causes the `preferences_deleted` trigger to fire.
193+
sqlite3 "$db" "DELETE FROM preferences;"
194+
195+
196+
197+
# # # # # # # # # # # # # # # # 
198+
# INSERT NEW ROWS
199+
#
200+
201+
# Insert a new row into the `data` table.
202+
sqlite3 "$db" "INSERT INTO data(rowid,value) VALUES( $((lastrow[0] + 1)), $value );"
203+
204+
# Insert four new rows into the `preferences` table.
205+
sqlite3 "$db" "INSERT INTO preferences(rowid,key,data_id,picture_id) VALUES( $((lastrow[1] + 1)),$key,$((lastrow[0] + 1)),3);"
206+
sqlite3 "$db" "INSERT INTO preferences(rowid,key,data_id,picture_id) VALUES( $((lastrow[1] + 2)),$key,$((lastrow[0] + 1)),4);"
207+
sqlite3 "$db" "INSERT INTO preferences(rowid,key,data_id,picture_id) VALUES( $((lastrow[1] + 3)),$key,$((lastrow[0] + 1)),2);"
208+
sqlite3 "$db" "INSERT INTO preferences(rowid,key,data_id,picture_id) VALUES( $((lastrow[1] + 4)),$key,$((lastrow[0] + 1)),1);"
209+
210+
echo "The Desktop image has been set to $image."
211+
212+
213+
214+
# # # # # # # # # # # # # # # # 
215+
# FINISH UP
216+
#
217+
218+
# Restart the Dock so changes to desktoppicture.db take effect
219+
killall Dock
220+
221+
# Restore the user's ~/.sqliterc configuration file (if) renamed earlier in this script.
222+
restore_sqliterc

zsh/zplug.zsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ if zplug check "b4b4r07/enhancd"; then
88
export ENHANCD_DOT_SHOW_FULLPATH=1
99
fi
1010

11-
zplug "chriskempson/base16-shell", use:"scripts/base16-default-dark.sh", defer:0
11+
#zplug "chriskempson/base16-shell", use:"scripts/base16-default-dark.sh", defer:0
1212
zplug "chriskempson/base16-shell", use:colortest, as:command
1313

1414
zplug "chrissicool/zsh-256color"

0 commit comments

Comments
 (0)