Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add animations #156

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions completion/bash/m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ _m_sub () {
airdrop)
subcommands=(status on enable off disable help)
;;
animations)
subcommands=(mail inputs finder fullscreen windows quicklook)
;;
appearance)
subcommands=(darkmode transparency antialiasthreshold sidebariconsize maincolor highlightcolor)
;;
Expand Down
9 changes: 9 additions & 0 deletions completion/fish/m.fish
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ complete -f -c m -n '__fish_m_using_command airdrop' -a "off" -d 'turn off airdr
complete -f -c m -n '__fish_m_using_command airdrop' -a "disable" -d 'turn off airdrop'
complete -f -c m -n '__fish_m_using_command airdrop' -a "help" -d 'Show help'

complete -f -c m -n '__fish_m_needs_command' -a animations -d 'Manage animation use'
complete -f -c m -n '__fish_m_needs_command animations' -a mail -d 'Use animations in mail'
complete -f -c m -n '__fish_m_needs_command animations' -a inputs -d 'Use animations interacting with inputs'
complete -f -c m -n '__fish_m_needs_command animations' -a finder -d 'Use animations in finder'
complete -f -c m -n '__fish_m_needs_command animations' -a fullscreen -d 'Use animations in fullscreen'
complete -f -c m -n '__fish_m_needs_command animations' -a windows -d 'Use animations in windows'
complete -f -c m -n '__fish_m_needs_command animations' -a quicklook -d 'Use animations in quicklook'

complete -f -c m -n '__fish_m_needs_command' -a appearance -d 'Manage appearance'
complete -f -c m -n '__fish_m_using_command appearance' -a "darkmode" -d 'Manage dark mode'
complete -f -c m -n '__fish_m_using_command appearance' -a "transparency" -d 'Manage transparency'
complete -f -c m -n '__fish_m_using_command appearance' -a "antialiasthreshold" -d 'Manage anti-alias threshold'
Expand Down
10 changes: 10 additions & 0 deletions completion/zsh/_m
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,16 @@ function _m_cmd {
"disable:turn off airdrop" \
help
;;
animations)
_m_solo \
$sub \
"mail:use animations in mail" \
"inputs:use animations interacting with inputs" \
"finder:use animations in finder" \
"fullscreen:use animations in fullscreen" \
"windows:use animations in windows" \
"quicklook:use animations in quicklook"
;;
appearance)
_m_solo \
$sub \
Expand Down
125 changes: 125 additions & 0 deletions plugins/animations
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#!/usr/bin/env bash

source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh"
source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh"

declare command
command="$(basename "$0")"
declare subcommand="$1"

[ $# -gt 0 ] && shift

help(){
cat<<__EOF__
Usage:
m animations mail [ YES | NO ] # Use animations in mail
m animations inputs [ YES | NO ] # Use animations interacting with inputs
m animations finder [ YES | NO ] # Use animations in finder/desktop
m animations fullscreen [ YES | NO ] # Use animations in fullscreen
m animations windows [ YES | NO ] [ x.x ] # Use animations when opening, closing or resizing windows (with optional speed factor)
m animations quicklook [ YES | NO ] [ x.x ] # Use animations when using quicklook
__EOF__
}

mail(){
value="$(_mcli_defaults_yes_no_to_boolean "com.apple.mail" \
"DisableReplyAnimations" \
"$1")"
value="$(_mcli_defaults_yes_no_to_boolean "com.apple.mail" \
"DisableSendAnimations" \
"$1")"

echo "${command} ${subcommand}: ${value}"
}

inputs() {
value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \
"NSUseAnimatedFocusRing" \
"$1")"

echo "${command} ${subcommand}: ${value}"
}

finder() {
value="$(_mcli_defaults_yes_no_to_inverted_boolean "com.apple.finder" \
"DisableAllAnimations" \
"$1")"
value="$(_mcli_defaults_yes_no_to_boolean "com.apple.finder" \
"AnimateInfoPanes" \
"$1")"
value="$(_mcli_defaults_yes_no_to_boolean "com.apple.finder" \
"AnimateSnapToGrid" \
"$1")"
value="$(_mcli_defaults_yes_no_to_boolean "com.apple.finder" \
"ZoomRects" \
"$1")"
value="$(_mcli_defaults_yes_no_to_boolean "com.apple.finder" \
"AnimateWindowZoom" \
"$1")"

echo "${command} ${subcommand}: ${value}"
}

fullscreen(){
value="$(_mcli_defaults_yes_no_to_inverted_boolean "com.apple.dock" \
"workspaces-swoosh-animation-off" \
"$1")"

echo "${command} ${subcommand}: ${value}"
}

windows() {
# Toggle Open/Close Window Animations
value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \
"NSAutomaticWindowAnimationsEnabled" \
"$1")"

# Sets the Length of Time in Seconds When a Window is Resized
_mcli_defaults_yes_no_to_number "NSGlobalDomain" \
"NSWindowResizeTime" \
"$2"

echo "${command} ${subcommand}: ${value}"
}

quicklook() {
local choice
choice="$(_mcli_convert_yes_no_to_boolean "$1")"
local duration="$2"

[[ "${choice}" == "false" ]] && duration="0"

# Sets the Length of Time in Seconds When a Window is Resized
value="$(_mcli_defaults_number "NSGlobalDomain" \
"QLPanelAnimationDuration" \
"${duration}")"

echo "${command} ${subcommand}: ${value}"
}

case "${subcommand}" in
help)
help
;;
mail)
mail "$@"
;;
inputs)
inputs "$@"
;;
finder)
finder "$@"
;;
fullscreen)
fullscreen "$@"
;;
windows)
windows "$@"
;;
quicklook)
quicklook "$@"
;;
*)
help
;;
esac