Merge pull request #904 from JadeMatrix/master

macOS fixes & improvements
This commit is contained in:
Dylan Araps 2018-02-03 09:07:10 +11:00 committed by GitHub
commit b6b1dfc2fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 48 additions and 13 deletions

View File

@ -926,14 +926,19 @@ get_wm_theme() {
;;
"Quartz Compositor")
wm_theme="$(PlistBuddy -c "Print AppleAquaColorVariant" \
"${HOME}/Library/Preferences/.GlobalPreferences.plist")"
global_preferences="${HOME}/Library/Preferences/.GlobalPreferences.plist"
wm_theme="$(PlistBuddy -c "Print AppleInterfaceStyle" "$global_preferences")"
wm_theme_color="$(PlistBuddy -c "Print AppleAquaColorVariant" "$global_preferences")"
if [[ -z "$wm_theme" ]] || ((wm_theme == 1)); then
wm_theme="Blue"
[[ -z "$wm_theme" ]] && wm_theme="Light"
if [[ -z "$wm_theme_color" ]] || ((wm_theme_color == 1)); then
wm_theme_color="Blue"
else
wm_theme="Graphite"
wm_theme_color="Graphite"
fi
wm_theme="$wm_theme_color ($wm_theme)"
;;
*"Explorer")
@ -1522,7 +1527,7 @@ get_memory() {
}
get_song() {
player="$(ps -e | grep -m 1 -o -F \
player="$(ps -e | grep -m 1 -o \
-e "Google Play" \
-e "Spotify" \
-e "amarok" \
@ -1537,7 +1542,7 @@ get_song() {
-e "exaile" \
-e "gnome-music" \
-e "guayadeque" \
-e "iTunes.app" \
-e "iTunes$" \
-e "juk" \
-e "lollypop" \
-e "mocp" \
@ -1603,13 +1608,29 @@ get_song() {
"Linux") get_song_dbus "spotify" ;;
"Mac OS X")
song="$(osascript -e 'tell application "Spotify" to artist of current track as string & " - " & name of current track as string')"
song="$(osascript <<END
if application "Spotify" is running then
tell application "Spotify"
artist of current track as string & \
" - " & name of current track as string
end tell
end if
END
)"
;;
esac
;;
"itunes"*)
song="$(osascript -e 'tell application "iTunes" to artist of current track as string & " - " & name of current track as string')"
song="$(osascript <<END
if application "iTunes" is running then
tell application "iTunes"
artist of current track as string & \
" - " & name of current track as string
end tell
end if
END
)"
;;
"banshee"*)
@ -1965,7 +1986,10 @@ get_term_font() {
;;
"Apple_Terminal")
term_font="$(osascript -e 'tell application "Terminal" to font name of window frontmost')"
term_font="$(osascript <<END
tell application "Terminal" to font name of window frontmost
END
)"
;;
"iTerm2")
@ -1976,7 +2000,11 @@ get_term_font() {
# See: https://groups.google.com/forum/#!topic/iterm2-discuss/0tO3xZ4Zlwg
local current_profile_name profiles_count profile_name diff_font none_ascii
current_profile_name="$(osascript -e 'tell application "iTerm2" to profile name of current session of current window')"
current_profile_name="$(osascript <<END
tell application "iTerm2" to profile name \
of current session of current window
END
)"
# Warning: Dynamic profiles are not taken into account here!
# https://www.iterm2.com/documentation-dynamic-profiles.html
@ -2620,7 +2648,10 @@ get_image_source() {
get_wallpaper() {
case "$os" in
"Mac OS X")
image="$(osascript -e 'tell application "System Events" to picture of current desktop')"
image="$(osascript <<END
tell application "System Events" to picture of current desktop
END
)"
;;
"Windows")
@ -3232,7 +3263,11 @@ strip_sequences() {
}
uppercase() {
((bash_version >= 4)) && printf "%s" "${1^}"
if ((bash_version >= 4)); then
printf "%s" "${1^}"
else
printf "%s" "$1"
fi
}
# COLORS