Skip to content

Commit

Permalink
Fix for #23 and #27
Browse files Browse the repository at this point in the history
* Reverted handling of Dropbox timezones.txt (#23)
* Asking wheither override when an existing timezones.txt in the new location (#27)
jaroslawhartman committed Sep 1, 2019
1 parent c1eb11d commit ff9f3f8
Showing 5 changed files with 56 additions and 24 deletions.
Binary file removed TimeZones-v2.13.zip
Binary file not shown.
Binary file renamed TimeZones-v2.12.zip → TimeZones-v2.14.zip
Binary file not shown.
24 changes: 14 additions & 10 deletions source/includes.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
#includes for TimeZones scripts

#Working Directories
TZPREFS="$alfred_workflow_data"

CONFIG_EXTRA="$TZPREFS/configExtra"
#!/usr/bin/env bash

function migratePreferece() {
LEGACY_TZPREFS="$HOME/Library/Application Support/Alfred 3/Workflow Data/carlosnz.timezones"
[[ ! -d "$TZPREFS" ]] && mkdir -p "$TZPREFS" 2>/dev/null
[[ ! -e "$TZPREFS/timezones.txt" ]] && cp "$LEGACY_TZPREFS/"* "$TZPREFS/" 2>/dev/null
[[ ! -e "$timezone_file" ]] && cp "$LEGACY_TZPREFS/"* "$TZPREFS/" 2>/dev/null
[[ -e "$TZPREFS/config-1-5" ]] && rm "$TZPREFS/config-1-5" 2>/dev/null
}

@@ -33,15 +28,24 @@ function getPreference() {
echo "$VALUE"
}

#Working Directories
#includes for TimeZones scripts
TZPREFS="$alfred_workflow_data"
CONFIG_EXTRA="$TZPREFS/configExtra"
TIMEZONE_PATH="$(getPreference 'TIMEZONE_PATH' "$TZPREFS" )"

#Load path to the user's timezones.txt file.
timezone_file="$TIMEZONE_PATH/timezones.txt"

# echo "$TIMEZONE_PATH" >> /tmp/bzz
# ls -l "$TIMEZONE_PATH" >> /tmp/bzz

#Enable aliases for this script
shopt -s expand_aliases

#Case-insensitive matching
shopt -s nocasematch

#Load path to the user's timezones.txt file.
timezone_file="$TZPREFS/timezones.txt"

migratePreferece

#Does the file actually exist?
17 changes: 11 additions & 6 deletions source/info.plist
Original file line number Diff line number Diff line change
@@ -721,7 +721,7 @@
<key>subtext</key>
<string>Results will not be sorted and will follow order from timezones.txt</string>
<key>text</key>
<string>Disable result ordering</string>
<string>Disable result sorting</string>
<key>withspace</key>
<false/>
</dict>
@@ -807,9 +807,9 @@
<key>keyword</key>
<string>timezone sort on</string>
<key>subtext</key>
<string>Results will not sorted with Favourites on the top</string>
<string>Results will be sorted with Favourites on the top</string>
<key>text</key>
<string>Enable result ordering</string>
<string>Enable result sorting</string>
<key>withspace</key>
<false/>
</dict>
@@ -887,8 +887,8 @@
</dict>
</array>
<key>readme</key>
<string>TimeZones v2.13
14 August 2019
<string>TimeZones v2.14
1 September 2019
@@ -934,6 +934,11 @@ CHANGELOG
All issues tracked on GitHub https://github.com/jaroslawhartman/TimeZones-Alfred/issues
v2.14
1 September 2019
* Reverted handling of Dropbox timezones.txt (#23)
* Asking wheither override when an existing timezones.txt in the new location (#27)
v2.13
26 August 2019
* Fixed an issue when more than 7 TimeZones (#28)
@@ -1250,7 +1255,7 @@ v1.0
</dict>
</dict>
<key>version</key>
<string>2.13</string>
<string>2.14</string>
<key>webaddress</key>
<string>https://jhartman.pl/tag/time-zones/</string>
</dict>
39 changes: 31 additions & 8 deletions source/move.sh
Original file line number Diff line number Diff line change
@@ -12,23 +12,46 @@ end tell
EOF)
if [ -z $user_path ]; then
if [[ -z "${user_path}" ]]; then
exit
fi
#Move timezones.txt
mv "$timezone_file" "$user_path"
yes_no="override"
# Check if timezones.txt exists in the target
# Ask if override
if [[ -e "${user_path}/timezones.txt" ]]
then
yes_no=$(osascript <<-EOF
tell application "System Events"
activate
display alert "A timezones.txt exists in the new location.\nUse config from the new location or override it by the current config?" buttons {"New location", "Override"}
if button returned of result = "Override" then
return "override"
end if
end tell
EOF)
fi
if [[ "$yes_no" == "override" ]]
then
#Move timezones.txt
cp "$timezone_file" "$user_path"
result="$?"
else
result=0
fi
#If file operation successful
if [ $? = 0 ]; then
#Update config file with new path
echo "$user_path/timezones.txt" > "$TZPREFS/config-1-5"
if [[ $result = 0 ]]; then
storePreference "TIMEZONE_PATH" "$user_path"
#Notify
echo -n "File successfully moved to new location."
echo -n "Using timezones.txt file from $user_path."
else
#Notify
echo -n "Sorry, unable to move to that location."
echo -n "Sorry, unable to move to that location $user_path."
fi
exit

0 comments on commit ff9f3f8

Please sign in to comment.