diff --git a/completion/bash/m b/completion/bash/m index e0704f8..b1f6a6a 100644 --- a/completion/bash/m +++ b/completion/bash/m @@ -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) ;; diff --git a/completion/fish/m.fish b/completion/fish/m.fish index 3060ac7..4cae316 100755 --- a/completion/fish/m.fish +++ b/completion/fish/m.fish @@ -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' diff --git a/completion/zsh/_m b/completion/zsh/_m index f2dc0df..eadd1a0 100644 --- a/completion/zsh/_m +++ b/completion/zsh/_m @@ -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 \ diff --git a/plugins/animations b/plugins/animations new file mode 100755 index 0000000..b17ad04 --- /dev/null +++ b/plugins/animations @@ -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