From c00bbd5dcba9ab65346fbc1ce95c0aa89f481361 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Thu, 5 Jan 2017 15:05:07 -0600 Subject: [PATCH 001/100] Add airdrop plugin --- Readme.md | 12 +++++++++++- plugins/airdrop | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100755 plugins/airdrop diff --git a/Readme.md b/Readme.md index 9af3b07..4396fa8 100644 --- a/Readme.md +++ b/Readme.md @@ -45,6 +45,7 @@ usage: m [OPTIONS] COMMAND [help] COMMANDS: help + airdrop battery bluetooth dir @@ -57,7 +58,7 @@ usage: m [OPTIONS] COMMAND [help] gatekeeper hostname info - itunes + itunes lock ntp printer @@ -81,6 +82,15 @@ usage: m [OPTIONS] COMMAND [help] ``` +#### Airdrop: +``` + usage: m airdrop [ onlywifi | help ] + + Examples: + m airdrop onlywifi YES # allow airdropping only via WIFI + m airdrop onlywifi NO # allow airdropping via any network interface +``` + #### Battery: ``` usage: m battery [ status | help ] diff --git a/plugins/airdrop b/plugins/airdrop new file mode 100755 index 0000000..572e0fe --- /dev/null +++ b/plugins/airdrop @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +help(){ + cat<<__EOF__ + usage: m airdrop [ onlywifi | help ] + + Examples: + m airdrop onlywifi YES # allow airdropping only via WIFI + m airdrop onlywifi NO # allow airdropping via any network interface +__EOF__ +} + +onlywifi(){ + case $1 in + [yY][eE][sS]) + defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true + echo "Airdrop onlywifi: YES" + ;; + [nN][oO]) + defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool false + echo "Airdrop onlywifi: NO" + ;; + *) + VALUE=$(defaults read com.apple.NetworkBrowser BrowseAllInterfaces) + if [ "${VALUE}" -eq 1 ]; then + echo "Airdrop onlywifi: YES" + else + echo "Airdrop onlywifi: NO" + fi + ;; + esac +} + +case $1 in + help) + help + ;; + onlywifi) + shift + onlywifi $@ + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab From 006986bcd157796bd57d1c560b91bcf70fa38340 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Thu, 5 Jan 2017 15:42:26 -0600 Subject: [PATCH 002/100] Add airport plugin --- Readme.md | 40 ++++++++++ plugins/airport | 189 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 229 insertions(+) create mode 100755 plugins/airport diff --git a/Readme.md b/Readme.md index 4396fa8..d1684bd 100644 --- a/Readme.md +++ b/Readme.md @@ -91,6 +91,46 @@ usage: m [OPTIONS] COMMAND [help] m airdrop onlywifi NO # allow airdropping via any network interface ``` +#### Airport: +``` + usage: m airport [ + disconnectonlogout | + preferrednetworks | + nonpreferrednetworks | + rememberrecents | + secureadhocnetworks | + securechangenetworks | + securetogglepower | + help + ] + + Examples: + m airport disconnectonlogout [ YES | NO ] # whether to disconnect from wifi when logging out + m airport rememberrecents [ YES | NO ] # whether to remember recent networks + + m airport preferrednetworks [ # what to do when preferred networks are available + Automatic | + Preferred | + Ranked | + Recent | + Strongest + ] + + m airport nonpreferrednetworks [ # how to join non-preferred networks if preferred + Prompt | # networks are unavailable + JoinOpen | + KeepLooking | + DoNothing + ] + + m airport secureadhocnetworks [ YES | NO ] # whether a password is required to create a + # computer-to-computer network + m airport securechangenetworks [ YES | NO ] # whether a password is required to change + # networks + m airport securetogglepower [ YES | NO ] # whether a password is required to turn + # wi-fi on or off +``` + #### Battery: ``` usage: m battery [ status | help ] diff --git a/plugins/airport b/plugins/airport new file mode 100755 index 0000000..ac834a6 --- /dev/null +++ b/plugins/airport @@ -0,0 +1,189 @@ +#!/usr/bin/env bash + +declare path_to_airport_binary="/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport" + +help(){ + cat<<__EOF__ + usage: m airport [ + disconnectonlogout | + preferrednetworks | + nonpreferrednetworks | + rememberrecents | + secureadhocnetworks | + securechangenetworks | + securetogglepower | + help + ] + + Examples: + m airport disconnectonlogout [ YES | NO ] # whether to disconnect from wifi when logging out + m airport rememberrecents [ YES | NO ] # whether to remember recent networks + + m airport preferrednetworks [ # what to do when preferred networks are available + Automatic | + Preferred | + Ranked | + Recent | + Strongest + ] + + m airport nonpreferrednetworks [ # how to join non-preferred networks if preferred + Prompt | # networks are unavailable + JoinOpen | + KeepLooking | + DoNothing + ] + + m airport secureadhocnetworks [ YES | NO ] # whether a password is required to create a + # computer-to-computer network + m airport securechangenetworks [ YES | NO ] # whether a password is required to change + # networks + m airport securetogglepower [ YES | NO ] # whether a password is required to turn + # wi-fi on or off +__EOF__ +} + +disconnectonlogout(){ + case $1 in + [yY][eE][sS]) + sudo "${path_to_airport_binary}" prefs DisconnectOnLogout="YES" + echo "Airport disconnectonlogout: YES" + ;; + [nN][oO]) + sudo "${path_to_airport_binary}" prefs DisconnectOnLogout="NO" + echo "Airport disconnectonlogout: NO" + ;; + *) + sudo "${path_to_airport_binary}" prefs DisconnectOnLogout + ;; + esac +} + +nonpreferrednetworks(){ + [ -n "$1" ] && sudo "${path_to_airport_binary}" prefs JoinModeFallback="$1" + + sudo "${path_to_airport_binary}" prefs JoinModeFallback +} + +preferrednetworks(){ + [ -n "$1" ] && sudo "${path_to_airport_binary}" prefs JoinMode="$1" + + sudo "${path_to_airport_binary}" prefs JoinMode +} + +rememberrecents(){ + case $1 in + [yY][eE][sS]) + sudo "${path_to_airport_binary}" prefs RememberRecentNetworks="YES" + echo "Airport rememberrecents: YES" + ;; + [nN][oO]) + sudo "${path_to_airport_binary}" prefs RememberRecentNetworks="NO" + echo "Airport rememberrecents: NO" + ;; + *) + sudo "${path_to_airport_binary}" prefs RememberRecentNetworks + ;; + esac +} + +secureadhocnetworks(){ + case $1 in + [yY][eE][sS]) + sudo "${path_to_airport_binary}" prefs RememberRecentNetworks="YES" + echo "Airport secureadhocnetworks: YES" + ;; + [nN][oO]) + sudo "${path_to_airport_binary}" prefs RequireAdminIBSS="NO" + echo "Airport secureadhocnetworks: NO" + ;; + *) + sudo "${path_to_airport_binary}" prefs RequireAdminIBSS + ;; + esac +} + +securechangenetworks(){ + case $1 in + [yY][eE][sS]) + sudo "${path_to_airport_binary}" prefs RequireAdminNetworkChange="YES" + echo "Airport securechangenetworks: YES" + ;; + [nN][oO]) + sudo "${path_to_airport_binary}" prefs RequireAdminNetworkChange="NO" + echo "Airport securechangenetworks: NO" + ;; + *) + sudo "${path_to_airport_binary}" prefs RequireAdminNetworkChange + ;; + esac +} + +securechangenetworks(){ + case $1 in + [yY][eE][sS]) + sudo "${path_to_airport_binary}" prefs RequireAdminNetworkChange="YES" + echo "Airport securechangenetworks: YES" + ;; + [nN][oO]) + sudo "${path_to_airport_binary}" prefs RequireAdminNetworkChange="NO" + echo "Airport securechangenetworks: NO" + ;; + *) + sudo "${path_to_airport_binary}" prefs RequireAdminNetworkChange + ;; + esac +} + +securetogglepower(){ + case $1 in + [yY][eE][sS]) + sudo "${path_to_airport_binary}" prefs RequireAdminPowerToggle="YES" + echo "Airport securetogglepower: YES" + ;; + [nN][oO]) + sudo "${path_to_airport_binary}" prefs RequireAdminPowerToggle="NO" + echo "Airport securetogglepower: NO" + ;; + *) + sudo "${path_to_airport_binary}" prefs RequireAdminPowerToggle + ;; + esac +} + +case $1 in + help) + help + ;; + disconnectonlogout) + shift + disconnectonlogout $@ + ;; + nonpreferrednetworks) + shift + preferrednetworks $@ + ;; + preferrednetworks) + shift + preferrednetworks $@ + ;; + rememberrecents) + shift + rememberrecents $@ + ;; + secureadhocnetworks) + shift + secureadhocnetworks $@ + ;; + securechangenetworks) + shift + securechangenetworks $@ + ;; + securetogglepower) + shift + securetogglepower $@ + ;; + *) + help + ;; +esac From 1e0a7d370ae56ebca82ac9296010b513b8b5d29f Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Thu, 5 Jan 2017 16:08:20 -0600 Subject: [PATCH 003/100] Add debugmode plugin --- Readme.md | 6 +++++ plugins/debugmode | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100755 plugins/debugmode diff --git a/Readme.md b/Readme.md index d1684bd..df2a974 100644 --- a/Readme.md +++ b/Readme.md @@ -149,6 +149,12 @@ usage: m [OPTIONS] COMMAND [help] m bluetooth disable # turn off bluetooth ``` +#### Debug Mode: +``` + usage: m debugmode [ enable | disable ] # whether extra debugging options should + # be exposed for various applications +``` + #### Disk: ``` diff --git a/plugins/debugmode b/plugins/debugmode new file mode 100755 index 0000000..1a68411 --- /dev/null +++ b/plugins/debugmode @@ -0,0 +1,67 @@ +#!/usr/bin/env bash + +help(){ + cat<<__EOF__ + usage: m debugmode [ enable | disable ] # whether extra debugging options should + # be exposed for various applications +__EOF__ +} + +_toggle_debug_mode(){ + local enabled="$1" + + # Toggle Disk Utility Debug Mode + defaults write com.apple.DiskUtility DUDebugMenuEnabled -bool "${enabled}" + defaults write com.apple.diskcopy expert-mode -bool "${enabled}" + + # Toggle Address Book Debug Mode + defaults write com.apple.addressbook ABShowDebugMenu -bool "${enabled}" + + # Toggle Calendar Debug Mode + defaults write com.apple.iCal IncludeDebugMenu -bool "${enabled}" + + # Toggle Safari Debug Mode + defaults write com.apple.Safari IncludeInternalDebugMenu -bool "${enabled}" + + # Toggle App Store Debug Mode + defaults write com.apple.appstore ShowDebugMenu -bool "${enabled}" + defaults write com.apple.appstore WebKitDeveloperExtras -bool "${enabled}" + + # Toggle Help Viewer Debug Mode + defaults write com.apple.helpviewer DevMode -bool "${enabled}" + + # Toggle Developer Extras in All Web Views + sudo defaults write NSGlobalDomain WebKitDeveloperExtras -bool "${enabled}" + + # Toggle iBooks Debug Mode + defaults write com.apple.iBooksX BKShowDebugMenu -bool "${enabled}" + + # Toggle PhotoBooth Debug Mode + defaults write com.apple.PhotoBooth EnableDebugMenu -bool "${enabled}" + + # Toggle Reminders Debug Mode + defaults write com.apple.reminders RemindersDebugMenu -bool "${enabled}" + + # Toggle ScreenSharing Debug Mode + defaults write com.apple.ScreenSharing debug -bool "${enabled}" + + # Toggle TimeMachine Debug Mode + defaults write com.apple.Backup IncludeDebugMenu -bool "${enabled}" +} + +case $1 in + help) + help + ;; + enable) + shift + _toggle_debug_mode "true" + ;; + disable) + shift + _toggle_debug_mode "false" + ;; + *) + help + ;; +esac From febeb9d9e4117e43c733b7f890b5e7b174bb59d9 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Thu, 5 Jan 2017 16:18:23 -0600 Subject: [PATCH 004/100] Add lightsensor subcommand to display --- Readme.md | 7 ++++--- plugins/display | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/Readme.md b/Readme.md index df2a974..4ba06e0 100644 --- a/Readme.md +++ b/Readme.md @@ -188,11 +188,12 @@ usage: m [OPTIONS] COMMAND [help] #### Display: ``` - usage: m display [ status | help ] + usage: m display [ status | lightsensor | help ] Example: - m display status # status of displays - m display help # show usage + m display status # status of displays + m display autobrightness [ YES | NO ] # whether to enable the ambient light sensor + # to automatically darken/brighten the screen ``` #### Dns: diff --git a/plugins/display b/plugins/display index 85073c0..06cbc62 100755 --- a/plugins/display +++ b/plugins/display @@ -1,12 +1,15 @@ #!/usr/bin/env bash +declare path_to_plist="/Library/Preferences/com.apple.iokit.AmbientLightSensor" + help(){ cat<<__EOF__ - usage: m display [ status | help ] + usage: m display [ status | autobrightness | help ] Example: - m display status # status of displays - m display help # show usage + m display status # status of displays + m display autobrightness [ YES | NO ] # whether to enable the ambient light sensor + # to automatically darken/brighten the screen __EOF__ } @@ -14,6 +17,27 @@ display_status(){ system_profiler SPDisplaysDataType } +autobrightness() { + case $1 in + [yY][eE][sS]) + sudo defaults write "${path_to_plist}" "Automatic Display Enabled" -int 1 + echo "Display autobrightness: YES" + ;; + [nN][oO]) + sudo defaults write "${path_to_plist}" "Automatic Display Enabled" -int 0 + echo "Display autobrightness: NO" + ;; + *) + VALUE=$(sudo defaults read "${path_to_plist}" "Automatic Display Enabled") + if [ "${VALUE}" -eq 1 ]; then + echo "Display autobrightness: YES" + else + echo "Display autobrightness: NO" + fi + ;; + esac +} + case $1 in help) help @@ -21,6 +45,9 @@ case $1 in status) display_status ;; + autobrightness) + autobrightness $@ + ;; *) help ;; From ae21fa6430ab37eb82b10e3fc1a16fac5694945a Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Thu, 5 Jan 2017 16:26:53 -0600 Subject: [PATCH 005/100] Fix dock pruning so that it always works And so that it always wipes out all items. --- plugins/dock | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/dock b/plugins/dock index 366a84f..3e4bb36 100755 --- a/plugins/dock +++ b/plugins/dock @@ -109,8 +109,13 @@ add_recent_items(){ } prune(){ - echo "remove all items from stack" - defaults write com.apple.dock persistent-apps '()' + echo "remove all items from the Dock" + defaults write com.apple.dock checked-for-launchpad -bool true + defaults write com.apple.dock persistent-apps -array "" + defaults write com.apple.dock persistent-others -array "" + + rm -f ${HOME}/Library/Application\ Support/Dock/*.db 2> /dev/null + killall Dock } From 7d0817f0d36d2985ffa51148d1baca55e3b8f84c Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Thu, 5 Jan 2017 16:33:35 -0600 Subject: [PATCH 006/100] Allow the dock to be completely disabled --- Readme.md | 4 +++- plugins/dock | 20 +++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 4ba06e0..e59a25a 100644 --- a/Readme.md +++ b/Readme.md @@ -207,9 +207,11 @@ usage: m [OPTIONS] COMMAND [help] #### Dock: ``` - usage: m dock [ showdelay | autohide | magnification | position | addblankspace | addrecentitems | prune | help ] + usage: m dock [ enable | disable | autohide | magnification | position | addblankspace | addrecentitems | prune | help ] Examples: + m dock enable # Shows the Dock + m dock disable # Causes the Dock to be hidden and never reappear m dock showdelay x.x # Changes how long the Dock takes to show up when auto-hide is enabled m dock autohide YES # Enable Dock's auto hide feature m dock autohide NO # Disable Dock's auto hide feature diff --git a/plugins/dock b/plugins/dock index 3e4bb36..c0b946d 100755 --- a/plugins/dock +++ b/plugins/dock @@ -2,9 +2,11 @@ help(){ cat<<__EOF__ - usage: m dock [ showdelay | autohide | magnification | position | addblankspace | addrecentitems | prune | help ] + usage: m dock [ enable | disable | showdelay | autohide | magnification | position | addblankspace | addrecentitems | prune | help ] Examples: + m dock enable # Shows the Dock + m dock disable # Causes the Dock to be hidden and never reappear m dock showdelay x.x # Changes how long the Dock takes to show up when auto-hide is enabled m dock autohide YES # Enable Dock's auto hide feature m dock autohide NO # Disable Dock's auto hide feature @@ -20,6 +22,16 @@ help(){ __EOF__ } +enable(){ + auto_hide "NO" + show_delay 0.25 +} + +disable(){ + auto_hide "YES" + show_delay 999999 +} + show_delay(){ case $1 in [0-9][.][0-9]) @@ -123,6 +135,12 @@ case $1 in help) help ;; + enable) + enable + ;; + disable) + disable + ;; showdelay) shift show_delay $@ From 9aba633779b1ce4ebd1f86cfeff32c4e1aaaf19c Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Thu, 5 Jan 2017 16:46:44 -0600 Subject: [PATCH 007/100] Add autohidedelay and autohidespeed to dock The previous `show_delay` was incorrect. It was changing the speed of the transition, not the delay before the transition started. I left `show_delay` in there and mapped it to the (incorrect) `auto_hide_speed` for backwards compatibility but removed reference to it from the README. --- Readme.md | 6 ++++-- plugins/dock | 42 +++++++++++++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/Readme.md b/Readme.md index e59a25a..b052f2e 100644 --- a/Readme.md +++ b/Readme.md @@ -207,12 +207,14 @@ usage: m [OPTIONS] COMMAND [help] #### Dock: ``` - usage: m dock [ enable | disable | autohide | magnification | position | addblankspace | addrecentitems | prune | help ] + usage: m dock [ enable | disable | autohidedelay | autohidespeed | autohide | magnification | position | addblankspace | addrecentitems | prune | help ] Examples: m dock enable # Shows the Dock m dock disable # Causes the Dock to be hidden and never reappear - m dock showdelay x.x # Changes how long the Dock takes to show up when auto-hide is enabled + m dock autohidedelay x.x # Changes how long the Dock takes to show up when auto-hide is enabled + m dock autohidespeed x.x # Changes how long the Dock takes to slide into/out of view after the + # delay has expired m dock autohide YES # Enable Dock's auto hide feature m dock autohide NO # Disable Dock's auto hide feature m dock magnification YES # Turn magnification on diff --git a/plugins/dock b/plugins/dock index c0b946d..ddb5514 100755 --- a/plugins/dock +++ b/plugins/dock @@ -2,12 +2,14 @@ help(){ cat<<__EOF__ - usage: m dock [ enable | disable | showdelay | autohide | magnification | position | addblankspace | addrecentitems | prune | help ] + usage: m dock [ enable | disable | autohidedelay | autohidespeed | autohide | magnification | position | addblankspace | addrecentitems | prune | help ] Examples: m dock enable # Shows the Dock m dock disable # Causes the Dock to be hidden and never reappear - m dock showdelay x.x # Changes how long the Dock takes to show up when auto-hide is enabled + m dock autohidedelay x.x # Changes how long the Dock takes to show up when auto-hide is enabled + m dock autohidespeed x.x # Changes how long the Dock takes to slide into/out of view after the + # delay has expired m dock autohide YES # Enable Dock's auto hide feature m dock autohide NO # Disable Dock's auto hide feature m dock magnification YES # Turn magnification on @@ -32,18 +34,36 @@ disable(){ show_delay 999999 } -show_delay(){ +auto_hide_speed(){ case $1 in [0-9][.][0-9]) - echo "New Auto-Hide time: "$1 + echo "New Auto-Hide speed: "$1 defaults write com.apple.dock autohide-time-modifier -float $1 ;; [0-9]) - echo "New Auto-Hide time: "$1 + echo "New Auto-Hide speed: "$1 defaults write com.apple.dock autohide-time-modifier -int $1 ;; *) - echo "Current Auto-Hide time: $(defaults read com.apple.dock autohide-time-modifier 2>/dev/null)" + echo "Current Auto-Hide speed: $(defaults read com.apple.dock autohide-time-modifier 2>/dev/null)" + exit 0 + ;; + esac + killall Dock +} + +auto_hide_delay(){ + case $1 in + [0-9][.][0-9]) + echo "New Auto-Hide delay: "$1 + defaults write com.apple.dock autohide-delay -float $1 + ;; + [0-9]) + echo "New Auto-Hide delay: "$1 + defaults write com.apple.dock autohide-delay -int $1 + ;; + *) + echo "Current Auto-Hide delay: $(defaults read com.apple.dock autohide-delay 2>/dev/null)" exit 0 ;; esac @@ -143,7 +163,15 @@ case $1 in ;; showdelay) shift - show_delay $@ + auto_hide_speed $@ + ;; + autohidedelay) + shift + auto_hide_delay $@ + ;; + autohidespeed) + shift + auto_hide_speed $@ ;; autohide) shift From 70759c9a1ac7cb2885e287da17a1cf048f43b252 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Thu, 5 Jan 2017 16:55:41 -0600 Subject: [PATCH 008/100] Add magnificationsize to the dock --- Readme.md | 8 ++++---- plugins/dock | 25 ++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/Readme.md b/Readme.md index b052f2e..25e4e83 100644 --- a/Readme.md +++ b/Readme.md @@ -207,7 +207,7 @@ usage: m [OPTIONS] COMMAND [help] #### Dock: ``` - usage: m dock [ enable | disable | autohidedelay | autohidespeed | autohide | magnification | position | addblankspace | addrecentitems | prune | help ] + usage: m dock [ enable | disable | autohidedelay | autohidespeed | autohide | magnification | magnificationsize | position | addblankspace | addrecentitems | prune | help ] Examples: m dock enable # Shows the Dock @@ -219,14 +219,14 @@ usage: m [OPTIONS] COMMAND [help] m dock autohide NO # Disable Dock's auto hide feature m dock magnification YES # Turn magnification on m dock magnification NO # Turn magnification off + m dock magnificationsize x # Set the max size of the icons as the cursor gets closer to them m dock position BOTTOM # Change Dock's position to the bottom of the screen m dock position LEFT # Change Dock's position to the left of the screen m dock position RIGHT # Change Dock's position to the right of the screen m dock addblankspace # Add a blank space (separator) to the Dock m dock addrecentitems # Add a stack containg your recent items to the Dock - # (You can change the stack's type by right clicking on it) - m dock prune # Removes all apps from Dock - + # (You can change the stack's type by right clicking on it) + m dock prune # Remove all items from dock ``` #### Dir: diff --git a/plugins/dock b/plugins/dock index ddb5514..eda67ec 100755 --- a/plugins/dock +++ b/plugins/dock @@ -2,7 +2,7 @@ help(){ cat<<__EOF__ - usage: m dock [ enable | disable | autohidedelay | autohidespeed | autohide | magnification | position | addblankspace | addrecentitems | prune | help ] + usage: m dock [ enable | disable | autohidedelay | autohidespeed | autohide | magnification | magnificationsize | position | addblankspace | addrecentitems | prune | help ] Examples: m dock enable # Shows the Dock @@ -14,13 +14,14 @@ help(){ m dock autohide NO # Disable Dock's auto hide feature m dock magnification YES # Turn magnification on m dock magnification NO # Turn magnification off + m dock magnificationsize x # Set the max size of the icons as the cursor gets closer to them m dock position BOTTOM # Change Dock's position to the bottom of the screen m dock position LEFT # Change Dock's position to the left of the screen m dock position RIGHT # Change Dock's position to the right of the screen m dock addblankspace # Add a blank space (separator) to the Dock m dock addrecentitems # Add a stack containg your recent items to the Dock - # (You can change the stack's type by right clicking on it) - m dock prune # remove all items from dock + # (You can change the stack's type by right clicking on it) + m dock prune # Remove all items from dock __EOF__ } @@ -106,6 +107,20 @@ magnify(){ killall Dock } +magnification_size(){ + case $1 in + [0-9]*) + echo "New magnification size: ${1}px" + defaults write com.apple.dock largesize -int "$1" + ;; + *) + echo "Current magnification size: $(defaults read com.apple.dock largesize 2>/dev/null)px" + exit 0 + ;; + esac + killall Dock +} + dock_position(){ case $1 in [bB][oO][tT][tT][oO][mM]) @@ -181,6 +196,10 @@ case $1 in shift magnify $@ ;; + magnificationsize) + shift + magnification_size $@ + ;; position) shift dock_position $@ From 0b95915c042c602747b515f952c6942be689e0d1 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Thu, 5 Jan 2017 16:59:34 -0600 Subject: [PATCH 009/100] Add iconsize to the dock --- Readme.md | 3 ++- plugins/dock | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 25e4e83..34b3f87 100644 --- a/Readme.md +++ b/Readme.md @@ -207,7 +207,7 @@ usage: m [OPTIONS] COMMAND [help] #### Dock: ``` - usage: m dock [ enable | disable | autohidedelay | autohidespeed | autohide | magnification | magnificationsize | position | addblankspace | addrecentitems | prune | help ] + usage: m dock [ enable | disable | autohidedelay | autohidespeed | autohide | magnification | magnificationsize | iconsize | position | addblankspace | addrecentitems | prune | help ] Examples: m dock enable # Shows the Dock @@ -220,6 +220,7 @@ usage: m [OPTIONS] COMMAND [help] m dock magnification YES # Turn magnification on m dock magnification NO # Turn magnification off m dock magnificationsize x # Set the max size of the icons as the cursor gets closer to them + m dock iconsize x # Set the size of the icons when the dock is at rest m dock position BOTTOM # Change Dock's position to the bottom of the screen m dock position LEFT # Change Dock's position to the left of the screen m dock position RIGHT # Change Dock's position to the right of the screen diff --git a/plugins/dock b/plugins/dock index eda67ec..068eff5 100755 --- a/plugins/dock +++ b/plugins/dock @@ -2,7 +2,7 @@ help(){ cat<<__EOF__ - usage: m dock [ enable | disable | autohidedelay | autohidespeed | autohide | magnification | magnificationsize | position | addblankspace | addrecentitems | prune | help ] + usage: m dock [ enable | disable | autohidedelay | autohidespeed | autohide | magnification | magnificationsize | iconsize | position | addblankspace | addrecentitems | prune | help ] Examples: m dock enable # Shows the Dock @@ -15,6 +15,7 @@ help(){ m dock magnification YES # Turn magnification on m dock magnification NO # Turn magnification off m dock magnificationsize x # Set the max size of the icons as the cursor gets closer to them + m dock iconsize x # Set the size of the icons when the dock is at rest m dock position BOTTOM # Change Dock's position to the bottom of the screen m dock position LEFT # Change Dock's position to the left of the screen m dock position RIGHT # Change Dock's position to the right of the screen @@ -121,6 +122,20 @@ magnification_size(){ killall Dock } +icon_size(){ + case $1 in + [0-9]*) + echo "New icon size: ${1}px" + defaults write com.apple.dock tilesize -int "$1" + ;; + *) + echo "Current icon size: $(defaults read com.apple.dock tilesize 2>/dev/null)px" + exit 0 + ;; + esac + killall Dock +} + dock_position(){ case $1 in [bB][oO][tT][tT][oO][mM]) @@ -200,6 +215,10 @@ case $1 in shift magnification_size $@ ;; + iconsize) + shift + icon_size $@ + ;; position) shift dock_position $@ From 06bcbabe45da6c01f1b21cd1e910fd1ebe734de7 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Thu, 5 Jan 2017 17:42:53 -0600 Subject: [PATCH 010/100] Add bounce effects to the dock --- Readme.md | 4 +++- plugins/dock | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 34b3f87..544fa74 100644 --- a/Readme.md +++ b/Readme.md @@ -207,11 +207,13 @@ usage: m [OPTIONS] COMMAND [help] #### Dock: ``` - usage: m dock [ enable | disable | autohidedelay | autohidespeed | autohide | magnification | magnificationsize | iconsize | position | addblankspace | addrecentitems | prune | help ] + usage: m dock [ enable | disable | bounceonappactivity | bounceonapplaunch | autohidedelay | autohidespeed | autohide | magnification | magnificationsize | iconsize | position | addblankspace | addrecentitems | prune | help ] Examples: m dock enable # Shows the Dock m dock disable # Causes the Dock to be hidden and never reappear + m dock bounceonappactivity # Bounce an app's icon when it has activity + m dock bounceonapplaunch # Bounce an app's icon when it is launching m dock autohidedelay x.x # Changes how long the Dock takes to show up when auto-hide is enabled m dock autohidespeed x.x # Changes how long the Dock takes to slide into/out of view after the # delay has expired diff --git a/plugins/dock b/plugins/dock index 068eff5..cffe04f 100755 --- a/plugins/dock +++ b/plugins/dock @@ -2,11 +2,13 @@ help(){ cat<<__EOF__ - usage: m dock [ enable | disable | autohidedelay | autohidespeed | autohide | magnification | magnificationsize | iconsize | position | addblankspace | addrecentitems | prune | help ] + usage: m dock [ enable | disable | bounceonappactivity | bounceonapplaunch | autohidedelay | autohidespeed | autohide | magnification | magnificationsize | iconsize | position | addblankspace | addrecentitems | prune | help ] Examples: m dock enable # Shows the Dock m dock disable # Causes the Dock to be hidden and never reappear + m dock bounceonappactivity # Bounce an app's icon when it has activity + m dock bounceonapplaunch # Bounce an app's icon when it is launching m dock autohidedelay x.x # Changes how long the Dock takes to show up when auto-hide is enabled m dock autohidespeed x.x # Changes how long the Dock takes to slide into/out of view after the # delay has expired @@ -36,6 +38,50 @@ disable(){ show_delay 999999 } +bounce_on_app_activity(){ + case $1 in + [yY][eE][sS]) + echo "Bounce on App Activity: YES" + defaults write com.apple.dock no-bouncing -bool "NO" + ;; + [nN][oO]) + echo "Bounce on App Activity: NO" + defaults write com.apple.dock no-bouncing -bool "YES" + ;; + *) + VALUE=$(defaults read com.apple.dock no-bouncing) + if [ "${VALUE}" -eq 1 ]; then + echo "Bounce on App Activity: NO" + else + echo "Bounce on App Activity: YES" + fi + ;; + esac + killall Dock +} + +bounce_on_app_launch(){ + case $1 in + [yY][eE][sS]) + echo "Bounce on App Launch: YES" + defaults write com.apple.dock launchanim -bool "YES" + ;; + [nN][oO]) + echo "Bounce on App Launch: NO" + defaults write com.apple.dock launchanim -bool "NO" + ;; + *) + VALUE=$(defaults read com.apple.dock launchanim) + if [ "${VALUE}" -eq 1 ]; then + echo "Bounce on App Launch: YES" + else + echo "Bounce on App Launch: NO" + fi + ;; + esac + killall Dock +} + auto_hide_speed(){ case $1 in [0-9][.][0-9]) @@ -191,6 +237,14 @@ case $1 in disable) disable ;; + bounceonappactivity) + shift + bounce_on_app_activity $@ + ;; + bounceonapplaunch) + shift + bounce_on_app_launch $@ + ;; showdelay) shift auto_hide_speed $@ From a9d1b71e2eebc0e29a4dd9a90e140f432152585e Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Thu, 5 Jan 2017 17:46:51 -0600 Subject: [PATCH 011/100] Whitespace --- Readme.md | 18 +++++++++++++++++- plugins/dock | 18 +++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 544fa74..ee9b1e3 100644 --- a/Readme.md +++ b/Readme.md @@ -207,7 +207,23 @@ usage: m [OPTIONS] COMMAND [help] #### Dock: ``` - usage: m dock [ enable | disable | bounceonappactivity | bounceonapplaunch | autohidedelay | autohidespeed | autohide | magnification | magnificationsize | iconsize | position | addblankspace | addrecentitems | prune | help ] + usage: m dock [ + enable | + disable | + bounceonappactivity | + bounceonapplaunch | + autohidedelay | + autohidespeed | + autohide | + magnification | + magnificationsize | + iconsize | + position | + addblankspace | + addrecentitems | + prune | + help + ] Examples: m dock enable # Shows the Dock diff --git a/plugins/dock b/plugins/dock index cffe04f..c3fafb1 100755 --- a/plugins/dock +++ b/plugins/dock @@ -2,7 +2,23 @@ help(){ cat<<__EOF__ - usage: m dock [ enable | disable | bounceonappactivity | bounceonapplaunch | autohidedelay | autohidespeed | autohide | magnification | magnificationsize | iconsize | position | addblankspace | addrecentitems | prune | help ] + usage: m dock [ + enable | + disable | + bounceonappactivity | + bounceonapplaunch | + autohidedelay | + autohidespeed | + autohide | + magnification | + magnificationsize | + iconsize | + position | + addblankspace | + addrecentitems | + prune | + help + ] Examples: m dock enable # Shows the Dock From 9d7f6cfc58d6e2b6e2ba28fa787741b0206d5ae2 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Thu, 5 Jan 2017 17:59:17 -0600 Subject: [PATCH 012/100] Add active indicators to dock --- Readme.md | 2 ++ plugins/dock | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/Readme.md b/Readme.md index ee9b1e3..6bd3fc5 100644 --- a/Readme.md +++ b/Readme.md @@ -210,6 +210,7 @@ usage: m [OPTIONS] COMMAND [help] usage: m dock [ enable | disable | + activeindicators | bounceonappactivity | bounceonapplaunch | autohidedelay | @@ -228,6 +229,7 @@ usage: m [OPTIONS] COMMAND [help] Examples: m dock enable # Shows the Dock m dock disable # Causes the Dock to be hidden and never reappear + m dock activeindicators YES # Show the active indicators under the app icons m dock bounceonappactivity # Bounce an app's icon when it has activity m dock bounceonapplaunch # Bounce an app's icon when it is launching m dock autohidedelay x.x # Changes how long the Dock takes to show up when auto-hide is enabled diff --git a/plugins/dock b/plugins/dock index c3fafb1..9aeaecb 100755 --- a/plugins/dock +++ b/plugins/dock @@ -5,6 +5,7 @@ help(){ usage: m dock [ enable | disable | + activeindicators | bounceonappactivity | bounceonapplaunch | autohidedelay | @@ -23,6 +24,7 @@ help(){ Examples: m dock enable # Shows the Dock m dock disable # Causes the Dock to be hidden and never reappear + m dock activeindicators YES # Show the active indicators under the app icons m dock bounceonappactivity # Bounce an app's icon when it has activity m dock bounceonapplaunch # Bounce an app's icon when it is launching m dock autohidedelay x.x # Changes how long the Dock takes to show up when auto-hide is enabled @@ -54,6 +56,28 @@ disable(){ show_delay 999999 } +active_indicators(){ + case $1 in + [yY][eE][sS]) + echo "Active Indicators: YES" + defaults write com.apple.dock show-process-indicators -bool "true" + ;; + [nN][oO]) + echo "Active Indicators: NO" + defaults write com.apple.dock show-process-indicators -bool "false" + ;; + *) + VALUE=$(defaults read com.apple.dock show-process-indicators) + if [ "${VALUE}" -eq 1 ]; then + echo "Active Indicators: YES" + else + echo "Active Indicators: NO" + fi + ;; + esac + killall Dock +} + bounce_on_app_activity(){ case $1 in [yY][eE][sS]) @@ -253,6 +277,10 @@ case $1 in disable) disable ;; + activeindicators) + shift + active_indicators $@ + ;; bounceonappactivity) shift bounce_on_app_activity $@ From 1394663861b1b5fd791dee3ce102d911b0176e9b Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Thu, 5 Jan 2017 21:01:07 -0600 Subject: [PATCH 013/100] Add helper functions to remove some duplication around reading values There's quite a bit of duplication among many of these functions. I'm going to add a few helper functions to clean some of it up. It will make adding new plugins easier as well as make the user experience more consistent. Not to mention cutting down on possible bugs. --- lib/defaults.sh | 36 +++++++++++ lib/helpers.sh | 7 +++ plugins/airdrop | 14 ++--- plugins/display | 14 ++--- plugins/dock | 141 +++++++++++++++++++------------------------- plugins/screensaver | 14 ++--- 6 files changed, 115 insertions(+), 111 deletions(-) create mode 100644 lib/defaults.sh create mode 100644 lib/helpers.sh diff --git a/lib/defaults.sh b/lib/defaults.sh new file mode 100644 index 0000000..ef0a27c --- /dev/null +++ b/lib/defaults.sh @@ -0,0 +1,36 @@ +_mcli_read() { + local domain="$1" + local key="$2" + local sudo="$3" + + [ -n "${domain}" ] && [ -n "${key}" ] || return 1 + [[ -n "${sudo}" ]] && sudo="sudo" + + echo "$(${sudo} defaults read "${domain}" "${key}")" +} + +_mcli_read_boolean() { + local value="$(_mcli_read $@)" + + if [ "${value}" -eq 1 ]; then + echo "YES" + else + echo "NO" + fi +} + +_mcli_read_number() { + local value="$(_mcli_read $@)" + + echo "${value}" +} + +_mcli_read_inverted_boolean() { + local value="$(_mcli_read_boolean $@)" + + if [[ "${value}" == "YES" ]]; then + echo "NO" + else + echo "YES" + fi +} diff --git a/lib/helpers.sh b/lib/helpers.sh new file mode 100644 index 0000000..ca2116d --- /dev/null +++ b/lib/helpers.sh @@ -0,0 +1,7 @@ +_mcli_print_command_status() { + local command="$1" + local subcommand="$1" + local value="$1" + + echo "${command} - ${subcommand}: ${value}" +} diff --git a/plugins/airdrop b/plugins/airdrop index 572e0fe..5907ee4 100755 --- a/plugins/airdrop +++ b/plugins/airdrop @@ -14,21 +14,15 @@ onlywifi(){ case $1 in [yY][eE][sS]) defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true - echo "Airdrop onlywifi: YES" ;; [nN][oO]) defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool false - echo "Airdrop onlywifi: NO" - ;; - *) - VALUE=$(defaults read com.apple.NetworkBrowser BrowseAllInterfaces) - if [ "${VALUE}" -eq 1 ]; then - echo "Airdrop onlywifi: YES" - else - echo "Airdrop onlywifi: NO" - fi ;; esac + + value="$(_mcli_read_boolean "com.apple.NetworkBrowser" "BrowseAllInterfaces")" + + echo "Airdrop onlywifi: ${value}" } case $1 in diff --git a/plugins/display b/plugins/display index 06cbc62..98d25a8 100755 --- a/plugins/display +++ b/plugins/display @@ -21,21 +21,15 @@ autobrightness() { case $1 in [yY][eE][sS]) sudo defaults write "${path_to_plist}" "Automatic Display Enabled" -int 1 - echo "Display autobrightness: YES" ;; [nN][oO]) sudo defaults write "${path_to_plist}" "Automatic Display Enabled" -int 0 - echo "Display autobrightness: NO" - ;; - *) - VALUE=$(sudo defaults read "${path_to_plist}" "Automatic Display Enabled") - if [ "${VALUE}" -eq 1 ]; then - echo "Display autobrightness: YES" - else - echo "Display autobrightness: NO" - fi ;; esac + + value="$(_mcli_read_boolean "${path_to_plist}" "Automatic Display Enabled" "sudo")" + + echo "Display autobrightness: ${value}" } case $1 in diff --git a/plugins/dock b/plugins/dock index 9aeaecb..cb31e6e 100755 --- a/plugins/dock +++ b/plugins/dock @@ -59,189 +59,168 @@ disable(){ active_indicators(){ case $1 in [yY][eE][sS]) - echo "Active Indicators: YES" defaults write com.apple.dock show-process-indicators -bool "true" ;; [nN][oO]) - echo "Active Indicators: NO" defaults write com.apple.dock show-process-indicators -bool "false" ;; - *) - VALUE=$(defaults read com.apple.dock show-process-indicators) - if [ "${VALUE}" -eq 1 ]; then - echo "Active Indicators: YES" - else - echo "Active Indicators: NO" - fi - ;; esac - killall Dock + + [ -n "$1" ] && killall Dock + + value="$(_mcli_read_boolean "com.apple.dock" "show-process-indicators")" + + echo "Dock activeindicators: ${value}" } bounce_on_app_activity(){ case $1 in [yY][eE][sS]) - echo "Bounce on App Activity: YES" defaults write com.apple.dock no-bouncing -bool "NO" ;; [nN][oO]) - echo "Bounce on App Activity: NO" defaults write com.apple.dock no-bouncing -bool "YES" ;; - *) - VALUE=$(defaults read com.apple.dock no-bouncing) - if [ "${VALUE}" -eq 1 ]; then - echo "Bounce on App Activity: NO" - else - echo "Bounce on App Activity: YES" - fi - ;; esac - killall Dock + + [ -n "$1" ] && killall Dock + + value="$(_mcli_read_inverted_boolean "com.apple.dock" "no-bouncing")" + + echo "Dock bounceonappactivity: ${value}" } bounce_on_app_launch(){ case $1 in [yY][eE][sS]) - echo "Bounce on App Launch: YES" defaults write com.apple.dock launchanim -bool "YES" ;; [nN][oO]) - echo "Bounce on App Launch: NO" defaults write com.apple.dock launchanim -bool "NO" ;; - *) - VALUE=$(defaults read com.apple.dock launchanim) - if [ "${VALUE}" -eq 1 ]; then - echo "Bounce on App Launch: YES" - else - echo "Bounce on App Launch: NO" - fi - ;; esac - killall Dock + + [ -n "$1" ] && killall Dock + + value="$(_mcli_read_boolean "com.apple.dock" "launchanim")" + + echo "Dock bounceonapplaunch: ${value}" } auto_hide_speed(){ case $1 in [0-9][.][0-9]) - echo "New Auto-Hide speed: "$1 defaults write com.apple.dock autohide-time-modifier -float $1 ;; [0-9]) - echo "New Auto-Hide speed: "$1 defaults write com.apple.dock autohide-time-modifier -int $1 ;; - *) - echo "Current Auto-Hide speed: $(defaults read com.apple.dock autohide-time-modifier 2>/dev/null)" - exit 0 - ;; esac - killall Dock + + [ -n "$1" ] && killall Dock + + value="$(_mcli_read_number "com.apple.dock" "autohide-time-modifier")" + + echo "Dock autohidespeed: ${value}" } auto_hide_delay(){ case $1 in [0-9][.][0-9]) - echo "New Auto-Hide delay: "$1 defaults write com.apple.dock autohide-delay -float $1 ;; [0-9]) - echo "New Auto-Hide delay: "$1 defaults write com.apple.dock autohide-delay -int $1 ;; - *) - echo "Current Auto-Hide delay: $(defaults read com.apple.dock autohide-delay 2>/dev/null)" - exit 0 - ;; esac - killall Dock + + [ -n "$1" ] && killall Dock + + value="$(_mcli_read_number "com.apple.dock" "autohide-delay")" + + echo "Dock autohidedelay: ${value}" } auto_hide(){ case $1 in [yY][eE][sS]) - echo "Auto Hide: YES" defaults write com.apple.dock autohide -boolean YES ;; [nN][oO]) - echo "Auto Hide: No" defaults write com.apple.dock autohide -boolean NO ;; - *) - echo "Auto Hide: $(defaults read com.apple.dock autohide)" - exit 0 - ;; esac - killall Dock + + [ -n "$1" ] && killall Dock + + value="$(_mcli_read_boolean "com.apple.dock" "autohide")" + + echo "Dock autohide: ${value}" } magnify(){ case $1 in [yY][eE][sS]) - echo "Magnification: YES" defaults write com.apple.dock magnification -boolean YES ;; [nN][oO]) - echo "Magnification: NO" defaults write com.apple.dock magnification -boolean NO ;; - *) - echo "Magnification: $(defaults read com.apple.dock magnification)" - exit 0 - ;; esac - killall Dock + + [ -n "$1" ] && killall Dock + + value="$(_mcli_read_boolean "com.apple.dock" "magnification")" + + echo "Dock magnification: ${value}" } magnification_size(){ case $1 in [0-9]*) - echo "New magnification size: ${1}px" defaults write com.apple.dock largesize -int "$1" ;; - *) - echo "Current magnification size: $(defaults read com.apple.dock largesize 2>/dev/null)px" - exit 0 - ;; esac - killall Dock + + [ -n "$1" ] && killall Dock + + value="$(_mcli_read_number "com.apple.dock" "largesize")" + + echo "Dock magnificationsize: ${value}" } icon_size(){ case $1 in [0-9]*) - echo "New icon size: ${1}px" defaults write com.apple.dock tilesize -int "$1" ;; - *) - echo "Current icon size: $(defaults read com.apple.dock tilesize 2>/dev/null)px" - exit 0 - ;; esac - killall Dock + + [ -n "$1" ] && killall Dock + + value="$(_mcli_read_number "com.apple.dock" "tilesize")" + + echo "Dock tilesize: ${value}" } dock_position(){ case $1 in [bB][oO][tT][tT][oO][mM]) - echo "Dock Position: BOTTOM" defaults write com.apple.dock orientation bottom ;; [lL][eE][fF][tT]) - echo "Dock Position: LEFT" defaults write com.apple.dock orientation left ;; [rR][iI][gG][hH][tT]) - echo "Dock Position: RIGHT" defaults write com.apple.dock orientation right ;; - *) - echo "Position: $(defaults read com.apple.dock orientation)" - exit 0 - ;; esac - killall Dock + + [ -n "$1" ] && killall Dock + + value="$(_mcli_read "com.apple.dock" "orientation")" + + echo "Dock position: ${value}" } add_blank_space(){ diff --git a/plugins/screensaver b/plugins/screensaver index 497844d..86c892b 100755 --- a/plugins/screensaver +++ b/plugins/screensaver @@ -19,21 +19,15 @@ askforpassword(){ case $1 in [yY][eE][sS]) defaults write com.apple.screensaver askForPassword -int 1 - echo "Screensaver askforpassword: YES" ;; [nN][oO]) defaults write com.apple.screensaver askForPassword -int 0 - echo "Screensaver askforpassword: NO" - ;; - *) - VALUE=$(defaults read com.apple.screensaver askForPassword) - if [ "${VALUE}" -eq 1 ]; then - echo "Screensaver askforpassword: YES" - else - echo "Screensaver askforpassword: NO" - fi ;; esac + + value="$(_mcli_read_boolean "com.apple.screensaver" "askForPassword")" + + echo "Screensaver askforpassword: ${value}" } status(){ From 5f6fdb99ee0360e062a5bc426b6f8c75cb4fa782 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Thu, 5 Jan 2017 22:47:18 -0600 Subject: [PATCH 014/100] Add more helper functions to remove a bunch of duplication --- lib/defaults.sh | 17 ++++--- lib/helpers.sh | 84 +++++++++++++++++++++++++++++++ plugins/airdrop | 14 +++--- plugins/airport | 117 ++++++++++++++----------------------------- plugins/dir | 18 +++---- plugins/display | 18 +++---- plugins/dock | 58 +++++++-------------- plugins/finder | 112 +++++++++++------------------------------ plugins/notification | 34 +++++-------- plugins/screensaver | 30 +++++------ 10 files changed, 226 insertions(+), 276 deletions(-) diff --git a/lib/defaults.sh b/lib/defaults.sh index ef0a27c..06441c5 100644 --- a/lib/defaults.sh +++ b/lib/defaults.sh @@ -6,17 +6,20 @@ _mcli_read() { [ -n "${domain}" ] && [ -n "${key}" ] || return 1 [[ -n "${sudo}" ]] && sudo="sudo" - echo "$(${sudo} defaults read "${domain}" "${key}")" + echo "$(${sudo} defaults read "${domain}" "${key}" 2> /dev/null)" } -_mcli_read_boolean() { +_mcli_read_boolean_as_yes_no() { local value="$(_mcli_read $@)" - if [ "${value}" -eq 1 ]; then - echo "YES" - else - echo "NO" - fi + case "${value}" in + 0|[nN][oO]|[fF][aA][lL][sS][eE]) + echo "NO" + ;; + 1|[yY][eE][sS]|[tT][rU][eE]) + echo "YES" + ;; + esac } _mcli_read_number() { diff --git a/lib/helpers.sh b/lib/helpers.sh index ca2116d..135b166 100644 --- a/lib/helpers.sh +++ b/lib/helpers.sh @@ -5,3 +5,87 @@ _mcli_print_command_status() { echo "${command} - ${subcommand}: ${value}" } + +_mcli_yes_no_to_boolean() { + local choice="$1" + + case "${choice}" in + 1|[yY][eE][sS]|[tT][rU][eE]) + echo "true" + ;; + 0|[nN][oO]|[fF][aA][lL][sS][eE]) + echo "false" + ;; + *) + echo "ERROR" + ;; + esac +} + +_mcli_exit_status_to_enabled_disabled() { + local command="$1" + + if eval("${command} &> /dev/null"); then + echo "enabled" + else + echo "disabled" + fi +} + +_mcli_yes_no_to_load_unload() { + local choice="$1" + + case "${choice}" in + 1|[yY][eE][sS]|[tT][rU][eE]) + echo "load" + ;; + 0|[nN][oO]|[fF][aA][lL][sS][eE]) + echo "unload" + ;; + *) + echo "ERROR" + ;; + esac +} + +_mcli_yes_no_to_inverted_boolean() { + local choice="$(_mcli_yes_no_to_boolean $@)" + + if [[ "${choice}" == "true" ]]; then + echo "false" + else + echo "true" + fi +} + +_mcli_yes_no_to_yes_no() { + local choice="$1" + + case "${choice}" in + 1|[yY][eE][sS]|[tT][rU][eE]) + echo "YES" + ;; + 0|[nN][oO]|[fF][aA][lL][sS][eE]) + echo "NO" + ;; + *) + echo "ERROR" + ;; + esac +} + +_mcli_yes_no_to_integer() { + local choice="$1" + + case "${choice}" in + 1|[yY][eE][sS]|[tT][rU][eE]) + echo "1" + ;; + 0|[nN][oO]|[fF][aA][lL][sS][eE]) + echo "0" + ;; + *) + echo "ERROR" + ;; + esac +} diff --git a/plugins/airdrop b/plugins/airdrop index 5907ee4..05f8891 100755 --- a/plugins/airdrop +++ b/plugins/airdrop @@ -1,5 +1,8 @@ #!/usr/bin/env bash +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/helpers.sh" + help(){ cat<<__EOF__ usage: m airdrop [ onlywifi | help ] @@ -11,14 +14,9 @@ __EOF__ } onlywifi(){ - case $1 in - [yY][eE][sS]) - defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true - ;; - [nN][oO]) - defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool false - ;; - esac + local choice="$(_mcli_yes_no_to_boolean "$1")" + + defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool "${choice}" value="$(_mcli_read_boolean "com.apple.NetworkBrowser" "BrowseAllInterfaces")" diff --git a/plugins/airport b/plugins/airport index ac834a6..a26fb80 100755 --- a/plugins/airport +++ b/plugins/airport @@ -1,5 +1,8 @@ #!/usr/bin/env bash +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/helpers.sh" + declare path_to_airport_binary="/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport" help(){ @@ -44,19 +47,13 @@ __EOF__ } disconnectonlogout(){ - case $1 in - [yY][eE][sS]) - sudo "${path_to_airport_binary}" prefs DisconnectOnLogout="YES" - echo "Airport disconnectonlogout: YES" - ;; - [nN][oO]) - sudo "${path_to_airport_binary}" prefs DisconnectOnLogout="NO" - echo "Airport disconnectonlogout: NO" - ;; - *) - sudo "${path_to_airport_binary}" prefs DisconnectOnLogout - ;; - esac + local choice="$(_mcli_yes_no_to_yes_no "$1")" + + sudo "${path_to_airport_binary}" prefs DisconnectOnLogout="${choice}" + + value="$(sudo "${path_to_airport_binary}" prefs DisconnectOnLogout)" + + echo "Airport disconnectonlogout: ${value}" } nonpreferrednetworks(){ @@ -72,83 +69,43 @@ preferrednetworks(){ } rememberrecents(){ - case $1 in - [yY][eE][sS]) - sudo "${path_to_airport_binary}" prefs RememberRecentNetworks="YES" - echo "Airport rememberrecents: YES" - ;; - [nN][oO]) - sudo "${path_to_airport_binary}" prefs RememberRecentNetworks="NO" - echo "Airport rememberrecents: NO" - ;; - *) - sudo "${path_to_airport_binary}" prefs RememberRecentNetworks - ;; - esac + local choice="$(_mcli_yes_no_to_yes_no "$1")" + + sudo "${path_to_airport_binary}" prefs RememberRecentNetworks="${choice}" + + value="$(sudo "${path_to_airport_binary}" prefs RememberRecentNetworks)" + + echo "Airport rememberrecents: ${value}" } secureadhocnetworks(){ - case $1 in - [yY][eE][sS]) - sudo "${path_to_airport_binary}" prefs RememberRecentNetworks="YES" - echo "Airport secureadhocnetworks: YES" - ;; - [nN][oO]) - sudo "${path_to_airport_binary}" prefs RequireAdminIBSS="NO" - echo "Airport secureadhocnetworks: NO" - ;; - *) - sudo "${path_to_airport_binary}" prefs RequireAdminIBSS - ;; - esac -} + local choice="$(_mcli_yes_no_to_yes_no "$1")" -securechangenetworks(){ - case $1 in - [yY][eE][sS]) - sudo "${path_to_airport_binary}" prefs RequireAdminNetworkChange="YES" - echo "Airport securechangenetworks: YES" - ;; - [nN][oO]) - sudo "${path_to_airport_binary}" prefs RequireAdminNetworkChange="NO" - echo "Airport securechangenetworks: NO" - ;; - *) - sudo "${path_to_airport_binary}" prefs RequireAdminNetworkChange - ;; - esac + sudo "${path_to_airport_binary}" prefs RequireAdminIBSS="${choice}" + + value="$(sudo "${path_to_airport_binary}" prefs RequireAdminIBSS)" + + echo "Airport secureadhocnetworks: ${value}" } securechangenetworks(){ - case $1 in - [yY][eE][sS]) - sudo "${path_to_airport_binary}" prefs RequireAdminNetworkChange="YES" - echo "Airport securechangenetworks: YES" - ;; - [nN][oO]) - sudo "${path_to_airport_binary}" prefs RequireAdminNetworkChange="NO" - echo "Airport securechangenetworks: NO" - ;; - *) - sudo "${path_to_airport_binary}" prefs RequireAdminNetworkChange - ;; - esac + local choice="$(_mcli_yes_no_to_yes_no "$1")" + + sudo "${path_to_airport_binary}" prefs RequireAdminNetworkChange="${choice}" + + value="$(sudo "${path_to_airport_binary}" prefs RequireAdminNetworkChange)" + + echo "Airport securechangenetworks: ${value}" } securetogglepower(){ - case $1 in - [yY][eE][sS]) - sudo "${path_to_airport_binary}" prefs RequireAdminPowerToggle="YES" - echo "Airport securetogglepower: YES" - ;; - [nN][oO]) - sudo "${path_to_airport_binary}" prefs RequireAdminPowerToggle="NO" - echo "Airport securetogglepower: NO" - ;; - *) - sudo "${path_to_airport_binary}" prefs RequireAdminPowerToggle - ;; - esac + local choice="$(_mcli_yes_no_to_yes_no "$1")" + + sudo "${path_to_airport_binary}" prefs RequireAdminPowerToggle="${choice}" + + value="$(sudo "${path_to_airport_binary}" prefs RequireAdminPowerToggle)" + + echo "Airport securetogglepower: ${value}" } case $1 in diff --git a/plugins/dir b/plugins/dir index 198f00e..ba3be1c 100755 --- a/plugins/dir +++ b/plugins/dir @@ -26,15 +26,15 @@ __EOF__ } confirm () { - # call with a prompt string or use a default - read -r -p "${1:-Are you sure? [y/n]} " response - case $response in - [yY][eE][sS]|[yY]) - true - ;; - *) - false - ;; + # call with a prompt string or use a default + read -r -p "${1:-Are you sure? [y/n]} " response + case $response in + [yY][eE][sS]|[yY]) + true + ;; + *) + false + ;; esac } diff --git a/plugins/display b/plugins/display index 98d25a8..0b121c3 100755 --- a/plugins/display +++ b/plugins/display @@ -1,5 +1,8 @@ #!/usr/bin/env bash +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/helpers.sh" + declare path_to_plist="/Library/Preferences/com.apple.iokit.AmbientLightSensor" help(){ @@ -18,16 +21,11 @@ display_status(){ } autobrightness() { - case $1 in - [yY][eE][sS]) - sudo defaults write "${path_to_plist}" "Automatic Display Enabled" -int 1 - ;; - [nN][oO]) - sudo defaults write "${path_to_plist}" "Automatic Display Enabled" -int 0 - ;; - esac - - value="$(_mcli_read_boolean "${path_to_plist}" "Automatic Display Enabled" "sudo")" + local choice="$(_mcli_yes_no_to_integer "$1")" + + defaults write "${path_to_plist}" "Automatic Display Enabled" -int "${choice}" + + value="$(_mcli_read_boolean "${path_to_plist}" "Automatic Display Enabled")" echo "Display autobrightness: ${value}" } diff --git a/plugins/dock b/plugins/dock index cb31e6e..b62348f 100755 --- a/plugins/dock +++ b/plugins/dock @@ -1,5 +1,8 @@ #!/usr/bin/env bash +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/helpers.sh" + help(){ cat<<__EOF__ usage: m dock [ @@ -57,14 +60,9 @@ disable(){ } active_indicators(){ - case $1 in - [yY][eE][sS]) - defaults write com.apple.dock show-process-indicators -bool "true" - ;; - [nN][oO]) - defaults write com.apple.dock show-process-indicators -bool "false" - ;; - esac + local choice="$(_mcli_yes_no_to_boolean "$1")" + + defaults write com.apple.dock show-process-indicators -bool "${choice}" [ -n "$1" ] && killall Dock @@ -74,14 +72,9 @@ active_indicators(){ } bounce_on_app_activity(){ - case $1 in - [yY][eE][sS]) - defaults write com.apple.dock no-bouncing -bool "NO" - ;; - [nN][oO]) - defaults write com.apple.dock no-bouncing -bool "YES" - ;; - esac + local choice="$(_mcli_yes_no_to_inverted_boolean "$1")" + + defaults write com.apple.dock no-bouncing -bool "${choice}" [ -n "$1" ] && killall Dock @@ -91,14 +84,9 @@ bounce_on_app_activity(){ } bounce_on_app_launch(){ - case $1 in - [yY][eE][sS]) - defaults write com.apple.dock launchanim -bool "YES" - ;; - [nN][oO]) - defaults write com.apple.dock launchanim -bool "NO" - ;; - esac + local choice="$(_mcli_yes_no_to_inverted_boolean "$1")" + + defaults write com.apple.dock launchanim -bool "${choice}" [ -n "$1" ] && killall Dock @@ -142,14 +130,9 @@ auto_hide_delay(){ } auto_hide(){ - case $1 in - [yY][eE][sS]) - defaults write com.apple.dock autohide -boolean YES - ;; - [nN][oO]) - defaults write com.apple.dock autohide -boolean NO - ;; - esac + local choice="$(_mcli_yes_no_to_boolean "$1")" + + defaults write com.apple.dock autohide -bool "${choice}" [ -n "$1" ] && killall Dock @@ -159,14 +142,9 @@ auto_hide(){ } magnify(){ - case $1 in - [yY][eE][sS]) - defaults write com.apple.dock magnification -boolean YES - ;; - [nN][oO]) - defaults write com.apple.dock magnification -boolean NO - ;; - esac + local choice="$(_mcli_yes_no_to_yes_no "$1")" + + defaults write com.apple.dock magnification -boolean "${choice}" [ -n "$1" ] && killall Dock diff --git a/plugins/finder b/plugins/finder index 74841e3..4cb8135 100755 --- a/plugins/finder +++ b/plugins/finder @@ -2,6 +2,9 @@ # TODO: add more functionalities +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/helpers.sh" + help(){ cat<<__EOF__ usage: m finder [ showhiddenfiles | showfileextensions | showdesktop | help ] @@ -22,94 +25,39 @@ __EOF__ } hidden_files(){ - case $1 in - [yY][eE][sS]) - echo "Show hidden files: YES" - defaults write com.apple.finder AppleShowAllFiles -bool true - ;; - [nN][oO]) - echo "Show hidden files: NO" - defaults write com.apple.finder AppleShowAllFiles -bool false - ;; - *) - HIDDEN_FILE_STATUS=$(defaults read com.apple.finder AppleShowAllFiles 2>/dev/null) - - case $HIDDEN_FILE_STATUS in - 0|[nN][oO]|[fF][aA][lL][sS][eE]) - HIDDEN_FILE_STATUS="NO" - ;; - 1|[yY][eE][sS]|[tT][rU][eE]) - HIDDEN_FILE_STATUS="YES" - ;; - *) - echo "We can't read AppleShowAllFiles property" && exit 1 - ;; - esac - - echo "Show hidden files: $HIDDEN_FILE_STATUS" - exit 0 - ;; - esac - killall Finder + local choice="$(_mcli_yes_no_to_boolean "$1")" + + defaults write com.apple.finder AppleShowAllFiles -bool "${choice}" + + [ -n "$1" ] && killall Finder + + value="$(_mcli_read_boolean_as_yes_no "com.apple.finder" "AppleShowAllFiles")" + + echo "Finder showhiddenfiles: ${value}" } file_extensions(){ - case $1 in - [yY][eE][sS]) - echo "Show file extensions: YES" - defaults write NSGlobalDomain AppleShowAllExtensions -bool true - ;; - [nN][oO]) - echo "Show file extensions: NO" - defaults write NSGlobalDomain AppleShowAllExtensions -bool false - ;; - *) - EXTENSION_STATUS=$(defaults read NSGlobalDomain AppleShowAllExtensions 2>/dev/null) - case $EXTENSION_STATUS in - 0|[nN][oO]|[fF][aA][lL][sS][eE]) - EXTENSION_STATUS="NO" - ;; - 1|[yY][eE][sS]|[tT][rU][eE]) - EXTENSION_STATUS="YES" - ;; - *) - echo "We can't read AppleShowAllExtension property" && exit 1 - ;; - esac - echo "Show file extensions: $EXTENSION_STATUS" - exit 0 - ;; - esac - killall Finder + local choice="$(_mcli_yes_no_to_boolean "$1")" + + defaults write NSGlobalDomain AppleShowAllExtensions -bool "${choice}" + + [ -n "$1" ] && killall Finder + + value="$(_mcli_read_boolean_as_yes_no "NSGlobalDomain" "AppleShowAllExtensions")" + + echo "Finder showextensions: ${value}" } desktop(){ - case $1 in - [yY][eE][sS]) - echo "Enable desktop: YES" - defaults write com.apple.finder CreateDesktop -bool true - ;; - [nN][oO]) - echo "Enable desktop: NO" - defaults write com.apple.finder CreateDesktop -bool false - ;; - *) - DESKTOP_STATUS=$(defaults read com.apple.finder CreateDesktop 2>/dev/null) - case $DESKTOP_STATUS in - 0|[nN][oO]|[fF][aA][lL][sS][eE]) - DESKTOP_STATUS="disabled" - ;; - 1|[yY][eE][sS]|[tT][rU][eE]) - DESKTOP_STATUS="enabled" - ;; - *) - echo "We can't read CreateDesktop property" && exit 1 - ;; - esac - echo "Desktop: $DESKTOP_STATUS" - ;; - esac - killall Finder + local choice="$(_mcli_yes_no_to_boolean "$1")" + + defaults write com.apple.finder CreateDesktop -bool "${choice}" + + [ -n "$1" ] && killall Finder + + value="$(_mcli_read_boolean_as_yes_no "com.apple.finder" "CreateDesktop")" + + echo "Finder showdesktop: ${value}" } case $1 in diff --git a/plugins/notification b/plugins/notification index 7813748..d8f2f71 100755 --- a/plugins/notification +++ b/plugins/notification @@ -1,5 +1,8 @@ #!/usr/bin/env bash +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/helpers.sh" + help(){ cat<<__EOF__ usage: m notification [ showcenter | help ] @@ -12,28 +15,15 @@ __EOF__ } showcenter(){ - case $1 in - [yY][eE][sS]) - echo "Enable notification center: YES" - launchctl load -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist - killall NotificationCenter - echo "Restart your computer for this to take effect" - ;; - [nN][oO]) - echo "Enable notification center: NO" - launchctl unload -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist - killall NotificationCenter - ;; - *) - ps -A | grep apsd | grep -v grep &>/dev/null - if [ $? -eq 0 ]; then - CENTER_STATUS="enabled" - else - CENTER_STATUS="disabled" - fi - echo "Notification Center: $CENTER_STATUS" - ;; - esac + local choice="$(_mcli_yes_no_to_load_unload $1)" + + launchctl "${choice}" -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist + + [ -n "${choice}" ] && killall NotificationCenter && echo "Restart your computer for this to take effect" + + value="$(_mcli_exit_status_to_enabled_disabled "ps -A | grep apsd | grep -v grep")" + + echo "Notification Center ${value}" } case $1 in diff --git a/plugins/screensaver b/plugins/screensaver index 86c892b..1782ff6 100755 --- a/plugins/screensaver +++ b/plugins/screensaver @@ -1,5 +1,7 @@ #!/usr/bin/env bash +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/helpers.sh" help(){ cat<<__EOF__ @@ -16,14 +18,9 @@ __EOF__ } askforpassword(){ - case $1 in - [yY][eE][sS]) - defaults write com.apple.screensaver askForPassword -int 1 - ;; - [nN][oO]) - defaults write com.apple.screensaver askForPassword -int 0 - ;; - esac + local choice="$(_mcli_yes_no_to_integer "$1")" + + defaults write com.apple.screensaver askForPassword -int "${choice}" value="$(_mcli_read_boolean "com.apple.screensaver" "askForPassword")" @@ -31,16 +28,13 @@ askforpassword(){ } status(){ - VALUE=$(osascript -e 'tell application "System Events"' \ - -e 'get running of screen saver preferences' \ - -e 'end tell') - if [ "${VALUE}" == 'true' ]; then - echo 'Screensaver is running: YES' - elif [ "${VALUE}" == 'false' ]; then - echo 'Screensaver is running: NO' - else - echo 'Screensaver is running: ERROR' - fi + local value=$(osascript -e 'tell application "System Events"' \ + -e 'get running of screen saver preferences' \ + -e 'end tell') + + value="$(_mcli_yes_no_to_yes_no "${value}")" + + echo "Screensaver is running: ${value}" } From f9090f3d0916e32ef5a3886e5cb0839b01057e71 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 00:31:14 -0600 Subject: [PATCH 015/100] Clear more duplication by creating more helpers --- lib/defaults.sh | 61 ++++++++++++++++++++++++++++++- lib/helpers.sh | 34 ++++++++++++++---- plugins/airdrop | 8 ++--- plugins/display | 8 ++--- plugins/dock | 88 +++++++++++++++------------------------------ plugins/finder | 24 +++++-------- plugins/screensaver | 8 ++--- 7 files changed, 134 insertions(+), 97 deletions(-) diff --git a/lib/defaults.sh b/lib/defaults.sh index 06441c5..01ef448 100644 --- a/lib/defaults.sh +++ b/lib/defaults.sh @@ -6,7 +6,19 @@ _mcli_read() { [ -n "${domain}" ] && [ -n "${key}" ] || return 1 [[ -n "${sudo}" ]] && sudo="sudo" - echo "$(${sudo} defaults read "${domain}" "${key}" 2> /dev/null)" + ${sudo} defaults read "${domain}" "${key}" 2> /dev/null +} + +_mcli_write_integer() { + local domain="$1" + local key="$2" + local value="$3" + local sudo="$4" + + [ -n "${domain}" ] && [ -n "${key}" ] && [ -n "${value}" ] || return 1 + [[ -n "${sudo}" ]] && sudo="sudo" + + ${sudo} defaults write "${domain}" "${key}" -int "${value}" } _mcli_read_boolean_as_yes_no() { @@ -37,3 +49,50 @@ _mcli_read_inverted_boolean() { echo "YES" fi } + +_mcli_defaults_yes_no_to_integer() { + _mcli_defaults_yes_no_to_type "integer" "yes_no_to_boolean" $@ +} + +_mcli_defaults_yes_no_to_boolean() { + _mcli_defaults_yes_no_to_type "boolean" "yes_no_to_boolean" $@ +} + +_mcli_defaults_yes_no_to_inverted_boolean() { + _mcli_defaults_yes_no_to_type "boolean" "yes_no_to_inverted_boolean" $@ +} + +_mcli_defaults_number() { + local domain="$1" + local key="$2" + local new_value="$3" + local sudo="$4" + local transformed="$(_mcli_number_to_number "${new_value}")" + + case "${transformed}" in + [0-9][.][0-9]) + ${sudo} defaults write "${domain}" "${key}" -float "${transformed}" + ;; + [0-9]*) + ${sudo} defaults write "${domain}" "${key}" -int "${transformed}" + ;; + esac + + _mcli_read_integer "${domain}" "${key}" +} + +_mcli_defaults_yes_no_to_type() { + local type="$1" + local transformer="$2" + local domain="$3" + local key="$4" + local new_value="$5" + local sudo="$6" + local transformed="$(_mcli_${transformer} "${new_value}")" + + if [ -n "${new_value}" ] && [[ "${transformed}" != "ERROR" ]]; then + ${sudo} defaults write "${domain}" "${key}" -${type} "${transformed}" + fi + + _mcli_read_boolean "${domain}" "${key}" +} diff --git a/lib/helpers.sh b/lib/helpers.sh index 135b166..25e565e 100644 --- a/lib/helpers.sh +++ b/lib/helpers.sh @@ -49,13 +49,19 @@ _mcli_yes_no_to_load_unload() { } _mcli_yes_no_to_inverted_boolean() { - local choice="$(_mcli_yes_no_to_boolean $@)" + local choice="$1" - if [[ "${choice}" == "true" ]]; then - echo "false" - else - echo "true" - fi + case "${choice}" in + 1|[yY][eE][sS]|[tT][rU][eE]) + echo "false" + ;; + 0|[nN][oO]|[fF][aA][lL][sS][eE]) + echo "true" + ;; + *) + echo "ERROR" + ;; + esac } _mcli_yes_no_to_yes_no() { @@ -89,3 +95,19 @@ _mcli_yes_no_to_integer() { ;; esac } + +_mcli_number_to_number() { + local choice="$1" + + case "${choice}" in + [0-9][.][0-9]) + echo "${choice}" + ;; + [0-9]*) + echo "${choice}" + ;; + *) + echo "ERROR" + ;; + esac +} diff --git a/plugins/airdrop b/plugins/airdrop index 05f8891..3aa1603 100755 --- a/plugins/airdrop +++ b/plugins/airdrop @@ -14,11 +14,9 @@ __EOF__ } onlywifi(){ - local choice="$(_mcli_yes_no_to_boolean "$1")" - - defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool "${choice}" - - value="$(_mcli_read_boolean "com.apple.NetworkBrowser" "BrowseAllInterfaces")" + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.NetworkBrowser" \ + "BrowseAllInterfaces" \ + "$1")" echo "Airdrop onlywifi: ${value}" } diff --git a/plugins/display b/plugins/display index 0b121c3..a3a93c2 100755 --- a/plugins/display +++ b/plugins/display @@ -21,11 +21,9 @@ display_status(){ } autobrightness() { - local choice="$(_mcli_yes_no_to_integer "$1")" - - defaults write "${path_to_plist}" "Automatic Display Enabled" -int "${choice}" - - value="$(_mcli_read_boolean "${path_to_plist}" "Automatic Display Enabled")" + value="$(_mcli_defaults_yes_no_to_integer "${path_to_plist}" \ + "Automatic Display Enabled" \ + "$1")" echo "Display autobrightness: ${value}" } diff --git a/plugins/dock b/plugins/dock index b62348f..13b5142 100755 --- a/plugins/dock +++ b/plugins/dock @@ -60,125 +60,93 @@ disable(){ } active_indicators(){ - local choice="$(_mcli_yes_no_to_boolean "$1")" - - defaults write com.apple.dock show-process-indicators -bool "${choice}" + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ + "show-process-indicators" \ + "$1")" [ -n "$1" ] && killall Dock - value="$(_mcli_read_boolean "com.apple.dock" "show-process-indicators")" - echo "Dock activeindicators: ${value}" } bounce_on_app_activity(){ - local choice="$(_mcli_yes_no_to_inverted_boolean "$1")" - - defaults write com.apple.dock no-bouncing -bool "${choice}" + value="$(_mcli_defaults_yes_no_to_inverted_boolean "com.apple.dock" \ + "no-bouncing" \ + "$1")" [ -n "$1" ] && killall Dock - value="$(_mcli_read_inverted_boolean "com.apple.dock" "no-bouncing")" - echo "Dock bounceonappactivity: ${value}" } bounce_on_app_launch(){ - local choice="$(_mcli_yes_no_to_inverted_boolean "$1")" - - defaults write com.apple.dock launchanim -bool "${choice}" + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ + "launchanim" \ + "$1")" [ -n "$1" ] && killall Dock - value="$(_mcli_read_boolean "com.apple.dock" "launchanim")" - echo "Dock bounceonapplaunch: ${value}" } auto_hide_speed(){ - case $1 in - [0-9][.][0-9]) - defaults write com.apple.dock autohide-time-modifier -float $1 - ;; - [0-9]) - defaults write com.apple.dock autohide-time-modifier -int $1 - ;; - esac + value="$(_mcli_defaults_number "com.apple.dock" \ + "autohide-time-modifier" \ + "$1")" [ -n "$1" ] && killall Dock - value="$(_mcli_read_number "com.apple.dock" "autohide-time-modifier")" - echo "Dock autohidespeed: ${value}" } auto_hide_delay(){ - case $1 in - [0-9][.][0-9]) - defaults write com.apple.dock autohide-delay -float $1 - ;; - [0-9]) - defaults write com.apple.dock autohide-delay -int $1 - ;; - esac + value="$(_mcli_defaults_number "com.apple.dock" \ + "autohide-delay" \ + "$1")" [ -n "$1" ] && killall Dock - value="$(_mcli_read_number "com.apple.dock" "autohide-delay")" - echo "Dock autohidedelay: ${value}" } auto_hide(){ - local choice="$(_mcli_yes_no_to_boolean "$1")" - - defaults write com.apple.dock autohide -bool "${choice}" + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ + "autohide" \ + "$1")" [ -n "$1" ] && killall Dock - value="$(_mcli_read_boolean "com.apple.dock" "autohide")" - echo "Dock autohide: ${value}" } magnify(){ - local choice="$(_mcli_yes_no_to_yes_no "$1")" - - defaults write com.apple.dock magnification -boolean "${choice}" + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ + "magnification" \ + "$1")" [ -n "$1" ] && killall Dock - value="$(_mcli_read_boolean "com.apple.dock" "magnification")" - echo "Dock magnification: ${value}" } magnification_size(){ - case $1 in - [0-9]*) - defaults write com.apple.dock largesize -int "$1" - ;; - esac + value="$(_mcli_defaults_number "com.apple.dock" \ + "largesize" \ + "$1")" [ -n "$1" ] && killall Dock - value="$(_mcli_read_number "com.apple.dock" "largesize")" - echo "Dock magnificationsize: ${value}" } icon_size(){ - case $1 in - [0-9]*) - defaults write com.apple.dock tilesize -int "$1" - ;; - esac + value="$(_mcli_defaults_number "com.apple.dock" \ + "tilesize" \ + "$1")" [ -n "$1" ] && killall Dock - value="$(_mcli_read_number "com.apple.dock" "tilesize")" - - echo "Dock tilesize: ${value}" + echo "Dock iconsize: ${value}" } dock_position(){ diff --git a/plugins/finder b/plugins/finder index 4cb8135..08c8e4b 100755 --- a/plugins/finder +++ b/plugins/finder @@ -25,38 +25,32 @@ __EOF__ } hidden_files(){ - local choice="$(_mcli_yes_no_to_boolean "$1")" - - defaults write com.apple.finder AppleShowAllFiles -bool "${choice}" + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.finder" \ + "AppleShowAllFiles" \ + "$1")" [ -n "$1" ] && killall Finder - value="$(_mcli_read_boolean_as_yes_no "com.apple.finder" "AppleShowAllFiles")" - echo "Finder showhiddenfiles: ${value}" } file_extensions(){ - local choice="$(_mcli_yes_no_to_boolean "$1")" - - defaults write NSGlobalDomain AppleShowAllExtensions -bool "${choice}" + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "AppleShowAllExtensions" \ + "$1")" [ -n "$1" ] && killall Finder - value="$(_mcli_read_boolean_as_yes_no "NSGlobalDomain" "AppleShowAllExtensions")" - echo "Finder showextensions: ${value}" } desktop(){ - local choice="$(_mcli_yes_no_to_boolean "$1")" - - defaults write com.apple.finder CreateDesktop -bool "${choice}" + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.finder" \ + "CreateDesktop" \ + "$1")" [ -n "$1" ] && killall Finder - value="$(_mcli_read_boolean_as_yes_no "com.apple.finder" "CreateDesktop")" - echo "Finder showdesktop: ${value}" } diff --git a/plugins/screensaver b/plugins/screensaver index 1782ff6..49f0ae8 100755 --- a/plugins/screensaver +++ b/plugins/screensaver @@ -18,11 +18,9 @@ __EOF__ } askforpassword(){ - local choice="$(_mcli_yes_no_to_integer "$1")" - - defaults write com.apple.screensaver askForPassword -int "${choice}" - - value="$(_mcli_read_boolean "com.apple.screensaver" "askForPassword")" + value="$(_mcli_defaults_yes_no_to_integer "com.apple.screensaver" \ + "askForPassword" \ + "$1")" echo "Screensaver askforpassword: ${value}" } From 7e09ee0b0bbdb9ec632c088cf5f417ab40e3fdba Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 00:58:02 -0600 Subject: [PATCH 016/100] Add hidden app dimming to the dock --- Readme.md | 2 ++ plugins/dock | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/Readme.md b/Readme.md index 6bd3fc5..ca903f3 100644 --- a/Readme.md +++ b/Readme.md @@ -218,6 +218,7 @@ usage: m [OPTIONS] COMMAND [help] autohide | magnification | magnificationsize | + hiddenappdimming | iconsize | position | addblankspace | @@ -240,6 +241,7 @@ usage: m [OPTIONS] COMMAND [help] m dock magnification YES # Turn magnification on m dock magnification NO # Turn magnification off m dock magnificationsize x # Set the max size of the icons as the cursor gets closer to them + m dock hiddenappdimming YES # Show apps that have been hidden as semi-transparent m dock iconsize x # Set the size of the icons when the dock is at rest m dock position BOTTOM # Change Dock's position to the bottom of the screen m dock position LEFT # Change Dock's position to the left of the screen diff --git a/plugins/dock b/plugins/dock index 13b5142..3651729 100755 --- a/plugins/dock +++ b/plugins/dock @@ -16,6 +16,7 @@ help(){ autohide | magnification | magnificationsize | + hiddenappdimming | iconsize | position | addblankspace | @@ -38,6 +39,7 @@ help(){ m dock magnification YES # Turn magnification on m dock magnification NO # Turn magnification off m dock magnificationsize x # Set the max size of the icons as the cursor gets closer to them + m dock hiddenappdimming YES # Show apps that have been hidden as semi-transparent m dock iconsize x # Set the size of the icons when the dock is at rest m dock position BOTTOM # Change Dock's position to the bottom of the screen m dock position LEFT # Change Dock's position to the left of the screen @@ -119,6 +121,16 @@ auto_hide(){ echo "Dock autohide: ${value}" } +hidden_app_dimming(){ + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ + "showhidden" \ + "$1")" + + [ -n "$1" ] && killall Dock + + echo "Dock app dimming: ${value}" +} + magnify(){ value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ "magnification" \ @@ -238,6 +250,10 @@ case $1 in shift magnification_size $@ ;; + hiddenappdimming) + shift + hidden_app_dimming $@ + ;; iconsize) shift icon_size $@ From c448b24ec7b203fafbfd4bcc445bfe6ec078d2df Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 01:05:49 -0600 Subject: [PATCH 017/100] Add only show running to the dock --- Readme.md | 2 ++ plugins/dock | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/Readme.md b/Readme.md index ca903f3..9edabf9 100644 --- a/Readme.md +++ b/Readme.md @@ -220,6 +220,7 @@ usage: m [OPTIONS] COMMAND [help] magnificationsize | hiddenappdimming | iconsize | + onlyshowrunning | position | addblankspace | addrecentitems | @@ -243,6 +244,7 @@ usage: m [OPTIONS] COMMAND [help] m dock magnificationsize x # Set the max size of the icons as the cursor gets closer to them m dock hiddenappdimming YES # Show apps that have been hidden as semi-transparent m dock iconsize x # Set the size of the icons when the dock is at rest + m dock onlyshowrunning YES # Only show the apps that are currently running. Apps cannot be pinned. m dock position BOTTOM # Change Dock's position to the bottom of the screen m dock position LEFT # Change Dock's position to the left of the screen m dock position RIGHT # Change Dock's position to the right of the screen diff --git a/plugins/dock b/plugins/dock index 3651729..edf7c9e 100755 --- a/plugins/dock +++ b/plugins/dock @@ -18,6 +18,7 @@ help(){ magnificationsize | hiddenappdimming | iconsize | + onlyshowrunning | position | addblankspace | addrecentitems | @@ -41,6 +42,7 @@ help(){ m dock magnificationsize x # Set the max size of the icons as the cursor gets closer to them m dock hiddenappdimming YES # Show apps that have been hidden as semi-transparent m dock iconsize x # Set the size of the icons when the dock is at rest + m dock onlyshowrunning YES # Only show the apps that are currently running. Apps cannot be pinned. m dock position BOTTOM # Change Dock's position to the bottom of the screen m dock position LEFT # Change Dock's position to the left of the screen m dock position RIGHT # Change Dock's position to the right of the screen @@ -161,6 +163,16 @@ icon_size(){ echo "Dock iconsize: ${value}" } +only_show_running(){ + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ + "static-only" \ + "$1")" + + [ -n "$1" ] && killall Dock + + echo "Dock onlyshowrunning: ${value}" +} + dock_position(){ case $1 in [bB][oO][tT][tT][oO][mM]) @@ -258,6 +270,10 @@ case $1 in shift icon_size $@ ;; + onlyshowrunning) + shift + only_show_running $@ + ;; position) shift dock_position $@ From db9b798070ae76a590678ba272024d9d153901c7 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 01:12:42 -0600 Subject: [PATCH 018/100] Add full screen delay to the dock --- Readme.md | 2 ++ plugins/dock | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/Readme.md b/Readme.md index 9edabf9..4e9cea9 100644 --- a/Readme.md +++ b/Readme.md @@ -216,6 +216,7 @@ usage: m [OPTIONS] COMMAND [help] autohidedelay | autohidespeed | autohide | + fullscreendelay | magnification | magnificationsize | hiddenappdimming | @@ -239,6 +240,7 @@ usage: m [OPTIONS] COMMAND [help] # delay has expired m dock autohide YES # Enable Dock's auto hide feature m dock autohide NO # Disable Dock's auto hide feature + m dock fullscreendelay YES # Whether to have a delay when showing the dock in full screen mode m dock magnification YES # Turn magnification on m dock magnification NO # Turn magnification off m dock magnificationsize x # Set the max size of the icons as the cursor gets closer to them diff --git a/plugins/dock b/plugins/dock index edf7c9e..f9768bd 100755 --- a/plugins/dock +++ b/plugins/dock @@ -14,6 +14,7 @@ help(){ autohidedelay | autohidespeed | autohide | + fullscreendelay | magnification | magnificationsize | hiddenappdimming | @@ -37,6 +38,7 @@ help(){ # delay has expired m dock autohide YES # Enable Dock's auto hide feature m dock autohide NO # Disable Dock's auto hide feature + m dock fullscreendelay YES # Whether to have a delay when showing the dock in full screen mode m dock magnification YES # Turn magnification on m dock magnification NO # Turn magnification off m dock magnificationsize x # Set the max size of the icons as the cursor gets closer to them @@ -123,6 +125,16 @@ auto_hide(){ echo "Dock autohide: ${value}" } +full_screen_delay(){ + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ + "autohide-fullscreen-delayed" \ + "$1")" + + [ -n "$1" ] && killall Dock + + echo "Dock full screen delay: ${value}" +} + hidden_app_dimming(){ value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ "showhidden" \ @@ -254,6 +266,10 @@ case $1 in shift auto_hide $@ ;; + fullscreendelay) + shift + full_screen_delay $@ + ;; magnification) shift magnify $@ From e8c627168778417ca243ac218126c380773fbc05 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 01:18:28 -0600 Subject: [PATCH 019/100] Add iTunes notifications to the dock --- Readme.md | 2 ++ plugins/dock | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/Readme.md b/Readme.md index 4e9cea9..5a15df5 100644 --- a/Readme.md +++ b/Readme.md @@ -217,6 +217,7 @@ usage: m [OPTIONS] COMMAND [help] autohidespeed | autohide | fullscreendelay | + itunesnotifications | magnification | magnificationsize | hiddenappdimming | @@ -241,6 +242,7 @@ usage: m [OPTIONS] COMMAND [help] m dock autohide YES # Enable Dock's auto hide feature m dock autohide NO # Disable Dock's auto hide feature m dock fullscreendelay YES # Whether to have a delay when showing the dock in full screen mode + m dock itunesnotifications NO # Whether to show iTunes notifications in the dock m dock magnification YES # Turn magnification on m dock magnification NO # Turn magnification off m dock magnificationsize x # Set the max size of the icons as the cursor gets closer to them diff --git a/plugins/dock b/plugins/dock index f9768bd..eea495c 100755 --- a/plugins/dock +++ b/plugins/dock @@ -15,6 +15,7 @@ help(){ autohidespeed | autohide | fullscreendelay | + itunesnotifications | magnification | magnificationsize | hiddenappdimming | @@ -39,6 +40,7 @@ help(){ m dock autohide YES # Enable Dock's auto hide feature m dock autohide NO # Disable Dock's auto hide feature m dock fullscreendelay YES # Whether to have a delay when showing the dock in full screen mode + m dock itunesnotifications NO # Whether to show iTunes notifications in the dock m dock magnification YES # Turn magnification on m dock magnification NO # Turn magnification off m dock magnificationsize x # Set the max size of the icons as the cursor gets closer to them @@ -135,6 +137,20 @@ full_screen_delay(){ echo "Dock full screen delay: ${value}" } +itunes_notifications() { + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ + "itunes-notifications" \ + "$1")" + + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ + "notification-always-show-image" \ + "$1")" + + [ -n "$1" ] && killall Dock + + echo "Dock iTunes Notifications: ${value}" +} + hidden_app_dimming(){ value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ "showhidden" \ @@ -270,6 +286,10 @@ case $1 in shift full_screen_delay $@ ;; + itunesnotifications) + shift + itunes_notifications $@ + ;; magnification) shift magnify $@ From 0638d9f8ef0e7f053894bd7b386b9439ece50047 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 12:52:06 -0600 Subject: [PATCH 020/100] Change helpers to converters to be more specific --- lib/{helpers.sh => converters.sh} | 24 ++++++++---------------- lib/defaults.sh | 8 ++++---- plugins/airdrop | 2 +- plugins/airport | 12 ++++++------ plugins/display | 2 +- plugins/dock | 2 +- plugins/finder | 2 +- plugins/notification | 6 +++--- plugins/screensaver | 4 ++-- 9 files changed, 27 insertions(+), 35 deletions(-) rename lib/{helpers.sh => converters.sh} (79%) diff --git a/lib/helpers.sh b/lib/converters.sh similarity index 79% rename from lib/helpers.sh rename to lib/converters.sh index 25e565e..2d2080b 100644 --- a/lib/helpers.sh +++ b/lib/converters.sh @@ -1,12 +1,4 @@ -_mcli_print_command_status() { - local command="$1" - local subcommand="$1" - local value="$1" - - echo "${command} - ${subcommand}: ${value}" -} - -_mcli_yes_no_to_boolean() { +_mcli_convert_yes_no_to_boolean() { local choice="$1" case "${choice}" in @@ -22,17 +14,17 @@ _mcli_yes_no_to_boolean() { esac } -_mcli_exit_status_to_enabled_disabled() { +_mcli_convert_exit_status_to_enabled_disabled() { local command="$1" - if eval("${command} &> /dev/null"); then + if eval "${command} &> /dev/null" ; then echo "enabled" else echo "disabled" fi } -_mcli_yes_no_to_load_unload() { +_mcli_convert_yes_no_to_load_unload() { local choice="$1" case "${choice}" in @@ -48,7 +40,7 @@ _mcli_yes_no_to_load_unload() { esac } -_mcli_yes_no_to_inverted_boolean() { +_mcli_convert_yes_no_to_inverted_boolean() { local choice="$1" case "${choice}" in @@ -64,7 +56,7 @@ _mcli_yes_no_to_inverted_boolean() { esac } -_mcli_yes_no_to_yes_no() { +_mcli_convert_yes_no_to_yes_no() { local choice="$1" case "${choice}" in @@ -80,7 +72,7 @@ _mcli_yes_no_to_yes_no() { esac } -_mcli_yes_no_to_integer() { +_mcli_convert_yes_no_to_integer() { local choice="$1" case "${choice}" in @@ -96,7 +88,7 @@ _mcli_yes_no_to_integer() { esac } -_mcli_number_to_number() { +_mcli_convert_number_to_number() { local choice="$1" case "${choice}" in diff --git a/lib/defaults.sh b/lib/defaults.sh index 01ef448..e8a8ca9 100644 --- a/lib/defaults.sh +++ b/lib/defaults.sh @@ -51,15 +51,15 @@ _mcli_read_inverted_boolean() { } _mcli_defaults_yes_no_to_integer() { - _mcli_defaults_yes_no_to_type "integer" "yes_no_to_boolean" $@ + _mcli_defaults_yes_no_to_type "integer" "convert_yes_no_to_boolean" $@ } _mcli_defaults_yes_no_to_boolean() { - _mcli_defaults_yes_no_to_type "boolean" "yes_no_to_boolean" $@ + _mcli_defaults_yes_no_to_type "boolean" "convert_yes_no_to_boolean" $@ } _mcli_defaults_yes_no_to_inverted_boolean() { - _mcli_defaults_yes_no_to_type "boolean" "yes_no_to_inverted_boolean" $@ + _mcli_defaults_yes_no_to_type "boolean" "convert_yes_no_to_inverted_boolean" $@ } _mcli_defaults_number() { @@ -67,7 +67,7 @@ _mcli_defaults_number() { local key="$2" local new_value="$3" local sudo="$4" - local transformed="$(_mcli_number_to_number "${new_value}")" + local transformed="$(_mcli_convert_number_to_number "${new_value}")" case "${transformed}" in [0-9][.][0-9]) diff --git a/plugins/airdrop b/plugins/airdrop index 3aa1603..8453f07 100755 --- a/plugins/airdrop +++ b/plugins/airdrop @@ -1,7 +1,7 @@ #!/usr/bin/env bash source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" -source "$( dirname "${BASH_SOURCE[0]}" )/../lib/helpers.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" help(){ cat<<__EOF__ diff --git a/plugins/airport b/plugins/airport index a26fb80..b1b8880 100755 --- a/plugins/airport +++ b/plugins/airport @@ -1,7 +1,7 @@ #!/usr/bin/env bash source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" -source "$( dirname "${BASH_SOURCE[0]}" )/../lib/helpers.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" declare path_to_airport_binary="/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport" @@ -47,7 +47,7 @@ __EOF__ } disconnectonlogout(){ - local choice="$(_mcli_yes_no_to_yes_no "$1")" + local choice="$(_mcli_convert_yes_no_to_yes_no "$1")" sudo "${path_to_airport_binary}" prefs DisconnectOnLogout="${choice}" @@ -69,7 +69,7 @@ preferrednetworks(){ } rememberrecents(){ - local choice="$(_mcli_yes_no_to_yes_no "$1")" + local choice="$(_mcli_convert_yes_no_to_yes_no "$1")" sudo "${path_to_airport_binary}" prefs RememberRecentNetworks="${choice}" @@ -79,7 +79,7 @@ rememberrecents(){ } secureadhocnetworks(){ - local choice="$(_mcli_yes_no_to_yes_no "$1")" + local choice="$(_mcli_convert_yes_no_to_yes_no "$1")" sudo "${path_to_airport_binary}" prefs RequireAdminIBSS="${choice}" @@ -89,7 +89,7 @@ secureadhocnetworks(){ } securechangenetworks(){ - local choice="$(_mcli_yes_no_to_yes_no "$1")" + local choice="$(_mcli_convert_yes_no_to_yes_no "$1")" sudo "${path_to_airport_binary}" prefs RequireAdminNetworkChange="${choice}" @@ -99,7 +99,7 @@ securechangenetworks(){ } securetogglepower(){ - local choice="$(_mcli_yes_no_to_yes_no "$1")" + local choice="$(_mcli_convert_yes_no_to_yes_no "$1")" sudo "${path_to_airport_binary}" prefs RequireAdminPowerToggle="${choice}" diff --git a/plugins/display b/plugins/display index a3a93c2..53a822c 100755 --- a/plugins/display +++ b/plugins/display @@ -1,7 +1,7 @@ #!/usr/bin/env bash source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" -source "$( dirname "${BASH_SOURCE[0]}" )/../lib/helpers.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" declare path_to_plist="/Library/Preferences/com.apple.iokit.AmbientLightSensor" diff --git a/plugins/dock b/plugins/dock index eea495c..f561207 100755 --- a/plugins/dock +++ b/plugins/dock @@ -1,7 +1,7 @@ #!/usr/bin/env bash source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" -source "$( dirname "${BASH_SOURCE[0]}" )/../lib/helpers.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" help(){ cat<<__EOF__ diff --git a/plugins/finder b/plugins/finder index 08c8e4b..455d074 100755 --- a/plugins/finder +++ b/plugins/finder @@ -3,7 +3,7 @@ # TODO: add more functionalities source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" -source "$( dirname "${BASH_SOURCE[0]}" )/../lib/helpers.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" help(){ cat<<__EOF__ diff --git a/plugins/notification b/plugins/notification index d8f2f71..710486f 100755 --- a/plugins/notification +++ b/plugins/notification @@ -1,7 +1,7 @@ #!/usr/bin/env bash source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" -source "$( dirname "${BASH_SOURCE[0]}" )/../lib/helpers.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" help(){ cat<<__EOF__ @@ -15,13 +15,13 @@ __EOF__ } showcenter(){ - local choice="$(_mcli_yes_no_to_load_unload $1)" + local choice="$(_mcli_convert_yes_no_to_load_unload $1)" launchctl "${choice}" -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist [ -n "${choice}" ] && killall NotificationCenter && echo "Restart your computer for this to take effect" - value="$(_mcli_exit_status_to_enabled_disabled "ps -A | grep apsd | grep -v grep")" + value="$(_mcli_convert_exit_status_to_enabled_disabled "ps -A | grep apsd | grep -v grep")" echo "Notification Center ${value}" } diff --git a/plugins/screensaver b/plugins/screensaver index 49f0ae8..e1cfd30 100755 --- a/plugins/screensaver +++ b/plugins/screensaver @@ -1,7 +1,7 @@ #!/usr/bin/env bash source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" -source "$( dirname "${BASH_SOURCE[0]}" )/../lib/helpers.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" help(){ cat<<__EOF__ @@ -30,7 +30,7 @@ status(){ -e 'get running of screen saver preferences' \ -e 'end tell') - value="$(_mcli_yes_no_to_yes_no "${value}")" + value="$(_mcli_convert_yes_no_to_yes_no "${value}")" echo "Screensaver is running: ${value}" } From 724c018c8ad66914bc9028187ef205b3d12d3748 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 13:02:03 -0600 Subject: [PATCH 021/100] Add keyboard plugin --- Readme.md | 32 +++++++++ plugins/keyboard | 179 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 211 insertions(+) create mode 100755 plugins/keyboard diff --git a/Readme.md b/Readme.md index 5a15df5..a2b9bf7 100644 --- a/Readme.md +++ b/Readme.md @@ -59,6 +59,7 @@ usage: m [OPTIONS] COMMAND [help] hostname info itunes + keyboard lock ntp printer @@ -381,6 +382,37 @@ usage: m [OPTIONS] COMMAND [help] m itunes quit # Quit iTunes ``` +#### Keyboard: +``` + usage: m keyboard [ + accentedpress | + spellchecking | + textsubstitution | + usefunctionkeys | + inputfieldaccess | + autodim | + autodimdelay | + keyrepeatrate | + keyrepeatdelay | + help + ] + + Examples: + m keyboard accentedpress [ YES | NO ] # Whether to enable press and hold to show accented characters + m keyboard spellchecking [ YES | NO ] # Whether to enable spell check indication (red squiggly lines) + m keyboard textsubstitution [ YES | NO ] # Whether to substitute quotes, dashes, spelling corrections, etc automatically + m keyboard usefunctionkeys [ YES | NO ] # Whether to use F1 function keys or alternate function keys (brightness, etc) + m keyboard inputfieldaccess [ # Specify which input fields can be tabbed through + BASIC | + ALL_EXCEPT_DROPDOWNS | + ALL + ] + m keyboard autodim [ YES | NO ] # Whether to automatically dim the keyboard brightness when idle + m keyboard autodimdelay 2 # How long to wait before dimming the keyboard brightness + m keyboard keyrepeatrate 4 # How quickly a held key repeats + m keyboard keyrepeatdelay 1.2 # How long a key needs to be held before repeating +``` + #### Lock: ``` usage: m lock [ help ] diff --git a/plugins/keyboard b/plugins/keyboard new file mode 100755 index 0000000..3f9743c --- /dev/null +++ b/plugins/keyboard @@ -0,0 +1,179 @@ +#!/usr/bin/env bash + +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +help(){ + cat<<__EOF__ + usage: m keyboard [ + accentedpress | + spellchecking | + textsubstitution | + usefunctionkeys | + inputfieldaccess | + autodim | + autodimdelay | + keyrepeatrate | + keyrepeatdelay | + help + ] + + Examples: + m keyboard accentedpress [ YES | NO ] # Whether to enable press and hold to show accented characters + m keyboard spellchecking [ YES | NO ] # Whether to enable spell check indication (red squiggly lines) + m keyboard textsubstitution [ YES | NO ] # Whether to substitute quotes, dashes, spelling corrections, etc automatically + m keyboard usefunctionkeys [ YES | NO ] # Whether to use F1 function keys or alternate function keys (brightness, etc) + m keyboard inputfieldaccess [ # Specify which input fields can be tabbed through + BASIC | + ALL_EXCEPT_DROPDOWNS | + ALL + ] + m keyboard autodim [ YES | NO ] # Whether to automatically dim the keyboard brightness when idle + m keyboard autodimdelay 2 # How long to wait before dimming the keyboard brightness + m keyboard keyrepeatrate 4 # How quickly a held key repeats + m keyboard keyrepeatdelay 1.2 # How long a key needs to be held before repeating +__EOF__ +} + +accentedpress() { + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "ApplePressAndHoldEnabled" \ + "$1")" + + echo "Keyboard Accented Press and Hold: ${value}" +} + +spellchecking() { + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "WebContinuousSpellCheckingEnabled" \ + "$1")" + + defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "continuousSpellCheckingEnabled" -bool "${value}" + + echo "Keyboard Spell Checking: ${value}" +} + +textsubstitution() { + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "NSAutomaticDashSubstitutionEnabled" \ + "$1")" + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "NSAutomaticQuoteSubstitutionEnabled" \ + "$1")" + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "NSAutomaticSpellingCorrectionEnabled" \ + "$1")" + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "WebAutomaticSpellingCorrectionEnabled" \ + "$1")" + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "WebAutomaticDashSubstitutionEnabled" \ + "$1")" + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "WebAutomaticTextReplacementEnabled" \ + "$1")" + + defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticQuoteSubstitutionEnabled" -bool "${value}" + + echo "Keyboard Text Substitution: ${value}" +} + +usefunctionkeys() { + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "com.apple.keyboard.fnState" \ + "$1")" + + echo "Keyboard Function Keys: ${value}" +} + +inputfieldaccess() { + local mode + + case "$1" in + [aA][lL][lL]) + mode="3" + ;; + [aA][lL][lL]_[eE][xX][cC][eE][pP][tT]_[dD][rR][oO][pP][dD][oO][wW][nN][sS]) + mode="2" + ;; + [bB][aA][sS][iI][cC]) + mode="1" + ;; + esac + + value="$(_mcli_defaults_integer "NSGlobalDomain" \ + "AppleKeyboardUIMode" \ + "${mode}")" + + echo "Keyboard Input Field Access: ${value}" +} + +autodim() { + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.iokit.AmbientLightSensor" \ + "Automatic Keyboard Enabled" \ + "$1")" + + echo "Keyboard Autodimming: ${value}" +} + +autodimdelay() { + value="$(_mcli_defaults_integer "com.apple.iokit.AmbientLightSensor" \ + "Keyboard Dim Time" \ + "$1")" + + echo "Keyboard Autodimming Delay: ${value}" +} + +keyrepeatrate() { + value="$(_mcli_defaults_integer "NSGlobalDomain" \ + "KeyRepeat" \ + "$1")" + + echo "Keyboard Key Repeat Rate: ${value}" +} + +keyrepeatdelay() { + value="$(_mcli_defaults_integer "NSGlobalDomain" \ + "InitialKeyRepeat" \ + "$1")" + + echo "Keyboard Key Repeat Delay: ${value}" +} + +case $1 in + help) + help + ;; + accentedpress) + accentedpress $@ + ;; + spellchecking) + spellchecking $@ + ;; + textsubstitution) + textsubstitution $@ + ;; + usefunctionkeys) + usefunctionkeys $@ + ;; + inputfieldaccess) + inputfieldaccess $@ + ;; + autodim) + autodim $@ + ;; + autodimdelay) + autodimdelay $@ + ;; + keyrepeatrate) + keyrepeatrate $@ + ;; + keyrepeatdelay) + keyrepeatdelay $@ + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab From 883160a069613926ee42842215bf1eee3a9e8662 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 13:02:24 -0600 Subject: [PATCH 022/100] Add tags to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1330247..90376a5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +tags *.log .DS_Store From 07d85d3c485f0c33052bc73d1f5203f430f55886 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 13:02:41 -0600 Subject: [PATCH 023/100] Add spotlight plugin --- Readme.md | 9 +++++++++ lib/keyboard_shortcuts.sh | 9 +++++++++ plugins/spotlight | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 lib/keyboard_shortcuts.sh create mode 100755 plugins/spotlight diff --git a/Readme.md b/Readme.md index a2b9bf7..a6df268 100644 --- a/Readme.md +++ b/Readme.md @@ -72,6 +72,7 @@ usage: m [OPTIONS] COMMAND [help] service shutdown sleep + spotlight timezone trash update @@ -548,6 +549,14 @@ usage: m [OPTIONS] COMMAND [help] m sleep # put the mac to sleep ``` +#### Spotlight: +``` + usage: m spotlight [ shortcutkeys | help ] + + Examples: + m spotlight shortcutkeys [ YES | NO ] # Whether to enable the Cmd-Space shortcuts +``` + #### Timezone: ``` usage: m timezone [ list | ls | set | help ] diff --git a/lib/keyboard_shortcuts.sh b/lib/keyboard_shortcuts.sh new file mode 100644 index 0000000..a8270f6 --- /dev/null +++ b/lib/keyboard_shortcuts.sh @@ -0,0 +1,9 @@ +_mcli_keyboard_shortcut_toggle(){ + local path_to_plistbuddy="/usr/libexec/PlistBuddy" + local keyboard_shortcut_id="$1" + local enabled="$2" + local plist_path="/Users/$(whoami)/Library/Preferences/com.apple.symbolichotkeys.plist" + + ${path_to_plistbuddy} -c "Delete :AppleSymbolicHotKeys:${keyboard_shortcut_id}:enabled" ${plist_path} 2> /dev/null + ${path_to_plistbuddy} -c "Add :AppleSymbolicHotKeys:${keyboard_shortcut_id}:enabled bool ${enabled}" ${plist_path} 2> /dev/null +} diff --git a/plugins/spotlight b/plugins/spotlight new file mode 100755 index 0000000..8e8e972 --- /dev/null +++ b/plugins/spotlight @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/keyboard_shortcuts.sh" + +help(){ + cat<<__EOF__ + usage: m spotlight [ shortcutkeys | help ] + + Examples: + m spotlight shortcutkeys [ YES | NO ] # Whether to enable the Cmd-Space shortcuts +__EOF__ +} + +shortcut_keys() { + local spotlight_keyboard_shortcut_ids=(64 65) + local enabled="$(_mcli_convert_yes_no_to_boolean "$1")" + + for keyboard_shortcut_id in "${spotlight_keyboard_shortcut_ids[@]}"; do + _mcli_keyboard_shortcut_toggle $keyboard_shortcut_id $enabled + done +} + +case $1 in + help) + help + ;; + shortcutkeys) + shortcut_keys + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab From f153ae8f58f8cbd295cdb25aa48ad12e7d786010 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 13:44:21 -0600 Subject: [PATCH 024/100] Add tooltips plugin --- Readme.md | 12 ++++++++ lib/defaults.sh | 25 +++++++++-------- plugins/tooltips | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 12 deletions(-) create mode 100755 plugins/tooltips diff --git a/Readme.md b/Readme.md index a6df268..3311449 100644 --- a/Readme.md +++ b/Readme.md @@ -74,6 +74,7 @@ usage: m [OPTIONS] COMMAND [help] sleep spotlight timezone + tooltip trash update user @@ -567,6 +568,17 @@ usage: m [OPTIONS] COMMAND [help] m timezone set Europe/Berlin # set timezone ``` +#### Tooltips: +``` + usage: m tooltips [ delay | autowrap | fontsize | fontname | help ] + + Examples: + m tooltips delay x # Set the delay before the tooltip shows up + m tooltips autowrap [ YES | NO ] # Whether tooltips should wrap + m tooltips fontsize x.x # The size of the font in the tooltip + m tooltips fontname # The name of the font in the tooltip +``` + #### Trash: ``` usage: m trash [ status | clean | help ] diff --git a/lib/defaults.sh b/lib/defaults.sh index e8a8ca9..81bb1ed 100644 --- a/lib/defaults.sh +++ b/lib/defaults.sh @@ -9,18 +9,6 @@ _mcli_read() { ${sudo} defaults read "${domain}" "${key}" 2> /dev/null } -_mcli_write_integer() { - local domain="$1" - local key="$2" - local value="$3" - local sudo="$4" - - [ -n "${domain}" ] && [ -n "${key}" ] && [ -n "${value}" ] || return 1 - [[ -n "${sudo}" ]] && sudo="sudo" - - ${sudo} defaults write "${domain}" "${key}" -int "${value}" -} - _mcli_read_boolean_as_yes_no() { local value="$(_mcli_read $@)" @@ -81,6 +69,19 @@ _mcli_defaults_number() { _mcli_read_integer "${domain}" "${key}" } +_mcli_defaults_font() { + local domain="$1" + local key="$2" + local new_value="$3" + local sudo="$4" + + if [ -n "${new_value}" ]; then + ${sudo} defaults write "${domain}" "${key}" -font "${transformed}" + fi + + _mcli_read_integer "${domain}" "${key}" +} + _mcli_defaults_yes_no_to_type() { local type="$1" local transformer="$2" diff --git a/plugins/tooltips b/plugins/tooltips new file mode 100755 index 0000000..f505ddd --- /dev/null +++ b/plugins/tooltips @@ -0,0 +1,71 @@ +#!/usr/bin/env bash + +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/keyboard_shortcuts.sh" + +help(){ + cat<<__EOF__ + usage: m tooltips [ delay | autowrap | fontsize | fontname | help ] + + Examples: + m tooltips delay x # Set the delay before the tooltip shows up + m tooltips autowrap [ YES | NO ] # Whether tooltips should wrap + m tooltips fontsize x.x # The size of the font in the tooltip + m tooltips fontname # The name of the font in the tooltip +__EOF__ +} + +delay() { + value="$(_mcli_defaults_yes_no_to_integer "NSGlobalDomain" \ + "NSInitialToolTipDelay" \ + "$1")" + + echo "Keyboard delay: ${value}" +} + +autowrap() { + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "NSToolTipAutoWrappingDisabled" \ + "$1")" + + echo "Keyboard autowrap: ${value}" +} + +fontsize() { + value="$(_mcli_defaults_yes_no_to_number "NSGlobalDomain" \ + "NSToolTipsFontSize" \ + "$1")" + + echo "Keyboard fontsize: ${value}" +} + +fontname() { + value="$(_mcli_defaults_font "NSGlobalDomain" \ + "NSToolTipsFont" \ + "$1")" + + echo "Keyboard fontname: ${value}" +} + +case $1 in + help) + help + ;; + delay) + delay + ;; + autowrap) + autowrap + ;; + fontsize) + fontsize + ;; + fontname) + fontname + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab From 9c413398f7cedd6502e7a044015ff5883c73b94b Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 14:45:27 -0600 Subject: [PATCH 025/100] Add consistent way of extracting commands/subcommand names This was much too prone to manual error. For now I just went through the commands that were predominantly 'defaults write' commands as that what I'm currently the most focused on. I also removed the duplication of the restarting of processes and made it happen after any command (which has been given a value) has been run. --- lib/converters.sh | 16 +++++++++ plugins/airdrop | 10 ++++-- plugins/airport | 31 +++++++++-------- plugins/display | 8 +++-- plugins/dock | 83 ++++++++++++-------------------------------- plugins/finder | 24 ++++++------- plugins/keyboard | 25 +++++++------ plugins/notification | 14 +++++--- plugins/screensaver | 15 ++++---- plugins/spotlight | 9 ++++- plugins/tooltips | 2 +- 11 files changed, 120 insertions(+), 117 deletions(-) diff --git a/lib/converters.sh b/lib/converters.sh index 2d2080b..55d3075 100644 --- a/lib/converters.sh +++ b/lib/converters.sh @@ -14,6 +14,22 @@ _mcli_convert_yes_no_to_boolean() { esac } +_mcli_convert_yes_no_to_enabled_disabled() { + local choice="$1" + + case "${choice}" in + 1|[yY][eE][sS]|[tT][rU][eE]) + echo "enabled" + ;; + 0|[nN][oO]|[fF][aA][lL][sS][eE]) + echo "disabled" + ;; + *) + echo "ERROR" + ;; + esac +} + _mcli_convert_exit_status_to_enabled_disabled() { local command="$1" diff --git a/plugins/airdrop b/plugins/airdrop index 8453f07..2d1ac7f 100755 --- a/plugins/airdrop +++ b/plugins/airdrop @@ -3,6 +3,11 @@ source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + help(){ cat<<__EOF__ usage: m airdrop [ onlywifi | help ] @@ -18,15 +23,14 @@ onlywifi(){ "BrowseAllInterfaces" \ "$1")" - echo "Airdrop onlywifi: ${value}" + echo "${command} ${subcommand}: ${value}" } -case $1 in +case "${subcommand}" in help) help ;; onlywifi) - shift onlywifi $@ ;; *) diff --git a/plugins/airport b/plugins/airport index b1b8880..22cec47 100755 --- a/plugins/airport +++ b/plugins/airport @@ -4,6 +4,10 @@ source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" declare path_to_airport_binary="/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport" +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift help(){ cat<<__EOF__ @@ -53,19 +57,23 @@ disconnectonlogout(){ value="$(sudo "${path_to_airport_binary}" prefs DisconnectOnLogout)" - echo "Airport disconnectonlogout: ${value}" + echo "${command} ${subcommand}: ${value}" } nonpreferrednetworks(){ [ -n "$1" ] && sudo "${path_to_airport_binary}" prefs JoinModeFallback="$1" - sudo "${path_to_airport_binary}" prefs JoinModeFallback + value="$(sudo "${path_to_airport_binary}" prefs JoinModeFallback)" + + echo "${command} ${subcommand}: ${value}" } preferrednetworks(){ [ -n "$1" ] && sudo "${path_to_airport_binary}" prefs JoinMode="$1" - sudo "${path_to_airport_binary}" prefs JoinMode + value="$(sudo "${path_to_airport_binary}" prefs JoinMode)" + + echo "${command} ${subcommand}: ${value}" } rememberrecents(){ @@ -75,7 +83,7 @@ rememberrecents(){ value="$(sudo "${path_to_airport_binary}" prefs RememberRecentNetworks)" - echo "Airport rememberrecents: ${value}" + echo "${command} ${subcommand}: ${value}" } secureadhocnetworks(){ @@ -85,7 +93,7 @@ secureadhocnetworks(){ value="$(sudo "${path_to_airport_binary}" prefs RequireAdminIBSS)" - echo "Airport secureadhocnetworks: ${value}" + echo "${command} ${subcommand}: ${value}" } securechangenetworks(){ @@ -95,7 +103,7 @@ securechangenetworks(){ value="$(sudo "${path_to_airport_binary}" prefs RequireAdminNetworkChange)" - echo "Airport securechangenetworks: ${value}" + echo "${command} ${subcommand}: ${value}" } securetogglepower(){ @@ -105,39 +113,32 @@ securetogglepower(){ value="$(sudo "${path_to_airport_binary}" prefs RequireAdminPowerToggle)" - echo "Airport securetogglepower: ${value}" + echo "${command} ${subcommand}: ${value}" } -case $1 in +case "${subcommand}" in help) help ;; disconnectonlogout) - shift disconnectonlogout $@ ;; nonpreferrednetworks) - shift preferrednetworks $@ ;; preferrednetworks) - shift preferrednetworks $@ ;; rememberrecents) - shift rememberrecents $@ ;; secureadhocnetworks) - shift secureadhocnetworks $@ ;; securechangenetworks) - shift securechangenetworks $@ ;; securetogglepower) - shift securetogglepower $@ ;; *) diff --git a/plugins/display b/plugins/display index 53a822c..4eee0bc 100755 --- a/plugins/display +++ b/plugins/display @@ -4,6 +4,10 @@ source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" declare path_to_plist="/Library/Preferences/com.apple.iokit.AmbientLightSensor" +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift help(){ cat<<__EOF__ @@ -25,10 +29,10 @@ autobrightness() { "Automatic Display Enabled" \ "$1")" - echo "Display autobrightness: ${value}" + echo "${command} ${subcommand}: ${value}" } -case $1 in +case "${subcommand}" in help) help ;; diff --git a/plugins/dock b/plugins/dock index f561207..3c3b22f 100755 --- a/plugins/dock +++ b/plugins/dock @@ -3,6 +3,11 @@ source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + help(){ cat<<__EOF__ usage: m dock [ @@ -72,9 +77,7 @@ active_indicators(){ "show-process-indicators" \ "$1")" - [ -n "$1" ] && killall Dock - - echo "Dock activeindicators: ${value}" + echo "${command} ${subcommand}: ${value}" } bounce_on_app_activity(){ @@ -82,9 +85,7 @@ bounce_on_app_activity(){ "no-bouncing" \ "$1")" - [ -n "$1" ] && killall Dock - - echo "Dock bounceonappactivity: ${value}" + echo "${command} ${subcommand}: ${value}" } bounce_on_app_launch(){ @@ -92,9 +93,7 @@ bounce_on_app_launch(){ "launchanim" \ "$1")" - [ -n "$1" ] && killall Dock - - echo "Dock bounceonapplaunch: ${value}" + echo "${command} ${subcommand}: ${value}" } auto_hide_speed(){ @@ -102,9 +101,7 @@ auto_hide_speed(){ "autohide-time-modifier" \ "$1")" - [ -n "$1" ] && killall Dock - - echo "Dock autohidespeed: ${value}" + echo "${command} ${subcommand}: ${value}" } auto_hide_delay(){ @@ -112,9 +109,7 @@ auto_hide_delay(){ "autohide-delay" \ "$1")" - [ -n "$1" ] && killall Dock - - echo "Dock autohidedelay: ${value}" + echo "${command} ${subcommand}: ${value}" } auto_hide(){ @@ -122,9 +117,7 @@ auto_hide(){ "autohide" \ "$1")" - [ -n "$1" ] && killall Dock - - echo "Dock autohide: ${value}" + echo "${command} ${subcommand}: ${value}" } full_screen_delay(){ @@ -132,9 +125,7 @@ full_screen_delay(){ "autohide-fullscreen-delayed" \ "$1")" - [ -n "$1" ] && killall Dock - - echo "Dock full screen delay: ${value}" + echo "${command} ${subcommand}: ${value}" } itunes_notifications() { @@ -146,9 +137,7 @@ itunes_notifications() { "notification-always-show-image" \ "$1")" - [ -n "$1" ] && killall Dock - - echo "Dock iTunes Notifications: ${value}" + echo "${command} ${subcommand}: ${value}" } hidden_app_dimming(){ @@ -156,9 +145,7 @@ hidden_app_dimming(){ "showhidden" \ "$1")" - [ -n "$1" ] && killall Dock - - echo "Dock app dimming: ${value}" + echo "${command} ${subcommand}: ${value}" } magnify(){ @@ -166,9 +153,7 @@ magnify(){ "magnification" \ "$1")" - [ -n "$1" ] && killall Dock - - echo "Dock magnification: ${value}" + echo "${command} ${subcommand}: ${value}" } magnification_size(){ @@ -176,9 +161,7 @@ magnification_size(){ "largesize" \ "$1")" - [ -n "$1" ] && killall Dock - - echo "Dock magnificationsize: ${value}" + echo "${command} ${subcommand}: ${value}" } icon_size(){ @@ -186,9 +169,7 @@ icon_size(){ "tilesize" \ "$1")" - [ -n "$1" ] && killall Dock - - echo "Dock iconsize: ${value}" + echo "${command} ${subcommand}: ${value}" } only_show_running(){ @@ -196,9 +177,7 @@ only_show_running(){ "static-only" \ "$1")" - [ -n "$1" ] && killall Dock - - echo "Dock onlyshowrunning: ${value}" + echo "${command} ${subcommand}: ${value}" } dock_position(){ @@ -214,11 +193,9 @@ dock_position(){ ;; esac - [ -n "$1" ] && killall Dock - value="$(_mcli_read "com.apple.dock" "orientation")" - echo "Dock position: ${value}" + echo "${command} ${subcommand}: ${value}" } add_blank_space(){ @@ -244,7 +221,7 @@ prune(){ killall Dock } -case $1 in +case "${subcommand}" in help) help ;; @@ -255,75 +232,57 @@ case $1 in disable ;; activeindicators) - shift active_indicators $@ ;; bounceonappactivity) - shift bounce_on_app_activity $@ ;; bounceonapplaunch) - shift bounce_on_app_launch $@ ;; showdelay) - shift auto_hide_speed $@ ;; autohidedelay) - shift auto_hide_delay $@ ;; autohidespeed) - shift auto_hide_speed $@ ;; autohide) - shift auto_hide $@ ;; fullscreendelay) - shift full_screen_delay $@ ;; itunesnotifications) - shift itunes_notifications $@ ;; magnification) - shift magnify $@ ;; magnificationsize) - shift magnification_size $@ ;; hiddenappdimming) - shift hidden_app_dimming $@ ;; iconsize) - shift icon_size $@ ;; onlyshowrunning) - shift only_show_running $@ ;; position) - shift dock_position $@ ;; addblankspace) - shift add_blank_space ;; addrecentitems) - shift add_recent_items ;; prune) - shift prune ;; *) @@ -331,4 +290,6 @@ case $1 in ;; esac +[ -n "${subcommand}" ] && [ -n "$1" ] && killall Dock + # vim: ts=4 sw=4 softtabstop=4 expandtab diff --git a/plugins/finder b/plugins/finder index 455d074..f12b9da 100755 --- a/plugins/finder +++ b/plugins/finder @@ -5,6 +5,11 @@ source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + help(){ cat<<__EOF__ usage: m finder [ showhiddenfiles | showfileextensions | showdesktop | help ] @@ -29,9 +34,7 @@ hidden_files(){ "AppleShowAllFiles" \ "$1")" - [ -n "$1" ] && killall Finder - - echo "Finder showhiddenfiles: ${value}" + echo "${command} ${subcommand}: ${value}" } file_extensions(){ @@ -39,9 +42,7 @@ file_extensions(){ "AppleShowAllExtensions" \ "$1")" - [ -n "$1" ] && killall Finder - - echo "Finder showextensions: ${value}" + echo "${command} ${subcommand}: ${value}" } desktop(){ @@ -49,25 +50,20 @@ desktop(){ "CreateDesktop" \ "$1")" - [ -n "$1" ] && killall Finder - - echo "Finder showdesktop: ${value}" + echo "${command} ${subcommand}: ${value}" } -case $1 in +case "${subcommand}" in help) help ;; showhiddenfiles) - shift hidden_files "$@" ;; showextensions) - shift file_extensions "$@" ;; showdesktop) - shift desktop "$@" ;; *) @@ -75,4 +71,6 @@ case $1 in ;; esac +[ -n "${subcommand}" ] && [ -n "$1" ] && killall Finder + # vim: ts=4 sw=4 softtabstop=4 expandtab diff --git a/plugins/keyboard b/plugins/keyboard index 3f9743c..bc3e758 100755 --- a/plugins/keyboard +++ b/plugins/keyboard @@ -3,6 +3,11 @@ source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + help(){ cat<<__EOF__ usage: m keyboard [ @@ -40,7 +45,7 @@ accentedpress() { "ApplePressAndHoldEnabled" \ "$1")" - echo "Keyboard Accented Press and Hold: ${value}" + echo "${command} ${subcommand}: ${value}" } spellchecking() { @@ -50,7 +55,7 @@ spellchecking() { defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "continuousSpellCheckingEnabled" -bool "${value}" - echo "Keyboard Spell Checking: ${value}" + echo "${command} ${subcommand}: ${value}" } textsubstitution() { @@ -75,7 +80,7 @@ textsubstitution() { defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticQuoteSubstitutionEnabled" -bool "${value}" - echo "Keyboard Text Substitution: ${value}" + echo "${command} ${subcommand}: ${value}" } usefunctionkeys() { @@ -83,7 +88,7 @@ usefunctionkeys() { "com.apple.keyboard.fnState" \ "$1")" - echo "Keyboard Function Keys: ${value}" + echo "${command} ${subcommand}: ${value}" } inputfieldaccess() { @@ -105,7 +110,7 @@ inputfieldaccess() { "AppleKeyboardUIMode" \ "${mode}")" - echo "Keyboard Input Field Access: ${value}" + echo "${command} ${subcommand}: ${value}" } autodim() { @@ -113,7 +118,7 @@ autodim() { "Automatic Keyboard Enabled" \ "$1")" - echo "Keyboard Autodimming: ${value}" + echo "${command} ${subcommand}: ${value}" } autodimdelay() { @@ -121,7 +126,7 @@ autodimdelay() { "Keyboard Dim Time" \ "$1")" - echo "Keyboard Autodimming Delay: ${value}" + echo "${command} ${subcommand}: ${value}" } keyrepeatrate() { @@ -129,7 +134,7 @@ keyrepeatrate() { "KeyRepeat" \ "$1")" - echo "Keyboard Key Repeat Rate: ${value}" + echo "${command} ${subcommand}: ${value}" } keyrepeatdelay() { @@ -137,10 +142,10 @@ keyrepeatdelay() { "InitialKeyRepeat" \ "$1")" - echo "Keyboard Key Repeat Delay: ${value}" + echo "${command} ${subcommand}: ${value}" } -case $1 in +case "${subcommand}" in help) help ;; diff --git a/plugins/notification b/plugins/notification index 710486f..4623b8e 100755 --- a/plugins/notification +++ b/plugins/notification @@ -3,6 +3,11 @@ source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + help(){ cat<<__EOF__ usage: m notification [ showcenter | help ] @@ -19,19 +24,16 @@ showcenter(){ launchctl "${choice}" -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist - [ -n "${choice}" ] && killall NotificationCenter && echo "Restart your computer for this to take effect" - value="$(_mcli_convert_exit_status_to_enabled_disabled "ps -A | grep apsd | grep -v grep")" - echo "Notification Center ${value}" + echo "${command} ${subcommand}: ${value}" } -case $1 in +case "${subcommand}" in help) help ;; showcenter) - shift showcenter "$@" ;; *) @@ -39,4 +41,6 @@ case $1 in ;; esac +[ -n "${subcommand}" ] && [ -n "$1" ] && killall NotificationCenter && echo "Restart your computer for this to take effect" + # vim: ts=4 sw=4 softtabstop=4 expandtab diff --git a/plugins/screensaver b/plugins/screensaver index e1cfd30..0a7e550 100755 --- a/plugins/screensaver +++ b/plugins/screensaver @@ -3,6 +3,11 @@ source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + help(){ cat<<__EOF__ usage: m screensaver [ status | askforpassword | help ] @@ -22,7 +27,7 @@ askforpassword(){ "askForPassword" \ "$1")" - echo "Screensaver askforpassword: ${value}" + echo "${command} ${subcommand}: ${value}" } status(){ @@ -30,18 +35,16 @@ status(){ -e 'get running of screen saver preferences' \ -e 'end tell') - value="$(_mcli_convert_yes_no_to_yes_no "${value}")" + value="$(_mcli_convert_yes_no_to_enabled_disabled "${value}")" - echo "Screensaver is running: ${value}" + echo "${command}: ${value}" } - -case $1 in +case "${subcommand}" in help) help ;; askforpassword) - shift askforpassword $@ ;; status) diff --git a/plugins/spotlight b/plugins/spotlight index 8e8e972..933a9d9 100755 --- a/plugins/spotlight +++ b/plugins/spotlight @@ -3,6 +3,11 @@ source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" source "$( dirname "${BASH_SOURCE[0]}" )/../lib/keyboard_shortcuts.sh" +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + help(){ cat<<__EOF__ usage: m spotlight [ shortcutkeys | help ] @@ -19,9 +24,11 @@ shortcut_keys() { for keyboard_shortcut_id in "${spotlight_keyboard_shortcut_ids[@]}"; do _mcli_keyboard_shortcut_toggle $keyboard_shortcut_id $enabled done + + echo "${command} ${subcommand}: ${enabled}" } -case $1 in +case "${subcommand}" in help) help ;; diff --git a/plugins/tooltips b/plugins/tooltips index f505ddd..8cf95c5 100755 --- a/plugins/tooltips +++ b/plugins/tooltips @@ -47,7 +47,7 @@ fontname() { echo "Keyboard fontname: ${value}" } -case $1 in +case "${subcommand}" in help) help ;; From c7fab51229b7d68e4f6bd1b130043141a02a8dc5 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 14:53:02 -0600 Subject: [PATCH 026/100] Add password delay to screensaver --- Readme.md | 1 + plugins/screensaver | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/Readme.md b/Readme.md index 3311449..2df1079 100644 --- a/Readme.md +++ b/Readme.md @@ -511,6 +511,7 @@ usage: m [OPTIONS] COMMAND [help] m screensaver askforpassword # get password requirement to unlock m screensaver askforpassword YES # enable password requirement to unlock m screensaver askforpassword NO # disable password requirement to unlock + m screensaver passworddelay x # the length of time before screensaver requires password ``` #### Service: diff --git a/plugins/screensaver b/plugins/screensaver index 0a7e550..b9d48b5 100755 --- a/plugins/screensaver +++ b/plugins/screensaver @@ -19,6 +19,7 @@ help(){ m screensaver askforpassword # get password requirement to unlock m screensaver askforpassword YES # enable password requirement to unlock m screensaver askforpassword NO # disable password requirement to unlock + m screensaver passworddelay x # the length of time before screensaver requires password __EOF__ } @@ -30,6 +31,14 @@ askforpassword(){ echo "${command} ${subcommand}: ${value}" } +passworddelay(){ + value="$(_mcli_defaults_number "com.apple.screensaver" \ + "askForPasswordDelay" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + status(){ local value=$(osascript -e 'tell application "System Events"' \ -e 'get running of screen saver preferences' \ @@ -47,6 +56,9 @@ case "${subcommand}" in askforpassword) askforpassword $@ ;; + passworddelay) + passworddelay $@ + ;; status) status ;; From 508218ca684cb6a28ed1fd598e20a88f472e4b6a Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 15:22:41 -0600 Subject: [PATCH 027/100] Add bannertime to notification --- Readme.md | 3 ++- lib/defaults.sh | 27 ++++++++++++++++++++++++++- plugins/notification | 12 ++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 2df1079..165cc3b 100644 --- a/Readme.md +++ b/Readme.md @@ -472,12 +472,13 @@ usage: m [OPTIONS] COMMAND [help] #### Notification: ``` - usage: m notification [ showcenter | help ] + usage: m notification [ showcenter | help ] Examples: m notification showcenter # get the current status m notification showcenter YES # enable the notification center m notification showcenter NO # disable the notification center + m notification bannertime x # disable the notification center ``` diff --git a/lib/defaults.sh b/lib/defaults.sh index 81bb1ed..6d9b298 100644 --- a/lib/defaults.sh +++ b/lib/defaults.sh @@ -28,6 +28,18 @@ _mcli_read_number() { echo "${value}" } +_mcli_read_string() { + local value="$(_mcli_read $@)" + + echo "${value}" +} + +_mcli_read_font() { + local value="$(_mcli_read $@)" + + echo "${value}" +} + _mcli_read_inverted_boolean() { local value="$(_mcli_read_boolean $@)" @@ -79,7 +91,20 @@ _mcli_defaults_font() { ${sudo} defaults write "${domain}" "${key}" -font "${transformed}" fi - _mcli_read_integer "${domain}" "${key}" + _mcli_read_font "${domain}" "${key}" +} + +_mcli_defaults_string() { + local domain="$1" + local key="$2" + local new_value="$3" + local sudo="$4" + + if [ -n "${new_value}" ]; then + ${sudo} defaults write "${domain}" "${key}" -string "${transformed}" + fi + + _mcli_read_string "${domain}" "${key}" } _mcli_defaults_yes_no_to_type() { diff --git a/plugins/notification b/plugins/notification index 4623b8e..cb2b032 100755 --- a/plugins/notification +++ b/plugins/notification @@ -16,6 +16,7 @@ help(){ m notification showcenter # get the current status m notification showcenter YES # enable the notification center m notification showcenter NO # disable the notification center + m notification bannertime x # disable the notification center __EOF__ } @@ -29,6 +30,14 @@ showcenter(){ echo "${command} ${subcommand}: ${value}" } +bannertime(){ + value="$(_mcli_defaults_string "com.apple.notificationcenterui" \ + "bannerTime" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + case "${subcommand}" in help) help @@ -36,6 +45,9 @@ case "${subcommand}" in showcenter) showcenter "$@" ;; + bannertime) + bannertime "$@" + ;; *) help ;; From 4259f4129b0bbb1961f807a767c3ee1a5effa73d Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 15:57:19 -0600 Subject: [PATCH 028/100] Add mission control --- Readme.md | 11 +++++++ plugins/missioncontrol | 69 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100755 plugins/missioncontrol diff --git a/Readme.md b/Readme.md index 165cc3b..85cdc71 100644 --- a/Readme.md +++ b/Readme.md @@ -63,6 +63,7 @@ usage: m [OPTIONS] COMMAND [help] lock ntp printer + missioncontrol network nosleep notification @@ -446,6 +447,16 @@ usage: m [OPTIONS] COMMAND [help] m printer web # Enable and show web interface ``` +#### Mission Control: +``` + usage: m missioncontrol [ showcenter | help ] + + Examples: + m missioncontrol dashboardvisible [ YES | NO ] # + m missioncontrol groupwindowsbyapp [ YES | NO ] # + m missioncontrol animationspeed x.x # +``` + #### Network: ``` usage: m network [ ls | list | location | help ] diff --git a/plugins/missioncontrol b/plugins/missioncontrol new file mode 100755 index 0000000..979faf0 --- /dev/null +++ b/plugins/missioncontrol @@ -0,0 +1,69 @@ +#!/usr/bin/env bash + +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + +help(){ + cat<<__EOF__ + usage: m missioncontrol [ showcenter | help ] + + Examples: + m missioncontrol dashboardvisible [ YES | NO ] # + m missioncontrol groupwindowsbyapp [ YES | NO ] # + m missioncontrol animationspeed x.x # +__EOF__ +} + +dashboardvisible(){ + value="$(_mcli_defaults_yes_no_to_inverted_boolean "com.apple.dock" \ + "dashboard-in-overlay" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +groupwindowsbyapp(){ + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ + "expose-group-by-app" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +animationspeed() { + value="$(_mcli_defaults_number "com.apple.dock" \ + "expose-animation-duration" \ + "$1")" + value="$(_mcli_defaults_number "com.apple.dock" \ + "workspaces-edge-delay" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +case "${subcommand}" in + help) + help + ;; + dashboardvisible) + dashboardvisible "$@" + ;; + groupwindowsbyapp) + groupwindowsbyapp "$@" + ;; + animationspeed) + animationspeed "$@" + ;; + *) + help + ;; +esac + +[ -n "${subcommand}" ] && [ -n "$1" ] && killall Dock + +# vim: ts=4 sw=4 softtabstop=4 expandtab From 0c8f5452ffd24d53346d9242641135078b07e510 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 16:29:45 -0600 Subject: [PATCH 029/100] Add hot corners plugin --- Readme.md | 18 ++++++++ plugins/hotcorners | 112 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100755 plugins/hotcorners diff --git a/Readme.md b/Readme.md index 85cdc71..e588f0c 100644 --- a/Readme.md +++ b/Readme.md @@ -57,6 +57,7 @@ usage: m [OPTIONS] COMMAND [help] firewall gatekeeper hostname + hotcorners info itunes keyboard @@ -358,6 +359,23 @@ usage: m [OPTIONS] COMMAND [help] m hostname help # only shows this help ``` +#### Hot Corners: +``` + usage: m hotcorners set [ bottomleft | bottomright | topright | topleft ] + [ + donothing | + missioncontrol | + showapplicationwindows | + desktop | + startscreensaver | + disablescreensaver | + dashboard | + sleepdisplay | + launchpad | + notificationcenter + ] +``` + #### Info: ``` usage: m info [ help ] diff --git a/plugins/hotcorners b/plugins/hotcorners new file mode 100755 index 0000000..24ff30d --- /dev/null +++ b/plugins/hotcorners @@ -0,0 +1,112 @@ +#!/usr/bin/env bash + +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" + +help(){ + cat<<__EOF__ + usage: m hotcorners set [ bottomleft | bottomright | topright | topleft ] + [ + donothing | + missioncontrol | + showapplicationwindows | + desktop | + startscreensaver | + disablescreensaver | + dashboard | + sleepdisplay | + launchpad | + notificationcenter + ] +__EOF__ +} + +set(){ + local corner; + local action; + local modifier; + + case "$1" in + bottomleft) + corner="bl" + ;; + bottomright) + corner="br" + ;; + topright) + corner="tr" + ;; + topleft) + corner="tl" + ;; + *) + corner="$1" + ;; + esac + + case "$2" in + donothing) + action=0 + ;; + missioncontrol) + action=2 + ;; + showapplicationwindows) + action=3 + ;; + desktop) + action=4 + ;; + startscreensaver) + action=5 + ;; + disablescreensaver) + action=6 + ;; + dashboard) + action=7 + ;; + sleepdisplay) + action=10 + ;; + launchpad) + action=11 + ;; + notificationcenter) + action=12 + ;; + *) + action="$2" + ;; + esac + + case $3 in + true) + modifier=1 + ;; + *) + modifier=0 + ;; + esac + + defaults write com.apple.dock wvous-${corner}-corner -integer $action + defaults write com.apple.dock wvous-${corner}-modifier -integer $modifier +} + +case "${subcommand}" in + help) + help + ;; + set) + set "$@" + ;; + *) + help + ;; +esac + +[ -n "${subcommand}" ] && [ -n "$1" ] && killall Dock + +# vim: ts=4 sw=4 softtabstop=4 expandtab From 6823062f141f3e5f61926e6814594a56ef284754 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 16:47:31 -0600 Subject: [PATCH 030/100] Add filevault plugin --- Readme.md | 11 +++++++++++ plugins/filevault | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100755 plugins/filevault diff --git a/Readme.md b/Readme.md index e588f0c..e179705 100644 --- a/Readme.md +++ b/Readme.md @@ -54,6 +54,7 @@ usage: m [OPTIONS] COMMAND [help] dns dock finder + filevault firewall gatekeeper hostname @@ -282,6 +283,16 @@ usage: m [OPTIONS] COMMAND [help] ``` +#### File Vault: +``` + usage: m filevault [ status | enable | disable | help ] + + Examples: + m filevault status # FileVault Status + m filevault enable # Enable FileVault + m filevault disable # Disable FileVault +``` + #### Finder: ``` usage: m finder [ showhiddenfiles | showfileextensions | showdesktop | help ] diff --git a/plugins/filevault b/plugins/filevault new file mode 100755 index 0000000..ff01332 --- /dev/null +++ b/plugins/filevault @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + +help(){ + cat<<__EOF__ + usage: m filevault [ status | enable | disable | help ] + + Examples: + m filevault status # FileVault Status + m filevault enable # Enable FileVault + m filevault disable # Disable FileVault +__EOF__ +} + +case "${subcommand}" in + help) + help + ;; + status) + sudo fdesetup status "$@" + ;; + enable) + sudo fdesetup enable "$@" + ;; + disable) + sudo fdesetup disable "$@" + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab From aa4f453610ba4af16444b8a76917ef7ed01b7cbe Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 19:27:55 -0600 Subject: [PATCH 031/100] Add power plugin --- Readme.md | 27 ++++++++++++ plugins/power | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100755 plugins/power diff --git a/Readme.md b/Readme.md index e179705..af8b79d 100644 --- a/Readme.md +++ b/Readme.md @@ -69,6 +69,7 @@ usage: m [OPTIONS] COMMAND [help] network nosleep notification + power restart safeboot screensaver @@ -522,6 +523,32 @@ usage: m [OPTIONS] COMMAND [help] ``` +#### Power: +``` + usage: m power [ + disksleeptime | + displaysleeptime | + hibernationdelay | + sleepdelay | + powernap | + powerbuttonsleeps | + appnapp | + help + ] + + Every command that has two entries requires both the battery setting and the + plugged setting (in that order). + + Examples: + m power disksleeptime x x # Time until disks sleep + m power displaysleeptime x x # Time until displays sleep + m power hibernationdelay x x # Time until system hibernates + m power sleepdelay x x # Time until system sleeps + m power powernap [ YES | NO ] [ YES | NO ] # Whether power nap is enabled + m power powerbuttonsleeps [ YES | NO ] # Whether pressing the power button sleeps the system + m power appnap [ YES | NO ] # Whether app nap is enabled +``` + #### Restart: ``` usage: m restart [ -f | --force | help ] diff --git a/plugins/power b/plugins/power new file mode 100755 index 0000000..56a5119 --- /dev/null +++ b/plugins/power @@ -0,0 +1,113 @@ +#!/usr/bin/env bash + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + +_set_power_setting(){ + local setting="$1" + local battery_value="$2" + local plugged_value="$2" + + sudo pmset -b "${setting}" "${battery_value}" + sudo pmset -c "${setting}" "${plugged_value}" +} + +help(){ + cat<<__EOF__ + usage: m power [ + disksleeptime | + displaysleeptime | + hibernationdelay | + sleepdelay | + powernap | + powerbuttonsleeps | + appnapp | + help + ] + + Every command that has two entries requires both the battery setting and the + plugged setting (in that order). + + Examples: + m power disksleeptime x x # Time until disks sleep + m power displaysleeptime x x # Time until displays sleep + m power hibernationdelay x x # Time until system hibernates + m power sleepdelay x x # Time until system sleeps + m power powernap [ YES | NO ] [ YES | NO ] # Whether power nap is enabled + m power powerbuttonsleeps [ YES | NO ] # Whether pressing the power button sleeps the system + m power appnap [ YES | NO ] # Whether app nap is enabled +__EOF__ +} + +disksleeptime(){ + _set_power_setting "disksleep" "$1" "$2" +} + +displaysleeptime(){ + _set_power_setting "displaysleep" "$1" "$2" +} + +hibernationdelay(){ + _set_power_setting "standbydelay" "$1" "$2" +} + +sleepdelay(){ + _set_power_setting "sleep" "$1" "$2" +} + +powernap(){ + battery_value="$(_mcli_convert_yes_no_to_integer "$1")" + plugged_value="$(_mcli_convert_yes_no_to_integer "$2")" + + _set_power_setting "powernap" "${battery_value}" "${plugged_value}" +} + +powerbuttonsleeps(){ + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.loginwindow" \ + "PowerButtonSleepsSystem" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +appnapp(){ + value="$(_mcli_defaults_yes_no_to_inverted_boolean "NSGlobalDomain" \ + "NSAppSleepDisabled" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +case "${subcommand}" in + help) + help + ;; + disksleeptime) + disksleeptime "$@" + ;; + displaysleeptime) + displaysleeptime "$@" + ;; + hibernationdelay) + hibernationdelay "$@" + ;; + sleepdelay) + sleepdelay "$@" + ;; + powernap) + powernap "$@" + ;; + powerbuttonsleeps) + powerbuttonsleeps "$@" + ;; + appnapp) + appnapp "$@" + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab From 4c03fb329275372ed5dc1050a060c00ecef2cea1 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 19:50:19 -0600 Subject: [PATCH 032/100] Add dashboard plugin --- Readme.md | 10 +++++++ plugins/dashboard | 66 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100755 plugins/dashboard diff --git a/Readme.md b/Readme.md index af8b79d..0305f9b 100644 --- a/Readme.md +++ b/Readme.md @@ -48,6 +48,7 @@ usage: m [OPTIONS] COMMAND [help] airdrop battery bluetooth + dashboard dir disk display @@ -156,6 +157,15 @@ usage: m [OPTIONS] COMMAND [help] m bluetooth disable # turn off bluetooth ``` +#### Dashboard: +``` + usage: m dashboard [ enable | disable | help ] + + Examples: + m dashboard enable # Enable the dashboard + m dashboard disable # Disable the dashboard +``` + #### Debug Mode: ``` usage: m debugmode [ enable | disable ] # whether extra debugging options should diff --git a/plugins/dashboard b/plugins/dashboard new file mode 100755 index 0000000..ee73fd4 --- /dev/null +++ b/plugins/dashboard @@ -0,0 +1,66 @@ +#!/usr/bin/env bash + +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/keyboard_shortcuts.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + +_mcli_toggle_dashboard_keyboard_shortcuts(){ + local enabled="$1" + local dashboard_keyboard_shortcut_ids=(62 63) + + for keyboard_shortcut_id in "${dashboard_keyboard_shortcut_ids[@]}"; do + _mcli_keyboard_shortcut_toggle "${keyboard_shortcut_id}" "${enabled}" + done +} + +help(){ + cat<<__EOF__ + usage: m dashboard [ enable | disable | help ] + + Examples: + m dashboard enable # Enable the dashboard + m dashboard disable # Disable the dashboard +__EOF__ +} + +enable(){ + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dashboard" \ + "mcx-disabled" \ + "NO")" + + _mcli_toggle_dashboard_keyboard_shortcuts "${value}" + + echo "${command} ${subcommand}: ${value}" +} + +disable(){ + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dashboard" \ + "mcx-disabled" \ + "YES")" + + _mcli_toggle_dashboard_keyboard_shortcuts "${value}" + + echo "${command} ${subcommand}: ${value}" +} + +case "${subcommand}" in + help) + help + ;; + enable) + enable "$@" + ;; + disable) + disable "$@" + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab From 1b497d0cf9f844205df8f8cf82cc3aeddd948be9 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 20:17:01 -0600 Subject: [PATCH 033/100] Add time machine plugin --- Readme.md | 12 ++++++++ plugins/timemachine | 73 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100755 plugins/timemachine diff --git a/Readme.md b/Readme.md index 0305f9b..17773df 100644 --- a/Readme.md +++ b/Readme.md @@ -78,6 +78,7 @@ usage: m [OPTIONS] COMMAND [help] shutdown sleep spotlight + timemachine timezone tooltip trash @@ -637,6 +638,17 @@ usage: m [OPTIONS] COMMAND [help] m spotlight shortcutkeys [ YES | NO ] # Whether to enable the Cmd-Space shortcuts ``` +#### Time Machine: +``` + usage: m timemachine [ enable | disable | help ] + + Examples: + m timemachine usenewdisks [ YES | NO ] # Whether to use new disks for backups + m timemachine useallnetworkvolumes [ YES | NO ] # Whether to use unsupported network volumes for backups + m timemachine localbackups [ YES | NO ] # Whether to enable local backups + m timemachine addexclusion path # Specify a path to be excluded from backups +``` + #### Timezone: ``` usage: m timezone [ list | ls | set | help ] diff --git a/plugins/timemachine b/plugins/timemachine new file mode 100755 index 0000000..fec4167 --- /dev/null +++ b/plugins/timemachine @@ -0,0 +1,73 @@ +#!/usr/bin/env bash + +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/keyboard_shortcuts.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + +help(){ + cat<<__EOF__ + usage: m timemachine [ enable | disable | help ] + + Examples: + m timemachine usenewdisks [ YES | NO ] # Whether to use new disks for backups + m timemachine useallnetworkvolumes [ YES | NO ] # Whether to use unsupported network volumes for backups + m timemachine localbackups [ YES | NO ] # Whether to enable local backups + m timemachine addexclusion path # Specify a path to be excluded from backups +__EOF__ +} + +usenewdisks(){ + value="$(_mcli_defaults_yes_no_to_inverted_boolean "com.apple.TimeMachine" \ + "DoNotOfferNewDisksForBackup" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +useallnetworkvolumes(){ + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.systempreferences" \ + "TMShowUnsupportedNetworkVolumes" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +localbackups(){ + value="$(_mcli_convert_yes_no_to_enabled_disabled "$1")" + + sudo tmutil ${value}local +} + +addexclusion(){ + sudo defaults write /Library/Preferences/com.apple.TimeMachine SkipPaths -array-add "$1" + + sudo tmutil addexclusion -p "$1" +} + +case "${subcommand}" in + help) + help + ;; + usenewdisks) + usenewdisks "$@" + ;; + useallnetworkvolumes) + useallnetworkvolumes "$@" + ;; + localbackups) + localbackups "$@" + ;; + addexclusion) + addexclusion "$@" + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab From dda13380335e17f4ac058ac7c7dcc0d9adb9c714 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 20:54:45 -0600 Subject: [PATCH 034/100] Add datetime plugin --- Readme.md | 13 ++++++++ lib/converters.sh | 16 +++++++++ plugins/datetime | 84 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100755 plugins/datetime diff --git a/Readme.md b/Readme.md index 17773df..a65c1d5 100644 --- a/Readme.md +++ b/Readme.md @@ -49,6 +49,7 @@ usage: m [OPTIONS] COMMAND [help] battery bluetooth dashboard + datetime dir disk display @@ -167,6 +168,18 @@ usage: m [OPTIONS] COMMAND [help] m dashboard disable # Disable the dashboard ``` +#### Date and Time: +``` + usage: m datetime [ 24hourclock | usentpserver | ntpserver | international | menubarformat | help ] + + Examples: + m datetime 24hourclock [ YES | NO ] # Whether to show the time using a 24 hour clock + m datetime usentpserver [ YES | NO ] # Whether the current date time can be set via NTP + m datetime ntpserver hostname # The NTP server to use to set the time + m datetime international [ YES ] # Sets the date/time formats to the international standard + m datetime menubarformat format # Sets format of the clock in the menu bar +``` + #### Debug Mode: ``` usage: m debugmode [ enable | disable ] # whether extra debugging options should diff --git a/lib/converters.sh b/lib/converters.sh index 55d3075..149ed33 100644 --- a/lib/converters.sh +++ b/lib/converters.sh @@ -14,6 +14,22 @@ _mcli_convert_yes_no_to_boolean() { esac } +_mcli_convert_yes_no_to_on_off() { + local choice="$1" + + case "${choice}" in + 1|[yY][eE][sS]|[tT][rU][eE]) + echo "on" + ;; + 0|[nN][oO]|[fF][aA][lL][sS][eE]) + echo "off" + ;; + *) + echo "ERROR" + ;; + esac +} + _mcli_convert_yes_no_to_enabled_disabled() { local choice="$1" diff --git a/plugins/datetime b/plugins/datetime new file mode 100755 index 0000000..2b0ab7d --- /dev/null +++ b/plugins/datetime @@ -0,0 +1,84 @@ +#!/usr/bin/env bash + +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + +help(){ + cat<<__EOF__ + usage: m datetime [ 24hourclock | usentpserver | ntpserver | international | menubarformat | help ] + + Examples: + m datetime 24hourclock [ YES | NO ] # Whether to show the time using a 24 hour clock + m datetime usentpserver [ YES | NO ] # Whether the current date time can be set via NTP + m datetime ntpserver hostname # The NTP server to use to set the time + m datetime international [ YES ] # Sets the date/time formats to the international standard + m datetime menubarformat format # Sets format of the clock in the menu bar +__EOF__ +} + +24hourclock(){ + local choice="$(_mcli_convert_yes_no_to_boolean "$1")" + local hour_format="$(if [[ "${choice}" == "true" ]]; then echo "H"; else echo "h"; fi)" + + defaults delete NSGlobalDomain AppleICUTimeFormatStrings > /dev/null 2&>1 + + defaults write NSGlobalDomain AppleICUTimeFormatStrings -dict-add "1" "${hour_format}:mm" + defaults write NSGlobalDomain AppleICUTimeFormatStrings -dict-add "2" "${hour_format}:mm:ss" + defaults write NSGlobalDomain AppleICUTimeFormatStrings -dict-add "3" "${hour_format}:mm:ss z" + defaults write NSGlobalDomain AppleICUTimeFormatStrings -dict-add "4" "${hour_format}:mm:ss zzzz" + defaults write NSGlobalDomain AppleICUForce24HourTime -bool "${choice}" +} + +usentpserver(){ + local choice="$(_mcli_convert_yes_no_to_on_off "$1")" + + sudo sh -c "/usr/sbin/systemsetup -setusingnetworktime ${choice} &> /dev/null" +} + +ntpserver(){ + sudo sh -c "/usr/sbin/systemsetup -setnetworktimeserver '$1' &> /dev/null" +} + +international() { + defaults delete NSGlobalDomain AppleICUDateFormatStrings > /dev/null 2&>1 + + defaults write NSGlobalDomain AppleICUDateFormatStrings -dict-add "1" "yyyy-MM-dd" + defaults write NSGlobalDomain AppleICUDateFormatStrings -dict-add "2" "yyyy MMM d" + defaults write NSGlobalDomain AppleICUDateFormatStrings -dict-add "3" "yyyy MMMM d" + defaults write NSGlobalDomain AppleICUDateFormatStrings -dict-add "4" "EEEE yyyy MMMM d" +} + +menubarformat() { + defaults write com.apple.menuextra.clock DateFormat -string "$1" +} + +case "${subcommand}" in + help) + help + ;; + 24hourclock) + 24hourclock "$@" + ;; + usentpserver) + usentpserver "$@" + ;; + ntpserver) + ntpserver "$@" + ;; + international) + international "$@" + ;; + menubarformat) + menubarformat "$@" + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab From c525512c0c51a684319e78d25dc7689304c81d68 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 21:07:46 -0600 Subject: [PATCH 035/100] Add locale plugin --- Readme.md | 10 ++++++++++ plugins/locale | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100755 plugins/locale diff --git a/Readme.md b/Readme.md index a65c1d5..c161b77 100644 --- a/Readme.md +++ b/Readme.md @@ -64,6 +64,7 @@ usage: m [OPTIONS] COMMAND [help] info itunes keyboard + locale lock ntp printer @@ -470,6 +471,15 @@ usage: m [OPTIONS] COMMAND [help] m keyboard keyrepeatdelay 1.2 # How long a key needs to be held before repeating ``` +#### Locale: +``` + usage: m locale [ onlywifi | help ] + + Examples: + m locale language # Specify the language to use (eg en_US) + m locale unit [ metric | english ] # Specify the measurement unit +``` + #### Lock: ``` usage: m lock [ help ] diff --git a/plugins/locale b/plugins/locale new file mode 100755 index 0000000..8af5e24 --- /dev/null +++ b/plugins/locale @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + +help(){ + cat<<__EOF__ + usage: m locale [ onlywifi | help ] + + Examples: + m locale language # Specify the language to use (eg en_US) + m locale unit [ metric | english ] # Specify the measurement unit +__EOF__ +} + +language(){ + defaults write NSGlobalDomain AppleLocale "$1" +} + +unit(){ + local unit="$(if [[ "$1" == "metric" ]]; then echo "Centimeters"; else echo "Inches"; fi)" + local metric="$(if [[ "$1" == "metric" ]]; then echo "true"; else echo "false"; fi)" + + defaults write NSGlobalDomain AppleMeasurementUnits -string "${unit}" + defaults write NSGlobalDomain AppleMetricUnits -boolean "${metric}" +} + +case "${subcommand}" in + help) + help + ;; + language) + language $@ + ;; + unit) + unit $@ + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab From 6921e9fc080b2d3302c1f041300b5a91511f6e83 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 21:08:17 -0600 Subject: [PATCH 036/100] Fix issues with matching 'true' text --- lib/converters.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/converters.sh b/lib/converters.sh index 149ed33..6b3b299 100644 --- a/lib/converters.sh +++ b/lib/converters.sh @@ -2,7 +2,7 @@ _mcli_convert_yes_no_to_boolean() { local choice="$1" case "${choice}" in - 1|[yY][eE][sS]|[tT][rU][eE]) + 1|[yY][eE][sS]|[tT][rR][uU][eE]) echo "true" ;; 0|[nN][oO]|[fF][aA][lL][sS][eE]) @@ -18,7 +18,7 @@ _mcli_convert_yes_no_to_on_off() { local choice="$1" case "${choice}" in - 1|[yY][eE][sS]|[tT][rU][eE]) + 1|[yY][eE][sS]|[tT][rR][uU][eE]) echo "on" ;; 0|[nN][oO]|[fF][aA][lL][sS][eE]) @@ -34,7 +34,7 @@ _mcli_convert_yes_no_to_enabled_disabled() { local choice="$1" case "${choice}" in - 1|[yY][eE][sS]|[tT][rU][eE]) + 1|[yY][eE][sS]|[tT][rR][uU][eE]) echo "enabled" ;; 0|[nN][oO]|[fF][aA][lL][sS][eE]) @@ -60,7 +60,7 @@ _mcli_convert_yes_no_to_load_unload() { local choice="$1" case "${choice}" in - 1|[yY][eE][sS]|[tT][rU][eE]) + 1|[yY][eE][sS]|[tT][rR][uU][eE]) echo "load" ;; 0|[nN][oO]|[fF][aA][lL][sS][eE]) @@ -76,7 +76,7 @@ _mcli_convert_yes_no_to_inverted_boolean() { local choice="$1" case "${choice}" in - 1|[yY][eE][sS]|[tT][rU][eE]) + 1|[yY][eE][sS]|[tT][rR][uU][eE]) echo "false" ;; 0|[nN][oO]|[fF][aA][lL][sS][eE]) @@ -92,7 +92,7 @@ _mcli_convert_yes_no_to_yes_no() { local choice="$1" case "${choice}" in - 1|[yY][eE][sS]|[tT][rU][eE]) + 1|[yY][eE][sS]|[tT][rR][uU][eE]) echo "YES" ;; 0|[nN][oO]|[fF][aA][lL][sS][eE]) @@ -108,7 +108,7 @@ _mcli_convert_yes_no_to_integer() { local choice="$1" case "${choice}" in - 1|[yY][eE][sS]|[tT][rU][eE]) + 1|[yY][eE][sS]|[tT][rR][uU][eE]) echo "1" ;; 0|[nN][oO]|[fF][aA][lL][sS][eE]) From 975c1afb3cabd749f6e652ffcce25f20615bb2c8 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 21:21:04 -0600 Subject: [PATCH 037/100] Add autobackup and mediakeys to itunes --- Readme.md | 36 ++++++++++++++++++---------------- plugins/itunes | 53 +++++++++++++++++++++++++++++++++++++------------- 2 files changed, 59 insertions(+), 30 deletions(-) diff --git a/Readme.md b/Readme.md index c161b77..165d0df 100644 --- a/Readme.md +++ b/Readme.md @@ -421,23 +421,25 @@ usage: m [OPTIONS] COMMAND [help] m info # print macOS operating system version information ``` -### Itunes: -``` - usage: m itunes [ status | play | pause | next | prev | mute | unmute | vol up | vol down | vol #| stop | quit | help ] - - Examples: - m itunes status # Show status - m itunes play # Play track - m itunes pause # Pause track - m itunes next # Play next track - m itunes prev # Play previous track - m itunes mute # Mute iTunes - m itunes unmute # Unmute iTunes - m itunes vol up # Volume Up - m itunes vol down # Volume Down - m itunes vol # # Set volume level - m itunes stop # Stop track - m itunes quit # Quit iTunes +### iTunes: +``` + usage: m itunes [ status | play | pause | next | prev | mute | unmute | vol up | vol down | vol # | stop | quit | autobackup | mediakeys | help ] + + Examples: + m itunes status # Show status + m itunes play # Play track + m itunes pause # Pause track + m itunes next # Play next track + m itunes prev # Play previous track + m itunes mute # Mute iTunes + m itunes unmute # Unmute iTunes + m itunes vol up # Volume Up + m itunes vol down # Volume Down + m itunes vol # # Set volume level + m itunes stop # Stop track + m itunes quit # Quit iTunes + m itunes autobackup [ YES | NO ] # Whether to backup devices after sync + m itunes mediakeys [ YES | NO ] # Whether to enable iTunes media keys ``` #### Keyboard: diff --git a/plugins/itunes b/plugins/itunes index 161a8c4..a423c07 100755 --- a/plugins/itunes +++ b/plugins/itunes @@ -1,29 +1,56 @@ #!/usr/bin/env bash +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + help () { cat<<__EOF__ - usage: m itunes [ status | play | pause | next | prev | mute | unmute | vol up | vol down | vol # | stop | quit | help ] + usage: m itunes [ status | play | pause | next | prev | mute | unmute | vol up | vol down | vol # | stop | quit | autobackup | mediakeys | help ] Examples: - m itunes status # Show status - m itunes play # Play track - m itunes pause # Pause track - m itunes next # Play next track - m itunes prev # Play previous track - m itunes mute # Mute iTunes - m itunes unmute # Unmute iTunes - m itunes vol up # Volume Up - m itunes vol down # Volume Down - m itunes vol # # Set volume level - m itunes stop # Stop track - m itunes quit # Quit iTunes + m itunes status # Show status + m itunes play # Play track + m itunes pause # Pause track + m itunes next # Play next track + m itunes prev # Play previous track + m itunes mute # Mute iTunes + m itunes unmute # Unmute iTunes + m itunes vol up # Volume Up + m itunes vol down # Volume Down + m itunes vol # # Set volume level + m itunes stop # Stop track + m itunes quit # Quit iTunes + m itunes autobackup [ YES | NO ] # Whether to backup devices after sync + m itunes mediakeys [ YES | NO ] # Whether to enable iTunes media keys __EOF__ } +autobackup(){ + value="$(_mcli_defaults_yes_no_to_inverted_boolean "com.apple.iTunes" \ + "AutomaticDeviceBackupsDisabled" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +mediakeys(){ + value="$(_mcli_convert_yes_no_to_load_unload "$1")" + + launchctl ${value} -w /System/Library/LaunchAgents/com.apple.rcd.plist 2> /dev/null +} + case $1 in help) help ;; + autobackup) + autobackup "$@" + ;; + mediakeys) + mediakeys "$@" + ;; status) state=`osascript -e 'tell application "iTunes" to player state as string'` echo "iTunes is currently $state." From 0964f8f3291c39af7aec4f755c534a16cd4d83e9 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 21:37:17 -0600 Subject: [PATCH 038/100] Add diskutility plugin --- Readme.md | 11 ++++++++ plugins/diskutility | 64 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100755 plugins/diskutility diff --git a/Readme.md b/Readme.md index 165d0df..0ca8f0a 100644 --- a/Readme.md +++ b/Readme.md @@ -52,6 +52,7 @@ usage: m [OPTIONS] COMMAND [help] datetime dir disk + diskutility display dns dock @@ -309,6 +310,16 @@ usage: m [OPTIONS] COMMAND [help] ``` +#### Disk Utility: +``` + usage: m diskutility [ advancedoptions | showhiddenpartitions | showunsupportednetworks | help ] + + Examples: + m diskutility advancedoptions [ YES | NO ] # Whether to enable advanced disk utility options + m diskutility showhiddenpartitions [ YES | NO ] # Whether to show hidden partitions + m diskutility showunsupportednetworks [ YES | NO ] # Whether to show unsupported networks +``` + #### File Vault: ``` usage: m filevault [ status | enable | disable | help ] diff --git a/plugins/diskutility b/plugins/diskutility new file mode 100755 index 0000000..ff440f5 --- /dev/null +++ b/plugins/diskutility @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + +help(){ + cat<<__EOF__ + usage: m diskutility [ advancedoptions | showhiddenpartitions | showunsupportednetworks | help ] + + Examples: + m diskutility advancedoptions [ YES | NO ] # Whether to enable advanced disk utility options + m diskutility showhiddenpartitions [ YES | NO ] # Whether to show hidden partitions + m diskutility showunsupportednetworks [ YES | NO ] # Whether to show unsupported networks +__EOF__ +} + +advancedoptions(){ + value="$(_mcli_defaults_yes_no_to_integer "com.apple.DiskUtility" \ + "advanced-image-options" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +showhiddenpartitions(){ + value="$(_mcli_defaults_yes_no_to_integer "com.apple.DiskUtility" \ + "DUShowEveryPartition" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +showunsupportednetworks(){ + value="$(_mcli_defaults_yes_no_to_integer "com.apple.DiskUtility" \ + "DUShowUnsupportedNetworks" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +case "${subcommand}" in + help) + help + ;; + advancedoptions) + advancedoptions "$@" + ;; + showhiddenpartitions) + showhiddenpartitions "$@" + ;; + showunsupportednetworks) + showunsupportednetworks "$@" + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab From 969f2d72c5fce41a384b5a4eac4f6df2c9d91451 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 21:46:42 -0600 Subject: [PATCH 039/100] Add new firewall commands --- Readme.md | 17 ++++++++++------- plugins/firewall | 43 ++++++++++++++++++++++++++++++++----------- 2 files changed, 42 insertions(+), 18 deletions(-) diff --git a/Readme.md b/Readme.md index 0ca8f0a..3053ef7 100644 --- a/Readme.md +++ b/Readme.md @@ -354,13 +354,16 @@ usage: m [OPTIONS] COMMAND [help] usage: m firewall [ status | enable | disable | list | add | remove | help ] Examples: - m firewall status # Show status - m firewall enable # Enable firewall - m firewall disable # Disable firewall - m firewall list # List applications handled by firewall - m firewall add /path/to/file # Add app to firewall - m firewall remove /path/to/file # Remove app from firewall - + m firewall status # Show status + m firewall enable # Enable firewall + m firewall disable # Disable firewall + m firewall list # List applications handled by firewall + m firewall autoallowsignedapps [ YES | NO ] # Whether to allow signed applications automatically + m firewall blockall [ YES | NO ] # Whether to block all incoming connections + m firewall logging [ YES | NO ] # Whether to enable firewall logging + m firewall stealth [ YES | NO ] # Whether to respond to pings + m firewall add /path/to/file # Add app to firewall + m firewall remove /path/to/file # Remove app from firewall ``` #### Gatekeeper: diff --git a/plugins/firewall b/plugins/firewall index 52e2da6..d0584aa 100755 --- a/plugins/firewall +++ b/plugins/firewall @@ -5,18 +5,19 @@ help(){ usage: m firewall [ status | enable | disable | list | add | remove | help ] Examples: - m firewall status # Show status - m firewall enable # Enable firewall - m firewall disable # Disable firewall - m firewall list # List applications handled by firewall - m firewall add /path/to/file # Add app to firewall - m firewall remove /path/to/file # Remove app from firewall - + m firewall status # Show status + m firewall enable # Enable firewall + m firewall disable # Disable firewall + m firewall list # List applications handled by firewall + m firewall autoallowsignedapps [ YES | NO ] # Whether to allow signed applications automatically + m firewall blockall [ YES | NO ] # Whether to block all incoming connections + m firewall logging [ YES | NO ] # Whether to enable firewall logging + m firewall stealth [ YES | NO ] # Whether to respond to pings + m firewall add /path/to/file # Add app to firewall + m firewall remove /path/to/file # Remove app from firewall __EOF__ } - - case $1 in help) help @@ -30,16 +31,36 @@ case $1 in disable) sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off ;; + autoallowsignedapps) + choice="$(_mcli_convert_yes_no_to_on_off "$1")" + + sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setallowsigned "${choice}" + ;; + blockall) + choice="$(_mcli_convert_yes_no_to_on_off "$1")" + + sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setblockall "${choice}" + ;; + logging) + choice="$(_mcli_convert_yes_no_to_on_off "$1")" + + sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setloggingmode "${choice}" + ;; + stealth) + choice="$(_mcli_convert_yes_no_to_on_off "$1")" + + sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setstealthmode "${choice}" + ;; list) sudo /usr/libexec/ApplicationFirewall/socketfilterfw --list ;; add) [ -z "$2" ] && help && exit 1 - sudo /usr/libexec/ApplicationFirewall/socketfilterfw --add $2 + sudo /usr/libexec/ApplicationFirewall/socketfilterfw --add "$2" ;; remove) [ -z "$2" ] && help && exit 1 - sudo /usr/libexec/ApplicationFirewall/socketfilterfw --remove $2 + sudo /usr/libexec/ApplicationFirewall/socketfilterfw --remove "$2" ;; *) help From 6c3057c6cb0ff98e4298fbac8c7eca5dc1ff58ea Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 22:17:31 -0600 Subject: [PATCH 040/100] Add scrolling plugin --- Readme.md | 15 +++++- plugins/scrolling | 124 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+), 1 deletion(-) create mode 100755 plugins/scrolling diff --git a/Readme.md b/Readme.md index 3053ef7..470d02f 100644 --- a/Readme.md +++ b/Readme.md @@ -77,6 +77,7 @@ usage: m [OPTIONS] COMMAND [help] restart safeboot screensaver + scrolling service shutdown sleep @@ -620,7 +621,7 @@ usage: m [OPTIONS] COMMAND [help] #### Screensaver: ``` - usage: m screensaver [ status | askforpassword | help ] + usage: m screensaver [ status | askforpassword | passworddelay | help ] Examples: m screensaver # launch screensaver @@ -632,6 +633,18 @@ usage: m [OPTIONS] COMMAND [help] m screensaver passworddelay x # the length of time before screensaver requires password ``` +#### Scrolling: +``` + usage: m scrolling [ direction | barvisibility | bounce | autoscrolldelay | momentum | help ] + + Examples: + m scrolling direction [ natural | inverted ] # What direction the content moves when swiping + m scrolling barvisibility [ onlywhenscrolling | always ] # When to show scroll bars + m scrolling bounce [ YES | NO ] # Whether to bounce at the end of scrolling + m scrolling autoscrolldelay x # Set the delay before the windows contents begins to scroll when you drag content to the edge + m scrolling momentum [ YES | NO ] # Whether to use momentum when scrolling +``` + #### Service: ``` usage: m service [ --status-all | --list | --ls | start | stop | load | unload | help ] diff --git a/plugins/scrolling b/plugins/scrolling new file mode 100755 index 0000000..09f1f70 --- /dev/null +++ b/plugins/scrolling @@ -0,0 +1,124 @@ +#!/usr/bin/env bash + +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + +help(){ + cat<<__EOF__ + usage: m scrolling [ direction | barvisibility | bounce | autoscrolldelay | momentum | help ] + + Examples: + m scrolling direction [ natural | inverted ] # What direction the content moves when swiping + m scrolling barvisibility [ onlywhenscrolling | always ] # When to show scroll bars + m scrolling bounce [ YES | NO ] # Whether to bounce at the end of scrolling + m scrolling autoscrolldelay x # Set the delay before the windows contents begins to scroll when you drag content to the edge + m scrolling momentum [ YES | NO ] # Whether to use momentum when scrolling +__EOF__ +} + +direction(){ + local enabled; + + case "$1" in + natural) + enabled="true";; + inverted) + enabled="false";; + *) + enabled="$1";; + esac + + value="$(_mcli_defaults_string "NSGlobalDomain" \ + "com.apple.swipescrolldirection" \ + "${enabled}")" + + echo "${command} ${subcommand}: ${value}" +} + +barvisibility(){ + local mode; + + case "$1" in + onlywhenscrolling) + mode="Automatic";; + always) + mode="Manual";; + *) + mode="$1";; + esac + + value="$(_mcli_defaults_string "NSGlobalDomain" \ + "AppleShowScrollBars" \ + "${mode}")" + + echo "${command} ${subcommand}: ${value}" +} + +bounce(){ + value="$(_mcli_defaults_yes_no_to_boolean "/Library/Preferences/.GlobalPreferences" \ + "NSScrollViewRubberbanding" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +autoscrolldelay(){ + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "NSDraggingAutoscrollDelay" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +momentum(){ + # Internal Trackpad + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "AppleScrollAnimationEnabled" \ + "$1")" + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.AppleMultitouchTrackpad" \ + "TrackpadMomentumScroll " \ + "$1")" + + # External Trackpad + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.driver.AppleBluetoothMultitouch.trackpad" \ + "TrackpadMomentumScroll" \ + "$1")" + + # Mouse + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.driver.AppleBluetoothMultitouch.mouse" \ + "MouseMomentumScroll" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +case "${subcommand}" in + help) + help + ;; + direction) + direction "$@" + ;; + barvisibility) + barvisibility "$@" + ;; + bounce) + bounce "$@" + ;; + autoscrolldelay) + autoscrolldelay "$@" + ;; + momentum) + momentum "$@" + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab From 42a892fa51ffb15e2cd6a5cb8024ca4fc79aaf10 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Fri, 6 Jan 2017 22:39:22 -0600 Subject: [PATCH 041/100] Add diskimages plugin --- Readme.md | 10 +++++++ plugins/diskimages | 72 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100755 plugins/diskimages diff --git a/Readme.md b/Readme.md index 470d02f..3fa497f 100644 --- a/Readme.md +++ b/Readme.md @@ -52,6 +52,7 @@ usage: m [OPTIONS] COMMAND [help] datetime dir disk + diskimages diskutility display dns @@ -220,6 +221,15 @@ usage: m [OPTIONS] COMMAND [help] ``` +#### Disk Images: +``` + usage: m diskimages [ automount | verification | help ] + + Examples: + m diskimages automount [ YES | NO ] # Whether to automount disk images + m diskimages verification [ YES | NO ] # Whether to verify disk image integrity +``` + #### Display: ``` usage: m display [ status | lightsensor | help ] diff --git a/plugins/diskimages b/plugins/diskimages new file mode 100755 index 0000000..e583344 --- /dev/null +++ b/plugins/diskimages @@ -0,0 +1,72 @@ +#!/usr/bin/env bash + +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + +help(){ + cat<<__EOF__ + usage: m diskimages [ automount | verification | help ] + + Examples: + m diskimages automount [ YES | NO ] # Whether to automount disk images + m diskimages verification [ YES | NO ] # Whether to verify disk image integrity +__EOF__ +} + +automount(){ + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.frameworks.diskimages" \ + "auto-open-ro-root" \ + "$1")" + + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.frameworks.diskimages" \ + "auto-open-rw-root" \ + "$1")" + + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.finder" \ + "OpenWindowForNewRemovableDisk" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +verification(){ + value="$(_mcli_defaults_yes_no_to_inverted_boolean "com.apple.frameworks.diskimages" \ + "skip-idme" \ + "$1")" + + value="$(_mcli_defaults_yes_no_to_inverted_boolean "com.apple.frameworks.diskimages" \ + "skip-verify" \ + "$1")" + + value="$(_mcli_defaults_yes_no_to_inverted_boolean "com.apple.frameworks.diskimages" \ + "skip-verify-locked" \ + "$1")" + + value="$(_mcli_defaults_yes_no_to_inverted_boolean "com.apple.frameworks.diskimages" \ + "skip-verify-remote" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +case "${subcommand}" in + help) + help + ;; + automount) + automount "$@" + ;; + verification) + verification "$@" + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab From d7c22baf02f3cea65908635d1ce02dea9773a6d1 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 10:21:50 -0600 Subject: [PATCH 042/100] Add appearance plugin --- Readme.md | 30 ++++++ plugins/appearance | 247 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 277 insertions(+) create mode 100755 plugins/appearance diff --git a/Readme.md b/Readme.md index 3fa497f..1f80daf 100644 --- a/Readme.md +++ b/Readme.md @@ -46,6 +46,8 @@ usage: m [OPTIONS] COMMAND [help] COMMANDS: help airdrop + airport + appearance battery bluetooth dashboard @@ -145,6 +147,34 @@ usage: m [OPTIONS] COMMAND [help] # wi-fi on or off ``` +#### Appearance: +``` + usage: m appearance [ inputfocusring | darkmode | transparency | antialiasthreshold | sidebariconsize | maincolor | highlightcolor | help ] + + Examples: + m appearance inputfocusring [ YES | NO ] # Whether to show the focus ring when an input gains focus + m appearance darkmode [ YES | NO ] # Whether to use dark versions of interface elements + m appearance transparency [ YES | NO ] # Whether to allow the OS to make certain elements semi-transparent + m appearance antialiasthreshold x # The threshold above which antialiasing is turned on + m appearance sidebariconsize [ small | medium | large ] # The size of the icons in various window sidebars + m appearance maincolor [ blue | graphite ] # The color used for the majority of the interface elements + m appearance highlightcolor [ # The color used for the majority of the interface elements + graphite | cayenne | asparagus | clover | + teal | midnight | plum | tin | + nickel | mocha | fern | moss | + ocean | eggplant | maroon | steel | + aluminum | maraschino | lemon | spring | + turquoise | blueberry | magenta | iron | + magnesium | tangerine | lime | seafoam | + aqua | grape | strawberry | tungsten | + silver | salmon | banana | flora | + ice | orchid | bubblegum | lead | + mercery | cantaloupe | honeydew | spindrift | + sky | lavender | carnation | licorice | + snow + ] +``` + #### Battery: ``` usage: m battery [ status | help ] diff --git a/plugins/appearance b/plugins/appearance new file mode 100755 index 0000000..3a880f3 --- /dev/null +++ b/plugins/appearance @@ -0,0 +1,247 @@ +#!/usr/bin/env bash + +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + +help(){ + cat<<__EOF__ + usage: m appearance [ inputfocusring | darkmode | transparency | antialiasthreshold | sidebariconsize | maincolor | highlightcolor | help ] + + Examples: + m appearance inputfocusring [ YES | NO ] # Whether to show the focus ring when an input gains focus + m appearance darkmode [ YES | NO ] # Whether to use dark versions of interface elements + m appearance transparency [ YES | NO ] # Whether to allow the OS to make certain elements semi-transparent + m appearance antialiasthreshold x # The threshold above which antialiasing is turned on + m appearance sidebariconsize [ small | medium | large ] # The size of the icons in various window sidebars + m appearance maincolor [ blue | graphite ] # The color used for the majority of the interface elements + m appearance highlightcolor [ # The color used for the majority of the interface elements + graphite | cayenne | asparagus | clover | + teal | midnight | plum | tin | + nickel | mocha | fern | moss | + ocean | eggplant | maroon | steel | + aluminum | maraschino | lemon | spring | + turquoise | blueberry | magenta | iron | + magnesium | tangerine | lime | seafoam | + aqua | grape | strawberry | tungsten | + silver | salmon | banana | flora | + ice | orchid | bubblegum | lead | + mercery | cantaloupe | honeydew | spindrift | + sky | lavender | carnation | licorice | + snow + ] +__EOF__ +} + +inputfocusring(){ + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "NSUseAnimatedFocusRing" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +darkmode(){ + local choice="$(_mcli_convert_yes_no_to_boolean "$1")" + local mode="$(if [[ "${choice}" == "true" ]]; then echo "Dark"; else echo "Light"; fi)" + + defaults write NSGlobalDomain AppleInterfaceStyle "${mode}" + defaults write NSGlobalDomain NSFullScreenDarkMenu -boolean "${choice}" +} + +transparency(){ + value="$(_mcli_defaults_yes_no_to_inverted_boolean "com.apple.universalaccess" \ + "reduceTransparency" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +antialiasthreshold(){ + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "AppleAntiAliasingThreshold" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +sidebariconsize(){ + local size + + case $1 in + small) + size="1" + ;; + medium) + size="2" + ;; + large) + size="3" + ;; + esac + + defaults write NSGlobalDomain NSTableViewDefaultSizeMode -integer "${size}" + defaults write NSGlobalDomain NSNavPanelIconViewIconSizeForOpenMode -integer "${size}" +} + +maincolor(){ + local color + + case $1 in + blue) + color="1" + ;; + graphite) + color="6" + ;; + *) + color="$1" + ;; + esac + + defaults write NSGlobalDomain AppleAquaColorVariant -int $color +} + +highlightcolor(){ + local color + + # Highlight colors (from the crayons picker) + case $1 in + graphite) + color="0.780400 0.815700 0.858800";; + cayenne) + color="0.501961 0.000000 0.000000";; + asparagus) + color="0.501961 0.501961 0.000000";; + clover) + color="0.000000 0.501961 0.000000";; + teal) + color="0.000000 0.501961 0.501961";; + midnight) + color="0.000000 0.000000 0.501961";; + plum) + color="0.501961 0.000000 0.501961";; + tin) + color="0.498039 0.498039 0.498039";; + nickel) + color="0.501961 0.501961 0.501961";; + mocha) + color="0.501961 0.250980 0.000000";; + fern) + color="0.250980 0.501961 0.000000";; + moss) + color="0.000000 0.501961 0.250980";; + ocean) + color="0.000000 0.250980 0.501961";; + eggplant) + color="0.250980 0.000000 0.501961";; + maroon) + color="0.501961 0.000000 0.250980";; + steel) + color="0.400000 0.400000 0.400000";; + aluminum) + color="0.600000 0.600000 0.600000";; + maraschino) + color="1.000000 0.000000 0.000000";; + lemon) + color="1.000000 1.000000 0.000000";; + spring) + color="0.000000 1.000000 0.000000";; + turquoise) + color="0.000000 1.000000 1.000000";; + blueberry) + color="0.000000 0.000000 1.000000";; + magenta) + color="1.000000 0.000000 1.000000";; + iron) + color="0.298039 0.298039 0.298039";; + magnesium) + color="0.701961 0.701961 0.701961";; + tangerine) + color="1.000000 0.501961 0.000000";; + lime) + color="0.501961 1.000000 0.000000";; + seafoam) + color="0.000000 1.000000 0.501961";; + aqua) + color="0.000000 0.501961 1.000000";; + grape) + color="0.501961 0.000000 1.000000";; + strawberry) + color="1.000000 0.000000 0.501961";; + tungsten) + color="0.200000 0.200000 0.200000";; + silver) + color="0.800000 0.800000 0.800000";; + salmon) + color="1.000000 0.400000 0.400000";; + banana) + color="1.000000 1.000000 0.400000";; + flora) + color="0.400000 1.000000 0.400000";; + ice) + color="0.400000 1.000000 1.000000";; + orchid) + color="0.400000 0.400000 1.000000";; + bubblegum) + color="1.000000 0.400000 1.000000";; + lead) + color="0.0980392 0.0980392 0.0980392";; + mercery) + color="0.901961 0.901961 0.901961";; + cantaloupe) + color="1.000000 0.800000 0.400000";; + honeydew) + color="0.800000 1.000000 0.400000";; + spindrift) + color="0.400000 1.000000 0.800000";; + sky) + color="0.400000 0.800000 1.000000";; + lavender) + color="0.800000 0.400000 1.000000";; + carnation) + color="1.000000 0.435294 0.811765";; + licorice) + color="0.000000 0.000000 0.000000";; + snow) + color="1.000000 1.000000 1.000000";; + *) + color="$1";; + esac + + defaults write NSGlobalDomain AppleHighlightColor -string "${color}" + defaults write com.apple.systempreferences AppleOtherHighlightColor -string "${color}" +} + +case "${subcommand}" in + help) + help + ;; + inputfocusring) + inputfocusring "$@" + ;; + darkmode) + darkmode "$@" + ;; + transparency) + transparency "$@" + ;; + antialiasthreshold) + antialiasthreshold "$@" + ;; + sidebariconsize) + sidebariconsize "$@" + ;; + maincolor) + maincolor "$@" + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab From 079b03691f92ed4cab3953732c8e34215e614a78 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 10:27:12 -0600 Subject: [PATCH 043/100] Add launchpad plugin --- Readme.md | 9 +++++++++ plugins/launchpad | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100755 plugins/launchpad diff --git a/Readme.md b/Readme.md index 1f80daf..12c9118 100644 --- a/Readme.md +++ b/Readme.md @@ -68,6 +68,7 @@ usage: m [OPTIONS] COMMAND [help] info itunes keyboard + launchpad locale lock ntp @@ -528,6 +529,14 @@ usage: m [OPTIONS] COMMAND [help] m keyboard keyrepeatdelay 1.2 # How long a key needs to be held before repeating ``` +#### Launchpad: +``` + usage: m launchpad [ prune | help ] + + Examples: + m launchpad prune # Remove all items from launchpad +``` + #### Locale: ``` usage: m locale [ onlywifi | help ] diff --git a/plugins/launchpad b/plugins/launchpad new file mode 100755 index 0000000..a6aca0c --- /dev/null +++ b/plugins/launchpad @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + +help(){ + cat<<__EOF__ + usage: m launchpad [ prune | help ] + + Examples: + m launchpad prune # Remove all items from launchpad +__EOF__ +} + +prune(){ + find "/Users/$(whoami)/Library/Application Support/Dock" -name "*-*.db" -maxdepth 1 -delete +} + +case "${subcommand}" in + help) + help + ;; + prune) + prune + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab From 112c8a05c0ebf53dc2c36c2c3531795690701c4f Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 10:43:48 -0600 Subject: [PATCH 044/100] Add location plugin --- Readme.md | 10 +++++++++ plugins/location | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100755 plugins/location diff --git a/Readme.md b/Readme.md index 12c9118..b199d69 100644 --- a/Readme.md +++ b/Readme.md @@ -70,6 +70,7 @@ usage: m [OPTIONS] COMMAND [help] keyboard launchpad locale + location lock ntp printer @@ -546,6 +547,15 @@ usage: m [OPTIONS] COMMAND [help] m locale unit [ metric | english ] # Specify the measurement unit ``` +#### Location: +``` + usage: m location [ prune | help ] + + Examples: + m location enable # Enable the location service + m location diable # Disable the location service +``` + #### Lock: ``` usage: m lock [ help ] diff --git a/plugins/location b/plugins/location new file mode 100755 index 0000000..6d7db2a --- /dev/null +++ b/plugins/location @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + +help(){ + cat<<__EOF__ + usage: m location [ prune | help ] + + Examples: + m location enable # Enable the location service + m location diable # Disable the location service +__EOF__ +} + +_mcli_enable_location_service(){ + local loaded="$(_mcli_convert_yes_no_to_load_unload "$1")" + + value="$(_mcli_defaults_yes_no_to_inverted_boolean "com.apple.MCX" \ + "DisableLocationServices" \ + "$1")" + + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.locationd" \ + "LocationServicesEnabled" \ + "$1")" + + sudo sh -c "launchctl ${loaded} -w /System/Library/LaunchDaemons/com.apple.locationd.plist 2> /dev/null" + + echo "${command} ${subcommand}: ${value}" +} + +enable(){ + _mcli_enable_location_service "true" +} + +disable(){ + _mcli_enable_location_service "false" +} + +case "${subcommand}" in + help) + help + ;; + enable) + enable + ;; + disable) + disable + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab From 7aa77d75458d9d54f5de60879749b74b63efc439 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 10:55:21 -0600 Subject: [PATCH 045/100] Syntax changes --- plugins/user | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/plugins/user b/plugins/user index 7d9f516..0f18f46 100755 --- a/plugins/user +++ b/plugins/user @@ -1,21 +1,25 @@ #!/usr/bin/env bash +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift help(){ cat<<__EOF__ usage: m user [ list | ls | info | create | delete | help ] Examples: - m user ls # list users - m user info demouser # display user information + m user ls # list users + m user info demouser # display user information - m user create # create a user, it will ask you the below information - Username: - Full name: - Shell [/bin/bash]: - Password: + m user create # create a user, it will ask you the below information + Username: + Full name: + Shell [/bin/bash]: + Password: - m user delete demouser # delete user + m user delete demouser # delete user __EOF__ } @@ -47,11 +51,6 @@ groups_user_belongs(){ } user_create(){ - - #SECONDARY_GROUPS="" # for a non-admin user - #SECONDARY_GROUPS="admin _lpadmin _appserveradm _appserverusr" # for an admin user - - LAST_ID=$(dscl . -list /Users UniqueID | awk '{print $2}' | sort -n | tail -1) LAST_ID=$(expr $LAST_ID + 1) @@ -110,15 +109,12 @@ case $1 in user_ls ;; info) - shift user_info $@ ;; create) - shift user_create ;; delete) - shift user_delete $@ ;; *) From e991c236af1fd20c3113eb0ae7930a5fbca72b69 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 10:55:57 -0600 Subject: [PATCH 046/100] Add autologin to user --- Readme.md | 17 +++++++++-------- plugins/user | 13 +++++++++++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Readme.md b/Readme.md index b199d69..2ec9f0d 100644 --- a/Readme.md +++ b/Readme.md @@ -805,16 +805,17 @@ usage: m [OPTIONS] COMMAND [help] usage: m user [ list | ls | info | create | delete | help ] Examples: - m user ls # list users - m user info demouser # display user information + m user ls # list users + m user info demouser # display user information - m user create # create a user, it will ask you the below information - Username: - Full name: - Shell [/bin/bash]: - Password: + m user create # create a user, it will ask you the below information + Username: + Full name: + Shell [/bin/bash]: + Password: - m user delete demouser # delete user + m user delete demouser # delete user + m user autologin [ disable | username ] # who to autologin as or whether to disable autologin ``` #### Volume: diff --git a/plugins/user b/plugins/user index 0f18f46..764f876 100755 --- a/plugins/user +++ b/plugins/user @@ -20,6 +20,7 @@ help(){ Password: m user delete demouser # delete user + m user autologin [ disable | username ] # who to autologin as or whether to disable autologin __EOF__ } @@ -99,7 +100,16 @@ user_delete(){ fi } +autologin(){ + local username="$(if [[ "$1" != "disable" ]]; then echo "$1"; fi)" + if [ -z "${username}" ]; then + sudo defaults delete /Library/Preferences/com.apple.loginwindow autoLoginUser 2> /dev/null + sudo rm -f /etc/kcpassword + else + sudo defaults write /Library/Preferences/com.apple.loginwindow autoLoginUser -string "$username" + fi +} case $1 in help) @@ -117,6 +127,9 @@ case $1 in delete) user_delete $@ ;; + autologin) + autologin $@ + ;; *) help ;; From 5056f381f301f4e01eaec07d7315650be383a540 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 11:08:38 -0600 Subject: [PATCH 047/100] Add fastuserswitching and guest to user --- plugins/user | 51 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/plugins/user b/plugins/user index 764f876..238c580 100755 --- a/plugins/user +++ b/plugins/user @@ -1,5 +1,10 @@ #!/usr/bin/env bash +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare login_pref_path="/Library/Preferences/com.apple.loginwindow" + declare command="$(basename "$0")" declare subcommand="$1" @@ -10,17 +15,19 @@ help(){ usage: m user [ list | ls | info | create | delete | help ] Examples: - m user ls # list users - m user info demouser # display user information - - m user create # create a user, it will ask you the below information - Username: - Full name: - Shell [/bin/bash]: - Password: - - m user delete demouser # delete user - m user autologin [ disable | username ] # who to autologin as or whether to disable autologin + m user ls # list users + m user info demouser # display user information + + m user create # create a user, it will ask you the below information + Username: + Full name: + Shell [/bin/bash]: + Password: + + m user delete demouser # delete user + m user autologin [ disable | username ] # who to autologin as or whether to disable autologin + m user fastswitching [ YES | NO ] # whether to enable fast user switching + m user guest [ YES | NO ] # whether to enable the guest user __EOF__ } @@ -111,6 +118,22 @@ autologin(){ fi } +fastswitching(){ + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "MultipleSessionEnabled" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +guest(){ + value="$(_mcli_defaults_yes_no_to_integer "${login_pref_path}" \ + "GuestEnabled" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + case $1 in help) help @@ -130,6 +153,12 @@ case $1 in autologin) autologin $@ ;; + fastswitching) + fastswitching $@ + ;; + guest) + guest $@ + ;; *) help ;; From 7cba97ea5bd7a3a96806819d2b58145efe6ad07d Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 11:12:09 -0600 Subject: [PATCH 048/100] Change to using the login_pref_path variable to remove duplication --- plugins/user | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/user b/plugins/user index 238c580..e415775 100755 --- a/plugins/user +++ b/plugins/user @@ -111,10 +111,10 @@ autologin(){ local username="$(if [[ "$1" != "disable" ]]; then echo "$1"; fi)" if [ -z "${username}" ]; then - sudo defaults delete /Library/Preferences/com.apple.loginwindow autoLoginUser 2> /dev/null + sudo defaults delete "${login_pref_path}" autoLoginUser 2> /dev/null sudo rm -f /etc/kcpassword else - sudo defaults write /Library/Preferences/com.apple.loginwindow autoLoginUser -string "$username" + sudo defaults write "${login_pref_path}" autoLoginUser -string "$username" fi } From 28e2265433c5324e02fc41e5c1a1a7d310a5b91e Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 11:18:51 -0600 Subject: [PATCH 049/100] Add loginattemptsbeforehint to user --- Readme.md | 23 +++++++++++++---------- plugins/user | 40 ++++++++++++++++++++++++++-------------- 2 files changed, 39 insertions(+), 24 deletions(-) diff --git a/Readme.md b/Readme.md index 2ec9f0d..9260915 100644 --- a/Readme.md +++ b/Readme.md @@ -802,20 +802,23 @@ usage: m [OPTIONS] COMMAND [help] #### User ``` - usage: m user [ list | ls | info | create | delete | help ] + usage: m user [ list | ls | info | create | delete | autologin | fastswitching | guest | loginattemptsbeforehint | help ] Examples: - m user ls # list users - m user info demouser # display user information + m user ls # list users + m user info demouser # display user information - m user create # create a user, it will ask you the below information - Username: - Full name: - Shell [/bin/bash]: - Password: + m user create # create a user, it will ask you the below information + Username: + Full name: + Shell [/bin/bash]: + Password: - m user delete demouser # delete user - m user autologin [ disable | username ] # who to autologin as or whether to disable autologin + m user delete demouser # delete user + m user autologin [ disable | username ] # who to autologin as or whether to disable autologin + m user fastswitching [ YES | NO ] # whether to enable fast user switching + m user guest [ YES | NO ] # whether to enable the guest user + m user loginattemptsbeforehint x # the number of failed attempts before hint is shown ``` #### Volume: diff --git a/plugins/user b/plugins/user index e415775..d65bb2b 100755 --- a/plugins/user +++ b/plugins/user @@ -12,22 +12,23 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m user [ list | ls | info | create | delete | help ] + usage: m user [ list | ls | info | create | delete | autologin | fastswitching | guest | loginattemptsbeforehint | help ] Examples: - m user ls # list users - m user info demouser # display user information - - m user create # create a user, it will ask you the below information - Username: - Full name: - Shell [/bin/bash]: - Password: - - m user delete demouser # delete user - m user autologin [ disable | username ] # who to autologin as or whether to disable autologin - m user fastswitching [ YES | NO ] # whether to enable fast user switching - m user guest [ YES | NO ] # whether to enable the guest user + m user ls # list users + m user info demouser # display user information + + m user create # create a user, it will ask you the below information + Username: + Full name: + Shell [/bin/bash]: + Password: + + m user delete demouser # delete user + m user autologin [ disable | username ] # who to autologin as or whether to disable autologin + m user fastswitching [ YES | NO ] # whether to enable fast user switching + m user guest [ YES | NO ] # whether to enable the guest user + m user loginattemptsbeforehint x # the number of failed attempts before hint is shown __EOF__ } @@ -134,6 +135,14 @@ guest(){ echo "${command} ${subcommand}: ${value}" } +loginattemptsbeforehint(){ + value="$(_mcli_defaults_number "${login_pref_path}" \ + "RetriesUntilHint" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + case $1 in help) help @@ -159,6 +168,9 @@ case $1 in guest) guest $@ ;; + loginattemptsbeforehint) + loginattemptsbeforehint $@ + ;; *) help ;; From d057ce63eb69b572fdc8deb770e499b4498a607f Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 11:22:08 -0600 Subject: [PATCH 050/100] Add showsecure to user --- plugins/user | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/plugins/user b/plugins/user index d65bb2b..2169f96 100755 --- a/plugins/user +++ b/plugins/user @@ -28,6 +28,7 @@ help(){ m user autologin [ disable | username ] # who to autologin as or whether to disable autologin m user fastswitching [ YES | NO ] # whether to enable fast user switching m user guest [ YES | NO ] # whether to enable the guest user + m user showsecure [ YES | NO ] # whether to show secure users on the login screen (such as root) m user loginattemptsbeforehint x # the number of failed attempts before hint is shown __EOF__ } @@ -130,7 +131,17 @@ fastswitching(){ guest(){ value="$(_mcli_defaults_yes_no_to_integer "${login_pref_path}" \ "GuestEnabled" \ - "$1")" + "$1" \ + "sudo")" + + echo "${command} ${subcommand}: ${value}" +} + +showsecure(){ + value="$(_mcli_defaults_yes_no_to_inverted_boolean "${login_pref_path}" \ + "Hide500Users" \ + "$1" \ + "sudo")" echo "${command} ${subcommand}: ${value}" } @@ -138,7 +149,8 @@ guest(){ loginattemptsbeforehint(){ value="$(_mcli_defaults_number "${login_pref_path}" \ "RetriesUntilHint" \ - "$1")" + "$1" \ + "sudo")" echo "${command} ${subcommand}: ${value}" } @@ -168,6 +180,9 @@ case $1 in guest) guest $@ ;; + showsecure) + showsecure $@ + ;; loginattemptsbeforehint) loginattemptsbeforehint $@ ;; From 8a8157bbbc53126303140bc213e2cc6839c8af76 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 11:24:54 -0600 Subject: [PATCH 051/100] Add loginpoweroptions to user --- Readme.md | 2 ++ plugins/user | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/Readme.md b/Readme.md index 9260915..2cf37de 100644 --- a/Readme.md +++ b/Readme.md @@ -818,6 +818,8 @@ usage: m [OPTIONS] COMMAND [help] m user autologin [ disable | username ] # who to autologin as or whether to disable autologin m user fastswitching [ YES | NO ] # whether to enable fast user switching m user guest [ YES | NO ] # whether to enable the guest user + m user showsecure [ YES | NO ] # whether to show secure users on the login screen (such as root) + m user loginpoweroptions [ YES | NO ] # whether to show power options during login m user loginattemptsbeforehint x # the number of failed attempts before hint is shown ``` diff --git a/plugins/user b/plugins/user index 2169f96..97d67a0 100755 --- a/plugins/user +++ b/plugins/user @@ -29,6 +29,7 @@ help(){ m user fastswitching [ YES | NO ] # whether to enable fast user switching m user guest [ YES | NO ] # whether to enable the guest user m user showsecure [ YES | NO ] # whether to show secure users on the login screen (such as root) + m user loginpoweroptions [ YES | NO ] # whether to show power options during login m user loginattemptsbeforehint x # the number of failed attempts before hint is shown __EOF__ } @@ -146,6 +147,15 @@ showsecure(){ echo "${command} ${subcommand}: ${value}" } +loginpoweroptions(){ + value="$(_mcli_defaults_yes_no_to_inverted_boolean "${login_pref_path}" \ + "PowerOffDisabled" \ + "$1" \ + "sudo")" + + echo "${command} ${subcommand}: ${value}" +} + loginattemptsbeforehint(){ value="$(_mcli_defaults_number "${login_pref_path}" \ "RetriesUntilHint" \ @@ -183,6 +193,9 @@ case $1 in showsecure) showsecure $@ ;; + loginpoweroptions) + loginpoweroptions $@ + ;; loginattemptsbeforehint) loginattemptsbeforehint $@ ;; From 3f7a9f4814f5b724000d48f088928756c1565bd0 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 11:29:28 -0600 Subject: [PATCH 052/100] Add warn to trash --- Readme.md | 7 ++++--- plugins/trash | 20 +++++++++++++++++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Readme.md b/Readme.md index 2cf37de..e248f5e 100644 --- a/Readme.md +++ b/Readme.md @@ -783,11 +783,12 @@ usage: m [OPTIONS] COMMAND [help] #### Trash: ``` - usage: m trash [ status | clean | help ] + usage: m trash [ status | clean | warn | help ] Examples: - m trash status # get trash info - m trash clean # clean trash + m trash status # get trash info + m trash clean # clean trash + m trash warn [ YES | NO ] # warn when emptying trash ``` #### Update diff --git a/plugins/trash b/plugins/trash index 9078723..830bbaf 100755 --- a/plugins/trash +++ b/plugins/trash @@ -3,11 +3,12 @@ help(){ cat<<__EOF__ - usage: m trash [ status | clean | help ] + usage: m trash [ status | clean | warn | help ] Examples: - m trash status # get trash info - m trash clean # clean trash + m trash status # get trash info + m trash clean # clean trash + m trash warn [ YES | NO ] # warn when emptying trash __EOF__ } @@ -18,6 +19,16 @@ clean_trash(){ echo "Done!" } +warn() { + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.finder" \ + "WarnOnEmptyTrash" \ + "$1")" + + [ -n "$1" ] && killall Finder + + echo "${command} ${subcommand}: ${value}" +} + case $1 in help) help @@ -25,6 +36,9 @@ case $1 in clean) clean_trash ;; + warn) + warn + ;; status) du -ch $HOME/.Trash/* 2>/dev/null | tail -n 1 | awk '{print "Size: ", $1}' find $HOME/.Trash/* 2>/dev/null | wc -l | awk '{print "Number of files:", $1}' From 091f58e302400aa26e5e5fecd79cbd73fc9a285e Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 11:40:53 -0600 Subject: [PATCH 053/100] Change hostname to add a few more places where it needs to change This was pretty close but was missing a couple places --- plugins/hostname | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/plugins/hostname b/plugins/hostname index 763963e..5e01320 100755 --- a/plugins/hostname +++ b/plugins/hostname @@ -19,16 +19,23 @@ show_hostname(){ scutil --get HostName | awk '{print "HostName: ", $1}' scutil --get LocalHostName | awk '{print "LocalHostName: ", $1}' defaults read /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName | awk '{print "NetBIOSName: " $1}' - } set_hostname(){ - echo "Changing hostname to: $1" - sudo scutil --set ComputerName "$1" && \ - sudo scutil --set HostName "$1" && \ - sudo scutil --set LocalHostName "$1" && \ - sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "$1" + local hostname="$1" + + echo "Changing hostname to: ${hostname}" + + sudo sh -c "hostname '${hostname}'" + sudo sh -c "scutil --set ComputerName '${hostname}'" + sudo sh -c "scutil --set HostName '${hostname}'" + sudo sh -c "scutil --set LocalHostName '${hostname}'" + sudo sh -c "/usr/sbin/systemsetup -setcomputername '${hostname}' &> /dev/null" + sudo sh -c "/usr/sbin/systemsetup -setlocalsubnetname '${hostname}' &> /dev/null" + + sudo sh -c "defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string '${hostname}'" + sudo sh -c "defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server ServerDescription -string '${hostname}'" } From 9d0e6ce8dde0daa21a341fbf92812cb83adb4800 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 11:47:22 -0600 Subject: [PATCH 054/100] Add loginmessage to user --- Readme.md | 1 + plugins/user | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/Readme.md b/Readme.md index e248f5e..81882f8 100644 --- a/Readme.md +++ b/Readme.md @@ -822,6 +822,7 @@ usage: m [OPTIONS] COMMAND [help] m user showsecure [ YES | NO ] # whether to show secure users on the login screen (such as root) m user loginpoweroptions [ YES | NO ] # whether to show power options during login m user loginattemptsbeforehint x # the number of failed attempts before hint is shown + m user loginmessage "Your message" # the custom text to show on the login screen (enter nothing to remove message) ``` #### Volume: diff --git a/plugins/user b/plugins/user index 97d67a0..f232a4f 100755 --- a/plugins/user +++ b/plugins/user @@ -31,6 +31,7 @@ help(){ m user showsecure [ YES | NO ] # whether to show secure users on the login screen (such as root) m user loginpoweroptions [ YES | NO ] # whether to show power options during login m user loginattemptsbeforehint x # the number of failed attempts before hint is shown + m user loginmessage "Your message" # the custom text to show on the login screen (enter nothing to remove message) __EOF__ } @@ -165,6 +166,34 @@ loginattemptsbeforehint(){ echo "${command} ${subcommand}: ${value}" } +loginmessage(){ + local message="$1" + local kextdir="/System/Library/Extensions" + local eficachedir="/System/Library/Caches/com.apple.corestorage/EFILoginLocalizations" + + if [ -n "${message}" ]; then + sudo defaults write /Library/Preferences/com.apple.loginwindow LoginwindowText -string "$message" + sudo nvram good-samaritan-message="$message" + else + sudo sh -c "defaults delete /Library/Preferences/com.apple.loginwindow LoginwindowText 2> /dev/null" + sudo sh -c "nvram -d good-samaritan-message 2> /dev/null" + fi + + # The CoreStorage kext cache needs to be updated so the recovery message + # is displayed on the FDE pre-boot screen. + # + # The CS cache can be updated directly by touching $eficachedir, if it exists. + # Otherwise you will need to touch $kextdir to generate it. + + # Refresh system kext cache + sudo mkdir -p $kextdir 2> /dev/null + + # Refresh CoreStorage EFI Cache + sudo mkdir -p $eficachedir 2> /dev/null + + sudo touch $eficachedir +} + case $1 in help) help @@ -199,6 +228,9 @@ case $1 in loginattemptsbeforehint) loginattemptsbeforehint $@ ;; + loginmessage) + loginmessage $@ + ;; *) help ;; From 534569beb80a6f85ea1df2137bd353fe732f526a Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 11:53:22 -0600 Subject: [PATCH 055/100] Add restartonhang to power --- Readme.md | 1 + plugins/power | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/Readme.md b/Readme.md index 81882f8..19c81f5 100644 --- a/Readme.md +++ b/Readme.md @@ -657,6 +657,7 @@ usage: m [OPTIONS] COMMAND [help] m power powernap [ YES | NO ] [ YES | NO ] # Whether power nap is enabled m power powerbuttonsleeps [ YES | NO ] # Whether pressing the power button sleeps the system m power appnap [ YES | NO ] # Whether app nap is enabled + m power restartonhang [ YES | NO ] # Whether to restart on system hang ``` #### Restart: diff --git a/plugins/power b/plugins/power index 56a5119..d4da658 100755 --- a/plugins/power +++ b/plugins/power @@ -38,6 +38,7 @@ help(){ m power powernap [ YES | NO ] [ YES | NO ] # Whether power nap is enabled m power powerbuttonsleeps [ YES | NO ] # Whether pressing the power button sleeps the system m power appnap [ YES | NO ] # Whether app nap is enabled + m power restartonhang [ YES | NO ] # Whether to restart on system hang __EOF__ } @@ -80,6 +81,12 @@ appnapp(){ echo "${command} ${subcommand}: ${value}" } +restartonhang(){ + value="$(_mcli_convert_yes_no_to_on_off "$1")" + + sudo /usr/sbin/systemsetup -setrestartfreeze "${value}" +} + case "${subcommand}" in help) help @@ -105,6 +112,9 @@ case "${subcommand}" in appnapp) appnapp "$@" ;; + restartonhang) + restartonhang "$@" + ;; *) help ;; From 36d9bdc67567294e2fabc2a8d4ea6ae97f82f19c Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 12:06:13 -0600 Subject: [PATCH 056/100] Add automatic options to update --- Readme.md | 8 +++++--- plugins/update | 54 ++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/Readme.md b/Readme.md index 19c81f5..f3cd4ce 100644 --- a/Readme.md +++ b/Readme.md @@ -797,9 +797,11 @@ usage: m [OPTIONS] COMMAND [help] usage: m update [ list | install | help ] Examples: - m update list # list available updates - m update install all # install all the available updates - m update install iTunesX-12.4.1 RAWCameraUpdate6.20-6.20 # install specific updates + m update list # list available updates + m update install all # install all the available updates + m update install iTunesX-12.4.1 RAWCameraUpdate6.20-6.20 # install specific updates + m update automaticinstall [ YES | NO ] # whether automatic installs should be enabled + m update automaticdownload [ YES | NO ] # whether automatic downloads should be enabled ``` #### User diff --git a/plugins/update b/plugins/update index 7580a5b..4485535 100755 --- a/plugins/update +++ b/plugins/update @@ -1,19 +1,27 @@ #!/usr/bin/env bash +declare path_to_update_prefs="/Library/Preferences/com.apple.SoftwareUpdate" +declare path_to_appstore_prefs="/Library/Preferences/com.apple.commerce" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + help(){ cat<<__EOF__ usage: m update [ list | install | help ] - Examples: - m update list # list available updates - m update install all # install all the available updates - m update install iTunesX-12.4.1 RAWCameraUpdate6.20-6.20 # install specific updates + m update list # list available updates + m update install all # install all the available updates + m update install iTunesX-12.4.1 RAWCameraUpdate6.20-6.20 # install specific updates + m update automaticinstall [ YES | NO ] # whether automatic installs should be enabled + m update automaticdownload [ YES | NO ] # whether automatic downloads should be enabled __EOF__ } - install_updates(){ # at least one package [ -z "$1" ] && help && exit 1 @@ -27,6 +35,35 @@ install_updates(){ esac } +automaticinstall(){ + value="$(_mcli_defaults_yes_no_to_integer "${path_to_update_prefs}" \ + "ConfigDataInstall" \ + "$1" \ + "sudo")" + value="$(_mcli_defaults_yes_no_to_integer "${path_to_update_prefs}" \ + "CriticalUpdateInstall" \ + "$1" \ + "sudo")" + value="$(_mcli_defaults_yes_no_to_integer "${path_to_appstore_prefs}" \ + "AutoUpdate" \ + "$1" \ + "sudo")" + value="$(_mcli_defaults_yes_no_to_integer "${path_to_appstore_prefs}" \ + "AutoUpdateRestartRequired" \ + "$1" \ + "sudo")" + + echo "${command} ${subcommand}: ${value}" +} + +automaticdownload(){ + value="$(_mcli_defaults_yes_no_to_integer "${path_to_update_prefs}" \ + "AutomaticDownload" \ + "$1" \ + "sudo")" + + echo "${command} ${subcommand}: ${value}" +} case $1 in help) @@ -36,9 +73,14 @@ case $1 in sudo softwareupdate --list ;; install) - shift install_updates "$@" ;; + automaticinstall) + automaticinstall "$@" + ;; + automaticdownload) + automaticdownload "$@" + ;; *) help ;; From d6391fede19f8a2370479f263326cf523b4dd19f Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 12:20:23 -0600 Subject: [PATCH 057/100] Add interval to update --- Readme.md | 11 ++++++----- plugins/update | 38 +++++++++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/Readme.md b/Readme.md index f3cd4ce..a3ef7f9 100644 --- a/Readme.md +++ b/Readme.md @@ -797,11 +797,12 @@ usage: m [OPTIONS] COMMAND [help] usage: m update [ list | install | help ] Examples: - m update list # list available updates - m update install all # install all the available updates - m update install iTunesX-12.4.1 RAWCameraUpdate6.20-6.20 # install specific updates - m update automaticinstall [ YES | NO ] # whether automatic installs should be enabled - m update automaticdownload [ YES | NO ] # whether automatic downloads should be enabled + m update list # list available updates + m update install all # install all the available updates + m update install iTunesX-12.4.1 RAWCameraUpdate6.20-6.20 # install specific updates + m update automaticinstall [ YES | NO ] # whether automatic installs should be enabled + m update automaticdownload [ YES | NO ] # whether automatic downloads should be enabled + m update interval [ daily | weekly | biweekly | monthly | x ] # how often to check for updates ``` #### User diff --git a/plugins/update b/plugins/update index 4485535..72c747e 100755 --- a/plugins/update +++ b/plugins/update @@ -13,11 +13,12 @@ help(){ usage: m update [ list | install | help ] Examples: - m update list # list available updates - m update install all # install all the available updates - m update install iTunesX-12.4.1 RAWCameraUpdate6.20-6.20 # install specific updates - m update automaticinstall [ YES | NO ] # whether automatic installs should be enabled - m update automaticdownload [ YES | NO ] # whether automatic downloads should be enabled + m update list # list available updates + m update install all # install all the available updates + m update install iTunesX-12.4.1 RAWCameraUpdate6.20-6.20 # install specific updates + m update automaticinstall [ YES | NO ] # whether automatic installs should be enabled + m update automaticdownload [ YES | NO ] # whether automatic downloads should be enabled + m update interval [ daily | weekly | biweekly | monthly | x ] # how often to check for updates __EOF__ } @@ -65,6 +66,30 @@ automaticdownload(){ echo "${command} ${subcommand}: ${value}" } +interval(){ + local interval + + case "$1" in + daily) + interval="1";; + weekly) + interval="7";; + biweekly) + interval="14";; + monthly) + interval="30";; + *) + interval="$1";; + esac + + value="$(_mcli_defaults_yes_no_to_integer "${path_to_update_prefs}" \ + "ScheduleFrequency" \ + "${interval}" \ + "sudo")" + + echo "${command} ${subcommand}: ${value}" +} + case $1 in help) help @@ -81,6 +106,9 @@ case $1 in automaticdownload) automaticdownload "$@" ;; + interval) + interval "$@" + ;; *) help ;; From 26fd3a9ad9ac423c0972576bc555bd21dcecdb23 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 13:25:32 -0600 Subject: [PATCH 058/100] Add animations --- Readme.md | 16 +++++- plugins/animations | 124 +++++++++++++++++++++++++++++++++++++++++++++ plugins/appearance | 17 ++----- 3 files changed, 142 insertions(+), 15 deletions(-) create mode 100755 plugins/animations diff --git a/Readme.md b/Readme.md index a3ef7f9..07fe76a 100644 --- a/Readme.md +++ b/Readme.md @@ -149,12 +149,24 @@ usage: m [OPTIONS] COMMAND [help] # wi-fi on or off ``` +#### Animations: +``` + usage: m animations [ mail | inputs | finder | fullscreen | windows | quicklook | help ] + + Examples: + m animations mail [ YES | NO ] # Whether to use animations in mail + m animations inputs [ YES | NO ] # Whether to use animations interacting with inputs + m animations finder [ YES | NO ] # Whether to use animations in finder/desktop + m animations fullscreen [ YES | NO ] # Whether to use animations in fullscreen + m animations windows [ YES | NO ] [ x.x ] # Whether to use animations when opening, closing or resizing windows (with optional speed factor) + m animations quicklook [ YES | NO ] [ x.x ] # Whether to use animations when using quicklook +``` + #### Appearance: ``` - usage: m appearance [ inputfocusring | darkmode | transparency | antialiasthreshold | sidebariconsize | maincolor | highlightcolor | help ] + usage: m appearance [ darkmode | transparency | antialiasthreshold | sidebariconsize | maincolor | highlightcolor | help ] Examples: - m appearance inputfocusring [ YES | NO ] # Whether to show the focus ring when an input gains focus m appearance darkmode [ YES | NO ] # Whether to use dark versions of interface elements m appearance transparency [ YES | NO ] # Whether to allow the OS to make certain elements semi-transparent m appearance antialiasthreshold x # The threshold above which antialiasing is turned on diff --git a/plugins/animations b/plugins/animations new file mode 100755 index 0000000..874ff6b --- /dev/null +++ b/plugins/animations @@ -0,0 +1,124 @@ +#!/usr/bin/env bash + +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + +help(){ + cat<<__EOF__ + usage: m animations [ mail | help ] + + Examples: + m animations mail [ YES | NO ] # Whether to use animations in mail + m animations inputs [ YES | NO ] # Whether to use animations interacting with inputs + m animations finder [ YES | NO ] # Whether to use animations in finder/desktop + m animations fullscreen [ YES | NO ] # Whether to use animations in fullscreen + m animations windows [ YES | NO ] [ x.x ] # Whether to use animations when opening, closing or resizing windows (with optional speed factor) + m animations quicklook [ YES | NO ] [ x.x ] # Whether to 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="$(_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 "$@" + ;; + fullscreen) + fullscreen "$@" + ;; + windows) + windows "$@" + ;; + quicklook) + quicklook "$@" + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab diff --git a/plugins/appearance b/plugins/appearance index 3a880f3..65ea9bb 100755 --- a/plugins/appearance +++ b/plugins/appearance @@ -10,10 +10,9 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m appearance [ inputfocusring | darkmode | transparency | antialiasthreshold | sidebariconsize | maincolor | highlightcolor | help ] + usage: m appearance [ darkmode | transparency | antialiasthreshold | sidebariconsize | maincolor | highlightcolor | help ] Examples: - m appearance inputfocusring [ YES | NO ] # Whether to show the focus ring when an input gains focus m appearance darkmode [ YES | NO ] # Whether to use dark versions of interface elements m appearance transparency [ YES | NO ] # Whether to allow the OS to make certain elements semi-transparent m appearance antialiasthreshold x # The threshold above which antialiasing is turned on @@ -37,14 +36,6 @@ help(){ __EOF__ } -inputfocusring(){ - value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ - "NSUseAnimatedFocusRing" \ - "$1")" - - echo "${command} ${subcommand}: ${value}" -} - darkmode(){ local choice="$(_mcli_convert_yes_no_to_boolean "$1")" local mode="$(if [[ "${choice}" == "true" ]]; then echo "Dark"; else echo "Light"; fi)" @@ -221,9 +212,6 @@ case "${subcommand}" in help) help ;; - inputfocusring) - inputfocusring "$@" - ;; darkmode) darkmode "$@" ;; @@ -239,6 +227,9 @@ case "${subcommand}" in maincolor) maincolor "$@" ;; + highlightcolor) + highlightcolor "$@" + ;; *) help ;; From 6a3244de64e12508e7431488db27bf0f98e45a14 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 13:39:05 -0600 Subject: [PATCH 059/100] Add remotedsstore to finder --- Readme.md | 21 +++++++++++---------- plugins/finder | 35 ++++++++++++++++++++++++++--------- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/Readme.md b/Readme.md index 07fe76a..2dca70b 100644 --- a/Readme.md +++ b/Readme.md @@ -387,21 +387,22 @@ usage: m [OPTIONS] COMMAND [help] #### Finder: ``` - usage: m finder [ showhiddenfiles | showfileextensions | showdesktop | help ] + usage: m finder [ showhiddenfiles | showfileextensions | showdesktop | help ] Examples: - m finder showhiddenfiles # get the current status - m finder showhiddenfiles YES # show hidden files - m finder showhiddenfiles NO # no show hidden files + m finder showhiddenfiles # get the current status + m finder showhiddenfiles YES # show hidden files + m finder showhiddenfiles NO # don't show hidden files - m finder showextensions # get the current status - m finder showextensions YES # show all file extensions - m finder showextensions NO # don't show all file extensions + m finder showextensions # get the current status + m finder showextensions YES # show all file extensions + m finder showextensions NO # don't show all file extensions - m finder showdesktop # get the current desktop status - m finder showdesktop YES # enable the desktop - m finder showdesktop NO # disable the desktop + m finder showdesktop # get the current desktop status + m finder showdesktop YES # enable the desktop + m finder showdesktop NO # disable the desktop + m finder remotedsstore [ YES | NO ] # whether to allow dsstore files to be created on remote volumes ``` #### Firewall: diff --git a/plugins/finder b/plugins/finder index f12b9da..0785c35 100755 --- a/plugins/finder +++ b/plugins/finder @@ -15,17 +15,19 @@ help(){ usage: m finder [ showhiddenfiles | showfileextensions | showdesktop | help ] Examples: - m finder showhiddenfiles # get the current status - m finder showhiddenfiles YES # show hidden files - m finder showhiddenfiles NO # don't show hidden files + m finder showhiddenfiles # get the current status + m finder showhiddenfiles YES # show hidden files + m finder showhiddenfiles NO # don't show hidden files - m finder showextensions # get the current status - m finder showextensions YES # show all file extensions - m finder showextensions NO # don't show all file extensions + m finder showextensions # get the current status + m finder showextensions YES # show all file extensions + m finder showextensions NO # don't show all file extensions - m finder showdesktop # get the current desktop status - m finder showdesktop YES # enable the desktop - m finder showdesktop NO # disable the desktop + m finder showdesktop # get the current desktop status + m finder showdesktop YES # enable the desktop + m finder showdesktop NO # disable the desktop + + m finder remotedsstore [ YES | NO ] # whether to allow dsstore files to be created on remote volumes __EOF__ } @@ -53,6 +55,18 @@ desktop(){ echo "${command} ${subcommand}: ${value}" } +remotedsstore(){ + local choice="$(_mcli_defaults_yes_no_to_boolean "$1")" + + if [[ "${choice}" == "true" ]]; then + defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true + defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true + else + defaults delete com.apple.desktopservices DSDontWriteNetworkStores + defaults delete com.apple.desktopservices DSDontWriteUSBStores + fi +} + case "${subcommand}" in help) help @@ -66,6 +80,9 @@ case "${subcommand}" in showdesktop) desktop "$@" ;; + remotedsstore) + remotedsstore "$@" + ;; *) help ;; From 74fb74d52a6964cfa2d614687f3cc49b8c30b291 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 14:15:32 -0600 Subject: [PATCH 060/100] Add defaultusername to network --- plugins/network | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/plugins/network b/plugins/network index 879f7e7..2e5c1dd 100755 --- a/plugins/network +++ b/plugins/network @@ -1,5 +1,9 @@ #!/usr/bin/env bash +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift help(){ cat<<__EOF__ @@ -12,6 +16,7 @@ help(){ m network location create XYZ # create a location m network location delete XYZ # delete a location m network location switch XYZ # switch location + m network defaultusername "your name" # the default username when connecting (don't specify a name to disable) __EOF__ } @@ -28,6 +33,18 @@ list_netservices(){ done } +defaultusername(){ + local username="$1" + + if [ -n "$1" ]; then + defaults write com.apple.NetworkAuthorization UseDefaultName -bool true + defaults write com.apple.NetworkAuthorization DefaultName "${username}" + else + defaults delete com.apple.NetworkAuthorization UseDefaultName + defaults delete com.apple.NetworkAuthorization DefaultName + fi +} + location(){ case $1 in @@ -53,9 +70,7 @@ location(){ esac } - - -case $1 in +case "${subcommand}" in help) help ;; @@ -63,9 +78,11 @@ case $1 in list_netservices ;; location) - shift location $@ ;; + defaultusername) + defaultusername $@ + ;; *) help ;; From 10cafe98c5aaa4da888ce9de678e86d047dfc870 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 14:39:39 -0600 Subject: [PATCH 061/100] Add quitwhenfinished to printer --- Readme.md | 13 +++++++------ plugins/printer | 34 +++++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/Readme.md b/Readme.md index 2dca70b..fc6bbbe 100644 --- a/Readme.md +++ b/Readme.md @@ -590,14 +590,15 @@ usage: m [OPTIONS] COMMAND [help] #### Printer: ``` - usage: m printer [ settings | name | queue | drivers | web | help ] + usage: m printer [ settings | name | queue | drivers | web | quitwhenfinished | help ] Examples: - m printer settings # Printer settings - m printer name # Display printer names on system - m printer queue # Display items in printer queue on system - m printer drivers # Display all printer drivers - m printer web # Enable and show web interface + m printer settings # Printer settings + m printer name # Display printer names on system + m printer queue # Display items in printer queue on system + m printer drivers # Display all printer drivers + m printer web # Enable and show web interface + m printer quitwhenfinished [ YES | NO ] # whether the print dialog should be closed when printing is finished ``` #### Mission Control: diff --git a/plugins/printer b/plugins/printer index 696b024..a94b5d0 100755 --- a/plugins/printer +++ b/plugins/printer @@ -1,21 +1,38 @@ #!/usr/bin/env bash +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + help(){ cat<<__EOF__ - usage: m printer [ settings | name | queue | drivers | web | help ] + usage: m printer [ settings | name | queue | drivers | web | quitwhenfinished | help ] Examples: - m printer settings # Printer settings - m printer name # Display printer names on system - m printer queue # Display items in printer queue on system - m printer drivers # Display all printer drivers - m printer web # Enable and show web interface + m printer settings # Printer settings + m printer name # Display printer names on system + m printer queue # Display items in printer queue on system + m printer drivers # Display all printer drivers + m printer web # Enable and show web interface + m printer quitwhenfinished [ YES | NO ] # whether the print dialog should be closed when printing is finished __EOF__ } -case $1 in +quitwhenfinished(){ + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.print.PrintingPrefs" \ + "Quit When Finished" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +case "${subcommand}" in help) help ;; @@ -34,6 +51,9 @@ case $1 in web) cupsctl WebInterface=yes && open http://localhost:631/printers ;; + quitwhenfinished) + quitwhenfinished "$@" + ;; *) help ;; From 5f969d394c6839d2daca913a80c999769ce53f56 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 14:52:17 -0600 Subject: [PATCH 062/100] Add wakeonethernet and guestaccess to network --- plugins/network | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/plugins/network b/plugins/network index 2e5c1dd..2e70c66 100755 --- a/plugins/network +++ b/plugins/network @@ -10,13 +10,15 @@ help(){ usage: m network [ ls | list | location | help ] Examples: - m network ls # list network interfaces - m network location # get current location - m network location ls # list locations - m network location create XYZ # create a location - m network location delete XYZ # delete a location - m network location switch XYZ # switch location - m network defaultusername "your name" # the default username when connecting (don't specify a name to disable) + m network ls # list network interfaces + m network location # get current location + m network location ls # list locations + m network location create XYZ # create a location + m network location delete XYZ # delete a location + m network location switch XYZ # switch location + m network defaultusername "your name" # the default username when connecting (don't specify a name to disable) + m network wakeonethernet [ YES | NO ] # whether to allow the computer to wake up if it receives a special network packet + m network guestaccess [ YES | NO ] # whether to allow the guest user to access shared folders __EOF__ } @@ -45,6 +47,23 @@ defaultusername(){ fi } +wakeonethernet(){ + choice="$(_mcli_convert_yes_no_to_integer "$1")" + + sudo pmset -a womp "${choice}" + sudo pmset -a ring "${choice}" +} + +guestaccess(){ + value="$(_mcli_defaults_yes_no_to_boolean "/Library/Preferences/com.apple.AppleFileServer" \ + "guestAccess" \ + "$1")" + value="$(_mcli_defaults_yes_no_to_boolean "/Library/Preferences/com.apple.smb.server" \ + "AllowGuestAccess" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} location(){ case $1 in @@ -83,6 +102,12 @@ case "${subcommand}" in defaultusername) defaultusername $@ ;; + wakeonethernet) + wakeonethernet $@ + ;; + guestaccess) + guestaccess $@ + ;; *) help ;; From 6fff6d14b4b6d64baa4337304f0239bf77c4f426 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 14:59:23 -0600 Subject: [PATCH 063/100] Alphabetize README --- Readme.md | 129 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 67 insertions(+), 62 deletions(-) diff --git a/Readme.md b/Readme.md index fc6bbbe..13a043a 100644 --- a/Readme.md +++ b/Readme.md @@ -47,11 +47,13 @@ usage: m [OPTIONS] COMMAND [help] help airdrop airport + animations appearance battery bluetooth dashboard datetime + debugmode dir disk diskimages @@ -59,10 +61,11 @@ usage: m [OPTIONS] COMMAND [help] display dns dock - finder filevault + finder firewall gatekeeper + group hostname hotcorners info @@ -72,13 +75,13 @@ usage: m [OPTIONS] COMMAND [help] locale location lock - ntp - printer missioncontrol network nosleep notification + ntp power + printer restart safeboot screensaver @@ -234,6 +237,24 @@ usage: m [OPTIONS] COMMAND [help] # be exposed for various applications ``` +#### Dir: +``` + usage: m dir [ tree | size | delete | help ] + + Examples: + m dir tree # tree view of folders in the current path + m dir tree /path # tree view of folders in a specific path + + m dir delete empty # delete empty folders recursively in the current path + m dir delete empty /path # delete empty folders recursively in a specific path + + m dir delete dsfiles # delete .DS_Store files recursively in the current path + m dir delete dsfiles /path # delete .DS_Store files recursively in a specific path + + m dir size # calculate current folder size + m dir size /path # calculate folder size in a specific path + +``` #### Disk: ``` @@ -274,6 +295,16 @@ usage: m [OPTIONS] COMMAND [help] m diskimages verification [ YES | NO ] # Whether to verify disk image integrity ``` +#### Disk Utility: +``` + usage: m diskutility [ advancedoptions | showhiddenpartitions | showunsupportednetworks | help ] + + Examples: + m diskutility advancedoptions [ YES | NO ] # Whether to enable advanced disk utility options + m diskutility showhiddenpartitions [ YES | NO ] # Whether to show hidden partitions + m diskutility showunsupportednetworks [ YES | NO ] # Whether to show unsupported networks +``` + #### Display: ``` usage: m display [ status | lightsensor | help ] @@ -346,35 +377,6 @@ usage: m [OPTIONS] COMMAND [help] m dock prune # Remove all items from dock ``` -#### Dir: -``` - usage: m dir [ tree | size | delete | help ] - - Examples: - m dir tree # tree view of folders in the current path - m dir tree /path # tree view of folders in a specific path - - m dir delete empty # delete empty folders recursively in the current path - m dir delete empty /path # delete empty folders recursively in a specific path - - m dir delete dsfiles # delete .DS_Store files recursively in the current path - m dir delete dsfiles /path # delete .DS_Store files recursively in a specific path - - m dir size # calculate current folder size - m dir size /path # calculate folder size in a specific path - -``` - -#### Disk Utility: -``` - usage: m diskutility [ advancedoptions | showhiddenpartitions | showunsupportednetworks | help ] - - Examples: - m diskutility advancedoptions [ YES | NO ] # Whether to enable advanced disk utility options - m diskutility showhiddenpartitions [ YES | NO ] # Whether to show hidden partitions - m diskutility showunsupportednetworks [ YES | NO ] # Whether to show unsupported networks -``` - #### File Vault: ``` usage: m filevault [ status | enable | disable | help ] @@ -577,30 +579,6 @@ usage: m [OPTIONS] COMMAND [help] m lock # lock session ``` -#### Ntp: -``` - usage: m ntp [ status | enable | disable | set | help ] - - Examples: - m ntp status # status of the network time service - m ntp enable # enable clock to use network time - m ntp disable # disable clock to use network time - m ntp set timehost1.net.sap.corp # set network time server -``` - -#### Printer: -``` - usage: m printer [ settings | name | queue | drivers | web | quitwhenfinished | help ] - - Examples: - m printer settings # Printer settings - m printer name # Display printer names on system - m printer queue # Display items in printer queue on system - m printer drivers # Display all printer drivers - m printer web # Enable and show web interface - m printer quitwhenfinished [ YES | NO ] # whether the print dialog should be closed when printing is finished -``` - #### Mission Control: ``` usage: m missioncontrol [ showcenter | help ] @@ -616,12 +594,15 @@ usage: m [OPTIONS] COMMAND [help] usage: m network [ ls | list | location | help ] Examples: - m network ls # list network interfaces - m network location # get current location - m network location ls # list locations - m network location create XYZ # create a location - m network location delete XYZ # delete a location - m network location switch XYZ # switch location + m network ls # list network interfaces + m network location # get current location + m network location ls # list locations + m network location create XYZ # create a location + m network location delete XYZ # delete a location + m network location switch XYZ # switch location + m network defaultusername "your name" # the default username when connecting (don't specify a name to disable) + m network wakeonethernet [ YES | NO ] # whether to allow the computer to wake up if it receives a special network packet + m network guestaccess [ YES | NO ] # whether to allow the guest user to access shared folders ``` #### Nosleep: @@ -647,6 +628,17 @@ usage: m [OPTIONS] COMMAND [help] ``` +#### Ntp: +``` + usage: m ntp [ status | enable | disable | set | help ] + + Examples: + m ntp status # status of the network time service + m ntp enable # enable clock to use network time + m ntp disable # disable clock to use network time + m ntp set timehost1.net.sap.corp # set network time server +``` + #### Power: ``` usage: m power [ @@ -674,6 +666,19 @@ usage: m [OPTIONS] COMMAND [help] m power restartonhang [ YES | NO ] # Whether to restart on system hang ``` +#### Printer: +``` + usage: m printer [ settings | name | queue | drivers | web | quitwhenfinished | help ] + + Examples: + m printer settings # Printer settings + m printer name # Display printer names on system + m printer queue # Display items in printer queue on system + m printer drivers # Display all printer drivers + m printer web # Enable and show web interface + m printer quitwhenfinished [ YES | NO ] # whether the print dialog should be closed when printing is finished +``` + #### Restart: ``` usage: m restart [ -f | --force | help ] From 79677185b39a22e8c34c323d149272cedae235e3 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 15:08:40 -0600 Subject: [PATCH 064/100] Add standbykey to filevault --- Readme.md | 9 +++++---- plugins/filevault | 18 ++++++++++++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Readme.md b/Readme.md index 13a043a..d5b133b 100644 --- a/Readme.md +++ b/Readme.md @@ -379,12 +379,13 @@ usage: m [OPTIONS] COMMAND [help] #### File Vault: ``` - usage: m filevault [ status | enable | disable | help ] + usage: m filevault [ status | enable | disable | standbykey | help ] Examples: - m filevault status # FileVault Status - m filevault enable # Enable FileVault - m filevault disable # Disable FileVault + m filevault status # FileVault Status + m filevault enable # Enable FileVault + m filevault disable # Disable FileVault + m filevault standbykey [ YES | NO ] # Whether to keep the filevault key in memory during sleep ``` #### Finder: diff --git a/plugins/filevault b/plugins/filevault index ff01332..34e707c 100755 --- a/plugins/filevault +++ b/plugins/filevault @@ -7,15 +7,22 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m filevault [ status | enable | disable | help ] + usage: m filevault [ status | enable | disable | standbykey | help ] Examples: - m filevault status # FileVault Status - m filevault enable # Enable FileVault - m filevault disable # Disable FileVault + m filevault status # FileVault Status + m filevault enable # Enable FileVault + m filevault disable # Disable FileVault + m filevault standbykey [ YES | NO ] # Whether to keep the filevault key in memory during sleep __EOF__ } +standbykey(){ + choice="$(_mcli_convert_yes_no_to_integer "$1")" + + sudo pmset -a destroyfvkeyonstandby "${choice}" +} + case "${subcommand}" in help) help @@ -29,6 +36,9 @@ case "${subcommand}" in disable) sudo fdesetup disable "$@" ;; + standbykey) + standbykey "$@" + ;; *) help ;; From 6e67119a74fe5dd2bf78fee8657aac1358554f57 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 16:36:00 -0600 Subject: [PATCH 065/100] Add sound plugin --- Readme.md | 15 ++++++ lib/defaults.sh | 12 +++++ plugins/sound | 133 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 160 insertions(+) create mode 100755 plugins/sound diff --git a/Readme.md b/Readme.md index d5b133b..220a9a2 100644 --- a/Readme.md +++ b/Readme.md @@ -89,6 +89,7 @@ usage: m [OPTIONS] COMMAND [help] service shutdown sleep + sound spotlight timemachine timezone @@ -762,6 +763,20 @@ usage: m [OPTIONS] COMMAND [help] m sleep # put the mac to sleep ``` +#### Sound: +``` + usage: m sound [ startupchime | volumefeedback | ui | speechrecognition | speechtotext | voiceover | powerchime | help ] + + Examples: + m sound startupchime [ YES | NO ] # whether the startup chime is used + m sound volumefeedback [ YES | NO ] # whether or not you hear feedback when the volume is changed + m sound ui [ YES | NO ] [ x.x ] # whether the UI bleeps and bloops are used + m sound speechrecognition [ YES | NO ] # whether speech recognition is enabled + m sound speechtotext [ YES | NO ] # whether speech-to-text is enabled + m sound voiceover [ YES | NO ] # whether VoiceOver is enabled + m sound powerchime [ YES | NO ] # whether the chime is used when power is connected/disconnected +``` + #### Spotlight: ``` usage: m spotlight [ shortcutkeys | help ] diff --git a/lib/defaults.sh b/lib/defaults.sh index 6d9b298..2fc575c 100644 --- a/lib/defaults.sh +++ b/lib/defaults.sh @@ -107,6 +107,18 @@ _mcli_defaults_string() { _mcli_read_string "${domain}" "${key}" } +_mcli_defaults_delete() { + local domain="$1" + local key="$2" + local sudo="$3" + + if [ -n "${sudo}" ]; then + ${sudo} sh -c "defaults delete '${domain}' '${key}' 2> /dev/null" + else + defaults delete "${domain}" "${key}" 2> /dev/null + fi +} + _mcli_defaults_yes_no_to_type() { local type="$1" local transformer="$2" diff --git a/plugins/sound b/plugins/sound new file mode 100755 index 0000000..191656a --- /dev/null +++ b/plugins/sound @@ -0,0 +1,133 @@ +#!/usr/bin/env bash + +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + +help(){ + cat<<__EOF__ + usage: m sound [ startupchime | volumefeedback | ui | speechrecognition | speechtotext | voiceover | powerchime | help ] + + Examples: + m sound startupchime [ YES | NO ] # whether the startup chime is used + m sound volumefeedback [ YES | NO ] # whether or not you hear feedback when the volume is changed + m sound ui [ YES | NO ] [ x.x ] # whether the UI bleeps and bloops are used + m sound speechrecognition [ YES | NO ] # whether speech recognition is enabled + m sound speechtotext [ YES | NO ] # whether speech-to-text is enabled + m sound voiceover [ YES | NO ] # whether VoiceOver is enabled + m sound powerchime [ YES | NO ] # whether the chime is used when power is connected/disconnected +__EOF__ +} + +startupchime(){ + local choice="$(_mcli_convert_yes_no_to_boolean "$1")" + + if [[ "${choice}" == "true" ]]; then + sudo nvram -d SystemAudioVolume + else + sudo nvram SystemAudioVolume=" " + fi +} + +volumefeedback(){ + value="$(_mcli_defaults_yes_no_to_integer "NSGlobalDomain" \ + "com.apple.sound.beep.feedback" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +ui(){ + value="$(_mcli_defaults_yes_no_to_integer "com.apple.systemsound" \ + "com.apple.sound.uiaudio.enabled" \ + "$1")" + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.finder" \ + "FinderSounds" \ + "$1")" + value="$(_mcli_defaults_number "com.apple.systemsound" \ + "com.apple.sound.beep.volume" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +speechrecognition(){ + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.speech.recognition.AppleSpeechRecognition.prefs" \ + "StartSpeakableItems" \ + "$1" \ + "sudo")" + + echo "${command} ${subcommand}: ${value}" +} + +speechtotext(){ + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.speech.synthesis.general.prefs" \ + "TalkingAlertsSpeakTextFlag" \ + "$1" \ + "sudo")" + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.speech.synthesis.general.prefs" \ + "SpokenNotificationAppActivationFlag" \ + "$1" \ + "sudo")" + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.speech.synthesis.general.prefs" \ + "SpokenUIUseSpeakingHotKeyFlag" \ + "$1" \ + "sudo")" + value="$(_mcli_defaults_delete "com.apple.speech.synthesis.general.prefs" \ + "TimeAnnouncementPrefs" \ + "sudo")" + + echo "${command} ${subcommand}: ${value}" +} + +voiceover(){ + local choice="$(_mcli_convert_yes_no_to_load_unload "$1")" + + sudo sh -c "launchctl ${choice} -w /System/Library/LaunchAgents/com.apple.VoiceOver.plist 2> /dev/null" + sudo sh -c "launchctl ${choice} -w /System/Library/LaunchAgents/com.apple.ScreenReaderUIServer.plist 2> /dev/null" + sudo sh -c "launchctl ${choice} -w /System/Library/LaunchAgents/com.apple.scrod.plist 2> /dev/null" +} + +powerchime(){ + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.PowerChime" \ + "ChimeOnAllHardware" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +case "${subcommand}" in + help) + help + ;; + startupchime) + startupchime "$@" + ;; + volumefeedback) + volumefeedback "$@" + ;; + ui) + ui "$@" + ;; + speechrecognition) + speechrecognition "$@" + ;; + speechtotext) + speechtotext "$@" + ;; + voiceover) + voiceover "$@" + ;; + powerchime) + powerchime "$@" + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab From 8bd82ba2c9363fbbe1edd5601ead56da0be3ab36 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 16:36:42 -0600 Subject: [PATCH 066/100] Add persistmemory to power --- Readme.md | 3 +++ plugins/power | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/Readme.md b/Readme.md index 220a9a2..3cb0054 100644 --- a/Readme.md +++ b/Readme.md @@ -651,6 +651,8 @@ usage: m [OPTIONS] COMMAND [help] powernap | powerbuttonsleeps | appnapp | + restartonhang | + persistmemory | help ] @@ -666,6 +668,7 @@ usage: m [OPTIONS] COMMAND [help] m power powerbuttonsleeps [ YES | NO ] # Whether pressing the power button sleeps the system m power appnap [ YES | NO ] # Whether app nap is enabled m power restartonhang [ YES | NO ] # Whether to restart on system hang + m power persistmemory [ YES | NO ] # Whether RAM contains working memory when sleeping ("NO" is more secure) ``` #### Printer: diff --git a/plugins/power b/plugins/power index d4da658..d11e5b9 100755 --- a/plugins/power +++ b/plugins/power @@ -24,6 +24,8 @@ help(){ powernap | powerbuttonsleeps | appnapp | + restartonhang | + persistmemory | help ] @@ -39,6 +41,7 @@ help(){ m power powerbuttonsleeps [ YES | NO ] # Whether pressing the power button sleeps the system m power appnap [ YES | NO ] # Whether app nap is enabled m power restartonhang [ YES | NO ] # Whether to restart on system hang + m power persistmemory [ YES | NO ] # Whether RAM contains working memory when sleeping ("NO" is more secure) __EOF__ } @@ -87,6 +90,19 @@ restartonhang(){ sudo /usr/sbin/systemsetup -setrestartfreeze "${value}" } +persistmemory(){ + local choice="$(_mcli_convert_yes_no_to_boolean "$1")" + local value + + if [[ "${choice}" == "true" ]]; then + value="3" + else + value="25" + fi + + sudo pmset -a hibernatemode "${value}" +} + case "${subcommand}" in help) help From c801b5ceaaa299d2ade2e6b9d5ddcbb8533c4202 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 16:56:35 -0600 Subject: [PATCH 067/100] Add dialogs plugin --- Readme.md | 9 +++++++++ plugins/dialogs | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100755 plugins/dialogs diff --git a/Readme.md b/Readme.md index 3cb0054..e9e2948 100644 --- a/Readme.md +++ b/Readme.md @@ -54,6 +54,7 @@ usage: m [OPTIONS] COMMAND [help] dashboard datetime debugmode + dialog dir disk diskimages @@ -238,6 +239,14 @@ usage: m [OPTIONS] COMMAND [help] # be exposed for various applications ``` +#### Dialog: +``` + usage: m dialogs [ autoexpand | help ] + + Examples: + m dialogs autoexpand [ YES | NO ] # Whether print, save and other dialogs auto-expand +``` + #### Dir: ``` usage: m dir [ tree | size | delete | help ] diff --git a/plugins/dialogs b/plugins/dialogs new file mode 100755 index 0000000..d2da233 --- /dev/null +++ b/plugins/dialogs @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + +help(){ + cat<<__EOF__ + usage: m dialogs [ autoexpand | help ] + + Examples: + m dialogs autoexpand [ YES | NO ] # Whether print, save and other dialogs auto-expand +__EOF__ +} + +autoexpand(){ + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "NSNavPanelExpandedStateForSaveMode" \ + "$1")" + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "NSNavPanelExpandedStateForSaveMode2" \ + "$1")" + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "PMPrintingExpandedStateForPrint" \ + "$1")" + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "PMPrintingExpandedStateForPrint2" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +case "${subcommand}" in + help) + help + ;; + autoexpand) + autoexpand "$@" + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab From 6f81baaa0bac3823ac4f504441d2f2dc55f423eb Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 17:25:00 -0600 Subject: [PATCH 068/100] Add dir show and hide --- Readme.md | 10 ++++++---- plugins/dir | 34 +++++++++++++++++++++++++++------- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/Readme.md b/Readme.md index e9e2948..af41fd4 100644 --- a/Readme.md +++ b/Readme.md @@ -252,8 +252,8 @@ usage: m [OPTIONS] COMMAND [help] usage: m dir [ tree | size | delete | help ] Examples: - m dir tree # tree view of folders in the current path - m dir tree /path # tree view of folders in a specific path + m dir tree # tree view of folders in the current path + m dir tree /path # tree view of folders in a specific path m dir delete empty # delete empty folders recursively in the current path m dir delete empty /path # delete empty folders recursively in a specific path @@ -261,9 +261,11 @@ usage: m [OPTIONS] COMMAND [help] m dir delete dsfiles # delete .DS_Store files recursively in the current path m dir delete dsfiles /path # delete .DS_Store files recursively in a specific path - m dir size # calculate current folder size - m dir size /path # calculate folder size in a specific path + m dir size # calculate current folder size + m dir size /path # calculate folder size in a specific path + m dir show /path # remove hidden flag from a directory + m dir hide /path # add hidden flag to a directory ``` #### Disk: diff --git a/plugins/dir b/plugins/dir index ba3be1c..07cae4b 100755 --- a/plugins/dir +++ b/plugins/dir @@ -4,13 +4,21 @@ # * include a function to delete older directories by days or mins # * include a function to delete newest directories by days or mins +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + help(){ cat<<__EOF__ usage: m dir [ tree | size | delete | help ] Examples: - m dir tree # tree view of folders in the current path - m dir tree /path # tree view of folders in a specific path + m dir tree # tree view of folders in the current path + m dir tree /path # tree view of folders in a specific path m dir delete empty # delete empty folders recursively in the current path m dir delete empty /path # delete empty folders recursively in a specific path @@ -18,8 +26,11 @@ help(){ m dir delete dsfiles # delete .DS_Store files recursively in the current path m dir delete dsfiles /path # delete .DS_Store files recursively in a specific path - m dir size # calculate current folder size - m dir size /path # calculate folder size in a specific path + m dir size # calculate current folder size + m dir size /path # calculate folder size in a specific path + + m dir show /path # remove hidden flag from a directory + m dir hide /path # add hidden flag to a directory __EOF__ @@ -83,24 +94,33 @@ delete(){ esac } +show(){ + chflags nohidden "$1" +} +hide(){ + chflags hidden "$1" +} case "$1" in help) help ;; tree) - shift tree_dirs "$@" ;; delete) - shift; delete "$@" ;; size) - shift folder_size "$@" ;; + show) + show "$@" + ;; + hide) + hide "$@" + ;; *) help ;; From f8f7fe8eb29970ac7bcd3cbcd8620f0c0e6ce4a2 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 19:03:06 -0600 Subject: [PATCH 069/100] Add tons of new finder capabilities --- lib/converters.sh | 24 +++++ plugins/finder | 233 +++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 246 insertions(+), 11 deletions(-) diff --git a/lib/converters.sh b/lib/converters.sh index 6b3b299..2fedd62 100644 --- a/lib/converters.sh +++ b/lib/converters.sh @@ -2,6 +2,9 @@ _mcli_convert_yes_no_to_boolean() { local choice="$1" case "${choice}" in + "") + echo "" + ;; 1|[yY][eE][sS]|[tT][rR][uU][eE]) echo "true" ;; @@ -18,6 +21,9 @@ _mcli_convert_yes_no_to_on_off() { local choice="$1" case "${choice}" in + "") + echo "" + ;; 1|[yY][eE][sS]|[tT][rR][uU][eE]) echo "on" ;; @@ -34,6 +40,9 @@ _mcli_convert_yes_no_to_enabled_disabled() { local choice="$1" case "${choice}" in + "") + echo "" + ;; 1|[yY][eE][sS]|[tT][rR][uU][eE]) echo "enabled" ;; @@ -60,6 +69,9 @@ _mcli_convert_yes_no_to_load_unload() { local choice="$1" case "${choice}" in + "") + echo "" + ;; 1|[yY][eE][sS]|[tT][rR][uU][eE]) echo "load" ;; @@ -76,6 +88,9 @@ _mcli_convert_yes_no_to_inverted_boolean() { local choice="$1" case "${choice}" in + "") + echo "" + ;; 1|[yY][eE][sS]|[tT][rR][uU][eE]) echo "false" ;; @@ -92,6 +107,9 @@ _mcli_convert_yes_no_to_yes_no() { local choice="$1" case "${choice}" in + "") + echo "" + ;; 1|[yY][eE][sS]|[tT][rR][uU][eE]) echo "YES" ;; @@ -108,6 +126,9 @@ _mcli_convert_yes_no_to_integer() { local choice="$1" case "${choice}" in + "") + echo "" + ;; 1|[yY][eE][sS]|[tT][rR][uU][eE]) echo "1" ;; @@ -124,6 +145,9 @@ _mcli_convert_number_to_number() { local choice="$1" case "${choice}" in + "") + echo "" + ;; [0-9][.][0-9]) echo "${choice}" ;; diff --git a/plugins/finder b/plugins/finder index 0785c35..d778608 100755 --- a/plugins/finder +++ b/plugins/finder @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# TODO: add more functionalities +declare path_to_plistbuddy="/usr/libexec/PlistBuddy" source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" @@ -15,19 +15,44 @@ help(){ usage: m finder [ showhiddenfiles | showfileextensions | showdesktop | help ] Examples: - m finder showhiddenfiles # get the current status - m finder showhiddenfiles YES # show hidden files - m finder showhiddenfiles NO # don't show hidden files + m finder showhiddenfiles # get the current status + m finder showhiddenfiles YES # show hidden files + m finder showhiddenfiles NO # don't show hidden files - m finder showextensions # get the current status - m finder showextensions YES # show all file extensions - m finder showextensions NO # don't show all file extensions + m finder showextensions # get the current status + m finder showextensions YES # show all file extensions + m finder showextensions NO # don't show all file extensions - m finder showdesktop # get the current desktop status - m finder showdesktop YES # enable the desktop - m finder showdesktop NO # disable the desktop + m finder showdesktop # get the current desktop status + m finder showdesktop YES # enable the desktop + m finder showdesktop NO # disable the desktop + + m finder statusbar [ YES | NO ] # whether to show the status bar + m finder posixtitlepath [ YES | NO ] # whether to show the full POSIX title in the window title + m finder remotedsstore [ YES | NO ] # whether to allow dsstore files to be created on remote volumes + m finder extensionchangewarning [ YES | NO ] # whether to show the warning when changing a file's extension + m finder quittable [ YES | NO ] # whether to finder is quittable + m finder clickthroughdestroysselection [ YES | NO ] # whether, when clicking through to a finder window, the current selection is destroyed + m finder stoppreviewswhenselectionchanges [ YES | NO ] # whether to stop previews when selection changes + m finder stoppreviewswhenscrolling [ YES | NO ] # whether to stop previews when scrolling + m finder infopanesexpanded [ YES | NO ] # whether the panes in the info panel are expanded + m finder showrecenttags [ YES | NO ] # whether to show recent tags in the sidebar + m finder springing [ YES | NO ] [ x.x ] # whether springing is enabled and how long it takes for an item to spring + m finder minimumplayablepreviewsize x # the minimum size on which a preview will have a play button + m finder datetype [ # whether to use relative or absolute dates when showing file dates + absolute | + relative + ] + m finder defaultlocation [ # the location that new finder windows will open to by default + computer | + volume | + desktop | + documents | + allmyfiles | + home | + /path + ] - m finder remotedsstore [ YES | NO ] # whether to allow dsstore files to be created on remote volumes __EOF__ } @@ -55,6 +80,22 @@ desktop(){ echo "${command} ${subcommand}: ${value}" } +statusbar(){ + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.finder" \ + "ShowStatusBar" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +posixtitlepath(){ + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.finder" \ + "_FXShowPosixPathInTitle" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + remotedsstore(){ local choice="$(_mcli_defaults_yes_no_to_boolean "$1")" @@ -67,6 +108,140 @@ remotedsstore(){ fi } +extensionchangewarning() { + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.finder" \ + "FXEnableExtensionChangeWarning" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +quittable() { + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.finder" \ + "QuitMenuItem" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +clickthroughdestroysselection(){ + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.finder" \ + "ClickThroughDestroysSelection" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +stoppreviewswhenselectionchanges(){ + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.finder" \ + "AutoStopWhenSelectionChanges" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +stoppreviewswhenscrolling(){ + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.finder" \ + "AutoStopWhenScrollingOffBounds" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +infopanesexpanded() { + local choice="$(_mcli_convert_yes_no_to_boolean "$1")" + + defaults write com.apple.finder FXInfoPanesExpanded -dict \ + General -boolean "${choice}" \ + OpenWith -boolean "${choice}" \ + Privileges -boolean "${choice}" +} + +showrecenttags() { + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.finder" \ + "ShowRecentTags" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +datetype() { + local mode; + local plist="/Users/$(whoami)/Library/Preferences/com.apple.finder.plist" + + case "$1" in + relative) + mode="true";; + absolute) + mode="false";; + *) + mode="$1";; + esac + + $path_to_plistbuddy -c "Delete :FK_StandardViewSettings:ListViewSettings:useRelativeDates" "${plist}" 2> /dev/null + $path_to_plistbuddy -c "Add :FK_StandardViewSettings:ListViewSettings:useRelativeDates bool ${mode}" "${plist}" + $path_to_plistbuddy -c "Delete :FK_StandardViewSettings:ExtendedListViewSettings:useRelativeDates" "${plist}" 2> /dev/null + $path_to_plistbuddy -c "Add :FK_StandardViewSettings:ExtendedListViewSettings:useRelativeDates bool ${mode}" "${plist}" + $path_to_plistbuddy -c "Delete :StandardViewSettings:ListViewSettings:useRelativeDates" "${plist}" 2> /dev/null + $path_to_plistbuddy -c "Add :StandardViewSettings:ListViewSettings:useRelativeDates bool ${mode}" "${plist}" + $path_to_plistbuddy -c "Delete :StandardViewSettings:ExtendedListViewSettings:useRelativeDates" "${plist}" 2> /dev/null + $path_to_plistbuddy -c "Add :StandardViewSettings:ExtendedListViewSettings:useRelativeDates bool ${mode}" "${plist}" + $path_to_plistbuddy -c "Delete :ComputerViewSettings:ListViewSettings:useRelativeDates" "${plist}" 2> /dev/null + $path_to_plistbuddy -c "Add :ComputerViewSettings:ListViewSettings:useRelativeDates bool ${mode}" "${plist}" + $path_to_plistbuddy -c "Delete :ComputerViewSettings:ExtendedListViewSettings:useRelativeDates" "${plist}" 2> /dev/null + $path_to_plistbuddy -c "Add :ComputerViewSettings:ExtendedListViewSettings:useRelativeDates bool ${mode}" "${plist}" +} + +springing(){ + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "com.apple.springing.enabled" \ + "$1")" + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ + "enable-spring-load-actions-on-all-items" \ + "$1")" + + _mcli_defaults_number "NSGlobalDomain" \ + "com.apple.springing.delay" \ + "$2" + + echo "${command} ${subcommand}: ${value}" +} + +minimumplayablepreviewsize(){ + value="$(_mcli_defaults_yes_no_to_integer "com.apple.finder" \ + "QLInlinePreviewMinimumSupportedSize" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +defaultlocation(){ + local mode; + + case "$1" in + computer) + mode="PfCm";; + volume) + mode="PfVo";; + desktop) + mode="PfDe";; + documents) + mode="PfDo";; + allmyfiles) + mode="PfAF";; + home) + mode="PfHm";; + *) + mode="PfLo";; + esac + + defaults write com.apple.finder NewWindowTarget "${mode}" + + if [[ "${mode}" == "PfLo" ]]; then + defaults write com.apple.finder NewWindowTargetPath "$1" + fi +} + case "${subcommand}" in help) help @@ -80,9 +255,45 @@ case "${subcommand}" in showdesktop) desktop "$@" ;; + statusbar) + statusbar "$@" + ;; + posixtitlepath) + posixtitlepath "$@" + ;; remotedsstore) remotedsstore "$@" ;; + extensionchangewarning) + extensionchangewarning "$@" + ;; + quittable) + quittable "$@" + ;; + clickthroughdestroysselection) + clickthroughdestroysselection "$@" + ;; + stoppreviewswhenselectionchanges) + stoppreviewswhenselectionchanges "$@" + ;; + stoppreviewswhenscrolling) + stoppreviewswhenscrolling "$@" + ;; + infopanesexpanded) + infopanesexpanded "$@" + ;; + showrecenttags) + showrecenttags "$@" + ;; + springing) + springing "$@" + ;; + minimumplayablepreviewsize) + minimumplayablepreviewsize "$@" + ;; + defaultlocation) + defaultlocation "$@" + ;; *) help ;; From 6b3a698fd973aebfc64edcbd161559594f80d06a Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 19:27:58 -0600 Subject: [PATCH 070/100] Add screencapture plugin --- Readme.md | 17 +++++++++ plugins/screencapture | 84 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100755 plugins/screencapture diff --git a/Readme.md b/Readme.md index af41fd4..ca28516 100644 --- a/Readme.md +++ b/Readme.md @@ -85,6 +85,7 @@ usage: m [OPTIONS] COMMAND [help] printer restart safeboot + screencapture screensaver scrolling service @@ -714,6 +715,22 @@ usage: m [OPTIONS] COMMAND [help] m safeboot disable # disable safeboot ``` +#### Screen Capture: +``` + usage: m screencapture [ help ] + + Examples: + m screencapture type [ # Specify the type of the screenshots + png | + jpg | + tiff | + pdf + ] + m screencapture location /path # The location the screenshots will be saved to + m screencapture filename "prefix" # The filename the screenshots will be saved under (suffixed by date) + m screencapture shadow [ YES | NO ] # Whether the screenshots will contain a drop shadow +``` + #### Screensaver: ``` usage: m screensaver [ status | askforpassword | passworddelay | help ] diff --git a/plugins/screencapture b/plugins/screencapture new file mode 100755 index 0000000..8f3146d --- /dev/null +++ b/plugins/screencapture @@ -0,0 +1,84 @@ +#!/usr/bin/env bash + +declare path_to_plistbuddy="/usr/libexec/PlistBuddy" + +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + +help(){ + cat<<__EOF__ + usage: m screencapture [ help ] + + Examples: + m screencapture type [ # Specify the type of the screenshots + png | + jpg | + tiff | + pdf + ] + m screencapture location /path # The location the screenshots will be saved to + m screencapture filename # The filename the screenshots will be saved under (suffixed by date) + m screencapture shadow [ YES | NO ] # Whether the screenshots will contain a drop shadow + +__EOF__ +} + +type(){ + value="$(_mcli_defaults_string "com.apple.screencapture" \ + "type" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +location(){ + value="$(_mcli_defaults_string "com.apple.screencapture" \ + "location" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +filename(){ + value="$(_mcli_defaults_string "com.apple.screencapture" \ + "name" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +shadow(){ + value="$(_mcli_defaults_string "com.apple.screencapture" \ + "disable-shadow" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +case "${subcommand}" in + help) + help + ;; + type) + type "$@" + ;; + location) + location "$@" + ;; + filename) + filename "$@" + ;; + shadow) + shadow "$@" + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab From c70cebdba308b39d5d72e5117ae6cb07d73e375b Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 20:16:29 -0600 Subject: [PATCH 071/100] Add system plugin --- Readme.md | 14 ++++++ plugins/system | 122 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100755 plugins/system diff --git a/Readme.md b/Readme.md index ca28516..d992e9e 100644 --- a/Readme.md +++ b/Readme.md @@ -93,6 +93,7 @@ usage: m [OPTIONS] COMMAND [help] sleep sound spotlight + system timemachine timezone tooltip @@ -816,6 +817,19 @@ usage: m [OPTIONS] COMMAND [help] m spotlight shortcutkeys [ YES | NO ] # Whether to enable the Cmd-Space shortcuts ``` +#### System: +``` + usage: m system [ quarantine | automaticapptermination | documentversioning | crashreporter | savetoicloudbydefault | savewindowsonquit | help ] + + Examples: + m system quarantine [ YES | NO ] # Whether to enable app quarantine + m system automaticapptermination [ YES | NO ] # Whether to enable automatic app termination + m system documentversioning [ YES | NO ] # Whether to enable document versioning + m system crashreporter [ YES | NO ] # Whether to enable the crash reporter + m system savetoicloudbydefault [ YES | NO ] # Whether to save to iCloud by default + m system savewindowsonquit [ YES | NO ] # Whether to save window state +``` + #### Time Machine: ``` usage: m timemachine [ enable | disable | help ] diff --git a/plugins/system b/plugins/system new file mode 100755 index 0000000..5fe8a80 --- /dev/null +++ b/plugins/system @@ -0,0 +1,122 @@ +#!/usr/bin/env bash + +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + +help(){ + cat<<__EOF__ + usage: m system [ quarantine | automaticapptermination | documentversioning | crashreporter | savetoicloudbydefault | savewindowsonquit | help ] + + Examples: + m system quarantine [ YES | NO ] # Whether to enable app quarantine + m system automaticapptermination [ YES | NO ] # Whether to enable automatic app termination + m system documentversioning [ YES | NO ] # Whether to enable document versioning + m system crashreporter [ YES | NO ] # Whether to enable the crash reporter + m system savetoicloudbydefault [ YES | NO ] # Whether to save to iCloud by default + m system savewindowsonquit [ YES | NO ] # Whether to save window state + +__EOF__ +} + +quarantine() { + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.LaunchServices" \ + "LSQuarantine" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +automaticapptermination() { + value="$(_mcli_defaults_yes_no_to_inverted_boolean "NSGlobalDomain" \ + "NSDisableAutomaticTermination" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +documentversioning(){ + local choice="$(_mcli_convert_yes_no_to_boolean "$1")" + + defaults write NSGlobalDomain ApplePersistence -bool "${choice}" + + if [[ "${choice}" == "true" ]]; then + sudo mkdir /.DocumentRevisions-V100 2> /dev/null + defaults delete NSGlobalDomain AutosavingDelay 2> /dev/null + else + sudo rm -rf /.DocumentRevisions-V1* + defaults write NSGlobalDomain AutosavingDelay -int 0 + fi +} + +crashreporter(){ + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.SubmitDiagInfo" \ + "AutoSubmit" \ + "$1")" + _mcli_defaults_string "com.apple.CrashReporter" \ + "DialogType" \ + "server" + + echo "${command} ${subcommand}: ${value}" +} + +savetoicloudbydefault(){ + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "NSDocumentSaveNewDocumentsToCloud" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +savewindowsonquit(){ + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "NSQuitAlwaysKeepsWindows" \ + "$1")" + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.systempreferences" \ + "NSQuitAlwaysKeepsWindows" \ + "$1")" + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.loginwindow" \ + "LoginwindowLaunchesRelaunchApps" \ + "$1")" + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.loginwindow" \ + "TALLogoutSavesState" \ + "$1")" + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.Preview" \ + "NSQuitAlwaysKeepsWindows" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +case "${subcommand}" in + help) + help + ;; + quarantine) + quarantine "$@" + ;; + automaticapptermination) + automaticapptermination "$@" + ;; + documentversioning) + documentversioning "$@" + ;; + crashreporter) + crashreporter "$@" + ;; + savetoicloudbydefault) + savetoicloudbydefault "$@" + ;; + savewindowsonquit) + savewindowsonquit "$@" + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab From 737eea540f66becaabd6306eb258883e699ec5d1 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 20:26:42 -0600 Subject: [PATCH 072/100] Add menubar plugin --- Readme.md | 9 +++++++++ plugins/menubar | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100755 plugins/menubar diff --git a/Readme.md b/Readme.md index d992e9e..1efaa35 100644 --- a/Readme.md +++ b/Readme.md @@ -594,6 +594,15 @@ usage: m [OPTIONS] COMMAND [help] m lock # lock session ``` +#### Menubar: +``` + usage: m menubar [ autohide | airplay | help ] + + Examples: + m menubar autohide [ YES | NO ] # Whether to autohide the menu bar + m menubar airplay [ YES | NO ] # Whether to show the airplay options in the menu bar +``` + #### Mission Control: ``` usage: m missioncontrol [ showcenter | help ] diff --git a/plugins/menubar b/plugins/menubar new file mode 100755 index 0000000..cf07861 --- /dev/null +++ b/plugins/menubar @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + +help(){ + cat<<__EOF__ + usage: m menubar [ autohide | airplay | help ] + + Examples: + m menubar autohide [ YES | NO ] # Whether to autohide the menu bar + m menubar airplay [ YES | NO ] # Whether to show the airplay options in the menu bar + +__EOF__ +} + +autohide() { + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "_HIHideMenuBar" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +airplay() { + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.airplay" \ + "showInMenuBarIfPresent" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +case "${subcommand}" in + help) + help + ;; + autohide) + autohide "$@" + ;; + airplay) + airplay "$@" + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab From e07d2f14460da02d79434221b7a0d41bca7495a1 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 20:53:22 -0600 Subject: [PATCH 073/100] Add fullscreen plugin --- Readme.md | 11 ++++++++ plugins/fullscreen | 68 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100755 plugins/fullscreen diff --git a/Readme.md b/Readme.md index 1efaa35..ea27fca 100644 --- a/Readme.md +++ b/Readme.md @@ -65,6 +65,7 @@ usage: m [OPTIONS] COMMAND [help] filevault finder firewall + fullscreen gatekeeper group hostname @@ -439,6 +440,16 @@ usage: m [OPTIONS] COMMAND [help] m firewall remove /path/to/file # Remove app from firewall ``` +#### Full Screen: +``` + usage: m fullscreen [ sortbymostrecentlyused | switchonactivation | separatedisplays | help ] + + Examples: + m fullscreen sortbymostrecentlyused [ YES | NO ] # Whether to the full screen apps reorder based on activity + m fullscreen switchonactivation [ YES | NO ] # Whether to switch to full screen app when activating the application (say by clicking in the dock) + m fullscreen separatedisplays [ YES | NO ] # Whether each display has its own set of full screen apps +``` + #### Gatekeeper: ``` usage: m gatekeeper [ status | list | ls | enable | disable | create | help ] diff --git a/plugins/fullscreen b/plugins/fullscreen new file mode 100755 index 0000000..96757ac --- /dev/null +++ b/plugins/fullscreen @@ -0,0 +1,68 @@ +#!/usr/bin/env bash + +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + +help(){ + cat<<__EOF__ + usage: m fullscreen [ sortbymostrecentlyused | switchonactivation | separatedisplays | help ] + + Examples: + m fullscreen sortbymostrecentlyused [ YES | NO ] # Whether to the full screen apps reorder based on activity + m fullscreen switchonactivation [ YES | NO ] # Whether to switch to full screen app when activating the application (say by clicking in the dock) + m fullscreen separatedisplays [ YES | NO ] # Whether each display has its own set of full screen apps + +__EOF__ +} + +sortbymostrecentlyused() { + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ + "mru-spaces" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +switchonactivation() { + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "AppleSpacesSwitchOnActivate" \ + "$1")" + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ + "workspaces-auto-swoosh" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +separatedisplays() { + value="$(_mcli_defaults_yes_no_to_inverted_boolean "com.apple.spaces" \ + "spans-displays" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +case "${subcommand}" in + help) + help + ;; + sortbymostrecentlyused) + sortbymostrecentlyused + ;; + switchonactivation) + switchonactivation + ;; + separatedisplays) + separatedisplays + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab From fb0857a2f7bd196796bf5cc23108e8f36b0aede2 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 20:53:50 -0600 Subject: [PATCH 074/100] Add windows plugin --- Readme.md | 9 +++++++++ plugins/windows | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100755 plugins/windows diff --git a/Readme.md b/Readme.md index ea27fca..42e3aea 100644 --- a/Readme.md +++ b/Readme.md @@ -105,6 +105,7 @@ usage: m [OPTIONS] COMMAND [help] vpn wallpaper wifi + windows ``` @@ -987,6 +988,14 @@ usage: m [OPTIONS] COMMAND [help] ``` +#### Windows: +``` + usage: m windows [ miniturizeondoubleclick | help ] + + Examples: + m windows miniturizeondoubleclick [ YES | NO ] # Whether to miniturize windows on a double click of the title bar +``` + ## Contributing 1. Fork it! diff --git a/plugins/windows b/plugins/windows new file mode 100755 index 0000000..bc784dd --- /dev/null +++ b/plugins/windows @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + +help(){ + cat<<__EOF__ + usage: m windows [ miniturizeondoubleclick | help ] + + Examples: + m windows miniturizeondoubleclick [ YES | NO ] # Whether to miniturize windows on a double click of the title bar + +__EOF__ +} + +miniturizeondoubleclick() { + value="$(_mcli_defaults_yes_no_to_integer "NSGlobalDomain" \ + "AppleMiniaturizeOnDoubleClick" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +case "${subcommand}" in + help) + help + ;; + miniturizeondoubleclick) + miniturizeondoubleclick "$@" + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab From 317dac6487b306452252e9e2b21cf70cc8130dcc Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 21:03:50 -0600 Subject: [PATCH 075/100] Add hidequicklookondeactivate to finder --- Readme.md | 51 +++++++++++++++++++++++++++++++++++++------------- plugins/finder | 12 ++++++++++++ 2 files changed, 50 insertions(+), 13 deletions(-) diff --git a/Readme.md b/Readme.md index 42e3aea..57e9de0 100644 --- a/Readme.md +++ b/Readme.md @@ -409,19 +409,44 @@ usage: m [OPTIONS] COMMAND [help] usage: m finder [ showhiddenfiles | showfileextensions | showdesktop | help ] Examples: - m finder showhiddenfiles # get the current status - m finder showhiddenfiles YES # show hidden files - m finder showhiddenfiles NO # don't show hidden files - - m finder showextensions # get the current status - m finder showextensions YES # show all file extensions - m finder showextensions NO # don't show all file extensions - - m finder showdesktop # get the current desktop status - m finder showdesktop YES # enable the desktop - m finder showdesktop NO # disable the desktop - - m finder remotedsstore [ YES | NO ] # whether to allow dsstore files to be created on remote volumes + m finder showhiddenfiles # get the current status + m finder showhiddenfiles YES # show hidden files + m finder showhiddenfiles NO # don't show hidden files + + m finder showextensions # get the current status + m finder showextensions YES # show all file extensions + m finder showextensions NO # don't show all file extensions + + m finder showdesktop # get the current desktop status + m finder showdesktop YES # enable the desktop + m finder showdesktop NO # disable the desktop + + m finder statusbar [ YES | NO ] # whether to show the status bar + m finder posixtitlepath [ YES | NO ] # whether to show the full POSIX title in the window title + m finder remotedsstore [ YES | NO ] # whether to allow dsstore files to be created on remote volumes + m finder extensionchangewarning [ YES | NO ] # whether to show the warning when changing a file's extension + m finder quittable [ YES | NO ] # whether to finder is quittable + m finder clickthroughdestroysselection [ YES | NO ] # whether, when clicking through to a finder window, the current selection is destroyed + m finder stoppreviewswhenselectionchanges [ YES | NO ] # whether to stop previews when selection changes + m finder stoppreviewswhenscrolling [ YES | NO ] # whether to stop previews when scrolling + m finder infopanesexpanded [ YES | NO ] # whether the panes in the info panel are expanded + m finder showrecenttags [ YES | NO ] # whether to show recent tags in the sidebar + m finder hidequicklookondeactivate [ YES | NO ] # whether quicklook is hidden if you switch to another app + m finder springing [ YES | NO ] [ x.x ] # whether springing is enabled and how long it takes for an item to spring + m finder minimumplayablepreviewsize x # the minimum size on which a preview will have a play button + m finder datetype [ # whether to use relative or absolute dates when showing file dates + absolute | + relative + ] + m finder defaultlocation [ # the location that new finder windows will open to by default + computer | + volume | + desktop | + documents | + allmyfiles | + home | + /path + ] ``` #### Firewall: diff --git a/plugins/finder b/plugins/finder index d778608..4c0f188 100755 --- a/plugins/finder +++ b/plugins/finder @@ -37,6 +37,7 @@ help(){ m finder stoppreviewswhenscrolling [ YES | NO ] # whether to stop previews when scrolling m finder infopanesexpanded [ YES | NO ] # whether the panes in the info panel are expanded m finder showrecenttags [ YES | NO ] # whether to show recent tags in the sidebar + m finder hidequicklookondeactivate [ YES | NO ] # whether quicklook is hidden if you switch to another app m finder springing [ YES | NO ] [ x.x ] # whether springing is enabled and how long it takes for an item to spring m finder minimumplayablepreviewsize x # the minimum size on which a preview will have a play button m finder datetype [ # whether to use relative or absolute dates when showing file dates @@ -165,6 +166,14 @@ showrecenttags() { echo "${command} ${subcommand}: ${value}" } +hidequicklookondeactivate() { + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.finder" \ + "QLHidePanelOnDeactivate" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + datetype() { local mode; local plist="/Users/$(whoami)/Library/Preferences/com.apple.finder.plist" @@ -285,6 +294,9 @@ case "${subcommand}" in showrecenttags) showrecenttags "$@" ;; + hidequicklookondeactivate) + hidequicklookondeactivate "$@" + ;; springing) springing "$@" ;; From dedcd827c0cdc685ebe9e1f5bed3db3eb9bb3812 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sat, 7 Jan 2017 21:23:26 -0600 Subject: [PATCH 076/100] Add remotesharing to disk --- Readme.md | 6 ++++-- plugins/disk | 39 +++++++++++++++++++++++++++++---------- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/Readme.md b/Readme.md index 57e9de0..b90bd87 100644 --- a/Readme.md +++ b/Readme.md @@ -272,9 +272,9 @@ usage: m [OPTIONS] COMMAND [help] m dir hide /path # add hidden flag to a directory ``` -#### Disk: +#### Disk: ``` - usage: m disk [ ls | list | info | fs | filesystems | ejectall | verify | repair | help ] + usage: m disk [ ls | list | info | fs | filesystems | ejectall | verify | repair | remotesharing | help ] Examples: m disk ls # list disks @@ -300,6 +300,8 @@ usage: m [OPTIONS] COMMAND [help] m disk reformat /Volumes/myvol # reformat a volume m disk rename CURRENTNAME NEWNAME # rename a volume + m disk remotesharing [ YES | NO ] # whether disks are allowed to be shared remotely + ``` #### Disk Images: diff --git a/plugins/disk b/plugins/disk index 5be36d5..d4827fd 100755 --- a/plugins/disk +++ b/plugins/disk @@ -1,8 +1,16 @@ #!/usr/bin/env bash +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + help(){ cat<<__EOF__ - usage: m disk [ ls | list | info | fs | filesystems | ejectall | verify | repair | help ] + usage: m disk [ ls | list | info | fs | filesystems | ejectall | verify | repair | remotesharing | help ] Examples: m disk ls # list disks @@ -28,6 +36,8 @@ help(){ m disk reformat /Volumes/myvol # reformat a volume m disk rename CURRENTNAME NEWNAME # rename a volume + m disk remotesharing [ YES | NO ] # whether disks are allowed to be shared remotely + __EOF__ } @@ -107,46 +117,55 @@ rename(){ } +remotesharing(){ + local loaded="$(_mcli_convert_yes_no_to_load_unload "$1")" + + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.NetworkBrowser" \ + "ODSSupported" \ + "$1")" + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.NetworkBrowser" \ + "EnableODiskBrowsing" \ + "$1")" + + sudo sh -c "launchctl $loaded -w /System/Library/LaunchDaemons/com.apple.ODSAgent.plist 2> /dev/null" + + echo "${command} ${subcommand}: ${value}" +} + case $1 in help) help ;; list|ls) - shift disk_ls "$@" ;; info) - shift disk_info "$@" ;; filesystems|fs) - shift list_filesystems ;; ejectall) - shift ejectall ;; verify) - shift verify "$@" ;; repair) - shift repair "$@" ;; format) - shift format "$@" ;; reformat) - shift reformat "$@" ;; rename) - shift rename "$@" ;; + remotesharing) + remotesharing "$@" + ;; *) help ;; From ed06b084d8cee413c345e4100f3a5c7664f0ec91 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sun, 8 Jan 2017 12:32:18 -0600 Subject: [PATCH 077/100] Update usage in docs to be more consistent Apparently from having many contributors the docs got a bit out of date (format-wise). Some (most) of the "examples" were actually usage. Examples should contain sample data. Usage should contain placeholders. Take the `service` plugin for example: This is usage: m service load This is an example: m service load com.apple.sessionlogoutd I didn't rewrite everything but I made some good progress. --- Readme.md | 530 ++++++++++++++--------------------------- plugins/airdrop | 6 +- plugins/airport | 30 +-- plugins/animations | 4 +- plugins/appearance | 9 +- plugins/bluetooth | 4 +- plugins/dashboard | 4 +- plugins/datetime | 4 +- plugins/debugmode | 5 +- plugins/dialogs | 4 +- plugins/dir | 4 +- plugins/disk | 36 ++- plugins/diskimages | 4 +- plugins/diskutility | 4 +- plugins/display | 7 +- plugins/dns | 4 +- plugins/dock | 75 ++---- plugins/filevault | 4 +- plugins/finder | 19 +- plugins/firewall | 4 +- plugins/fullscreen | 4 +- plugins/gatekeeper | 4 +- plugins/group | 4 +- plugins/hostname | 8 +- plugins/hotcorners | 26 +- plugins/info | 4 +- plugins/itunes | 6 +- plugins/keyboard | 33 +-- plugins/launchpad | 4 +- plugins/locale | 4 +- plugins/location | 4 +- plugins/menubar | 4 +- plugins/missioncontrol | 4 +- plugins/network | 4 +- plugins/nosleep | 12 +- plugins/notification | 11 +- plugins/ntp | 9 +- plugins/power | 21 +- plugins/printer | 5 +- plugins/restart | 8 +- plugins/safeboot | 4 +- plugins/screencapture | 4 +- plugins/screensaver | 15 +- plugins/scrolling | 4 +- plugins/service | 16 +- plugins/shutdown | 4 +- plugins/sleep | 4 +- plugins/sound | 4 +- plugins/spotlight | 4 +- plugins/system | 4 +- plugins/timemachine | 4 +- plugins/timezone | 9 +- plugins/tooltips | 7 +- plugins/trash | 4 +- plugins/update | 11 +- plugins/user | 4 +- plugins/vpn | 4 +- plugins/wallpaper | 5 +- plugins/wifi | 4 +- plugins/windows | 4 +- 60 files changed, 369 insertions(+), 690 deletions(-) diff --git a/Readme.md b/Readme.md index b90bd87..2634164 100644 --- a/Readme.md +++ b/Readme.md @@ -111,30 +111,23 @@ usage: m [OPTIONS] COMMAND [help] #### Airdrop: ``` - usage: m airdrop [ onlywifi | help ] + Usage: + m airdrop onlywifi [ YES | NO ] # Whether to allow all interfaces (or only wifi) to be airdropped to Examples: - m airdrop onlywifi YES # allow airdropping only via WIFI - m airdrop onlywifi NO # allow airdropping via any network interface + m airdrop onlywifi YES ``` #### Airport: ``` - usage: m airport [ - disconnectonlogout | - preferrednetworks | - nonpreferrednetworks | - rememberrecents | - secureadhocnetworks | - securechangenetworks | - securetogglepower | - help - ] - - Examples: + Usage: m airport disconnectonlogout [ YES | NO ] # whether to disconnect from wifi when logging out - m airport rememberrecents [ YES | NO ] # whether to remember recent networks - + m airport nonpreferrednetworks [ # how to join non-preferred networks if preferred + Prompt | # networks are unavailable + JoinOpen | + KeepLooking | + DoNothing + ] m airport preferrednetworks [ # what to do when preferred networks are available Automatic | Preferred | @@ -142,14 +135,7 @@ usage: m [OPTIONS] COMMAND [help] Recent | Strongest ] - - m airport nonpreferrednetworks [ # how to join non-preferred networks if preferred - Prompt | # networks are unavailable - JoinOpen | - KeepLooking | - DoNothing - ] - + m airport rememberrecents [ YES | NO ] # whether to remember recent networks m airport secureadhocnetworks [ YES | NO ] # whether a password is required to create a # computer-to-computer network m airport securechangenetworks [ YES | NO ] # whether a password is required to change @@ -160,9 +146,7 @@ usage: m [OPTIONS] COMMAND [help] #### Animations: ``` - usage: m animations [ mail | inputs | finder | fullscreen | windows | quicklook | help ] - - Examples: + Usage: m animations mail [ YES | NO ] # Whether to use animations in mail m animations inputs [ YES | NO ] # Whether to use animations interacting with inputs m animations finder [ YES | NO ] # Whether to use animations in finder/desktop @@ -173,15 +157,13 @@ usage: m [OPTIONS] COMMAND [help] #### Appearance: ``` - usage: m appearance [ darkmode | transparency | antialiasthreshold | sidebariconsize | maincolor | highlightcolor | help ] - - Examples: + Usage: m appearance darkmode [ YES | NO ] # Whether to use dark versions of interface elements m appearance transparency [ YES | NO ] # Whether to allow the OS to make certain elements semi-transparent m appearance antialiasthreshold x # The threshold above which antialiasing is turned on m appearance sidebariconsize [ small | medium | large ] # The size of the icons in various window sidebars m appearance maincolor [ blue | graphite ] # The color used for the majority of the interface elements - m appearance highlightcolor [ # The color used for the majority of the interface elements + m appearance highlightcolor [ # The color used for highlights graphite | cayenne | asparagus | clover | teal | midnight | plum | tin | nickel | mocha | fern | moss | @@ -196,6 +178,9 @@ usage: m [OPTIONS] COMMAND [help] sky | lavender | carnation | licorice | snow ] + + Examples: + m appearance antialiasthreshold 8 # Only a font size of 8pt or above will be anti-aliased ``` #### Battery: @@ -208,9 +193,7 @@ usage: m [OPTIONS] COMMAND [help] #### Bluetooth: ``` - usage: m bluetooth [ status | enable | disable | help ] - - Examples: + Usage: m bluetooth status # bluetooth status m bluetooth enable # turn on bluetooth m bluetooth disable # turn off bluetooth @@ -218,18 +201,14 @@ usage: m [OPTIONS] COMMAND [help] #### Dashboard: ``` - usage: m dashboard [ enable | disable | help ] - - Examples: + Usage: m dashboard enable # Enable the dashboard m dashboard disable # Disable the dashboard ``` #### Date and Time: ``` - usage: m datetime [ 24hourclock | usentpserver | ntpserver | international | menubarformat | help ] - - Examples: + Usage: m datetime 24hourclock [ YES | NO ] # Whether to show the time using a 24 hour clock m datetime usentpserver [ YES | NO ] # Whether the current date time can be set via NTP m datetime ntpserver hostname # The NTP server to use to set the time @@ -239,23 +218,20 @@ usage: m [OPTIONS] COMMAND [help] #### Debug Mode: ``` - usage: m debugmode [ enable | disable ] # whether extra debugging options should - # be exposed for various applications + Usage: + m debugmode enable # whether extra debugging options should be exposed for various applications + m debugmode disable ``` #### Dialog: ``` - usage: m dialogs [ autoexpand | help ] - - Examples: + Usage: m dialogs autoexpand [ YES | NO ] # Whether print, save and other dialogs auto-expand ``` #### Dir: ``` - usage: m dir [ tree | size | delete | help ] - - Examples: + Usage: m dir tree # tree view of folders in the current path m dir tree /path # tree view of folders in a specific path @@ -274,50 +250,44 @@ usage: m [OPTIONS] COMMAND [help] #### Disk: ``` - usage: m disk [ ls | list | info | fs | filesystems | ejectall | verify | repair | remotesharing | help ] - - Examples: - m disk ls # list disks - m disk list # list disks - m disk list /dev/disk0 # list a specific disk + Usage: + m disk ls # list disks + m disk list # list disks + m disk list /dev/disk0 # list a specific disk - m disk fs # list available filesystems for formatting - m disk filesystems # list available filesystems for formatting + m disk fs # list available filesystems for formatting + m disk filesystems # list available filesystems for formatting - m disk info /dev/disk0 # display information + m disk info /dev/disk0 # display information - m disk ejectall # eject all mountable volumes + m disk ejectall # eject all mountable volumes - m disk verify volume /Volume/MyVol # verify volume - m disk verify disk /dev/disk0 # verify disk + m disk verify volume /Volume/MyVol # verify volume + m disk verify disk /dev/disk0 # verify disk - m disk repair volume /Volume/MyVol # repair volume - m disk repair disk /dev/disk0 # repair disk + m disk repair volume /Volume/MyVol # repair volume + m disk repair disk /dev/disk0 # repair disk - m disk format MS-DOS MYNAME /dev/disk2 # format the entire disk with a windows format (MS-DOS) - m disk format volume MS-DOS MYNAME /Volumes/myvol # format the volume with a windows format (MS-DOS) + m disk format MS-DOS MYNAME /dev/disk2 # format the entire disk with a windows format (MS-DOS) + m disk format volume MS-DOS MYNAME /Volumes/myvol # format the volume with a windows format (MS-DOS) - m disk reformat /Volumes/myvol # reformat a volume - m disk rename CURRENTNAME NEWNAME # rename a volume + m disk reformat /Volumes/myvol # reformat a volume + m disk rename CURRENTNAME NEWNAME # rename a volume - m disk remotesharing [ YES | NO ] # whether disks are allowed to be shared remotely + m disk remotesharing [ YES | NO ] # whether disks are allowed to be shared remotely ``` #### Disk Images: ``` - usage: m diskimages [ automount | verification | help ] - - Examples: + Usage: m diskimages automount [ YES | NO ] # Whether to automount disk images m diskimages verification [ YES | NO ] # Whether to verify disk image integrity ``` #### Disk Utility: ``` - usage: m diskutility [ advancedoptions | showhiddenpartitions | showunsupportednetworks | help ] - - Examples: + Usage: m diskutility advancedoptions [ YES | NO ] # Whether to enable advanced disk utility options m diskutility showhiddenpartitions [ YES | NO ] # Whether to show hidden partitions m diskutility showunsupportednetworks [ YES | NO ] # Whether to show unsupported networks @@ -325,81 +295,51 @@ usage: m [OPTIONS] COMMAND [help] #### Display: ``` - usage: m display [ status | lightsensor | help ] - - Example: + Usage: m display status # status of displays - m display autobrightness [ YES | NO ] # whether to enable the ambient light sensor - # to automatically darken/brighten the screen + m display autobrightness [ YES | NO ] # whether to enable the ambient light sensor to automatically darken/brighten the screen ``` #### Dns: ``` - usage: m dns [ flush | help ] - - Examples: + Usage: m dns flush # flushes local DNS ``` #### Dock: ``` - usage: m dock [ - enable | - disable | - activeindicators | - bounceonappactivity | - bounceonapplaunch | - autohidedelay | - autohidespeed | - autohide | - fullscreendelay | - itunesnotifications | - magnification | - magnificationsize | - hiddenappdimming | - iconsize | - onlyshowrunning | - position | - addblankspace | - addrecentitems | - prune | - help - ] + Usage: + m dock enable # Shows the Dock + m dock disable # Causes the Dock to be hidden and never reappear + m dock activeindicators [ YES | NO ] # Whether to show the active indicators under the app icons + m dock autohide [ YES | NO ] # Whether to enable Dock's auto hide feature + m dock autohidedelay x.x # Changes how long the Dock takes to show up when auto-hide is enabled + m dock autohidespeed x.x # Changes how long the Dock takes to slide into/out of view after the delay has expired + m dock bounceonappactivity [ YES | NO ] # Whether to bounce an app's icon when it has activity + m dock bounceonapplaunch [ YES | NO ] # Whether to bounce an app's icon when it is launching + m dock fullscreendelay [ YES | NO ] # Whether to have a delay when showing the dock in full screen mode + m dock hiddenappdimming [ YES | NO ] # Whether to show apps that have been hidden as semi-transparent + m dock iconsize x # Set the size of the icons when the dock is at rest + m dock itunesnotifications [ YES | NO ] # Whether to show iTunes notifications in the dock + m dock magnification [ YES | NO ] # Whether to turn magnification on + m dock magnificationsize x # Set the max size of the icons as the cursor gets closer to them + m dock onlyshowrunning [ YES | NO ] # Only show the apps that are currently running. Apps cannot be pinned. + m dock position [ # Change Dock's position to the bottom of the screen + BOTTOM | + LEFT | + RIGHT + ] + m dock prune # Remove all items from dock - Examples: - m dock enable # Shows the Dock - m dock disable # Causes the Dock to be hidden and never reappear - m dock activeindicators YES # Show the active indicators under the app icons - m dock bounceonappactivity # Bounce an app's icon when it has activity - m dock bounceonapplaunch # Bounce an app's icon when it is launching - m dock autohidedelay x.x # Changes how long the Dock takes to show up when auto-hide is enabled - m dock autohidespeed x.x # Changes how long the Dock takes to slide into/out of view after the - # delay has expired - m dock autohide YES # Enable Dock's auto hide feature - m dock autohide NO # Disable Dock's auto hide feature - m dock fullscreendelay YES # Whether to have a delay when showing the dock in full screen mode - m dock itunesnotifications NO # Whether to show iTunes notifications in the dock - m dock magnification YES # Turn magnification on - m dock magnification NO # Turn magnification off - m dock magnificationsize x # Set the max size of the icons as the cursor gets closer to them - m dock hiddenappdimming YES # Show apps that have been hidden as semi-transparent - m dock iconsize x # Set the size of the icons when the dock is at rest - m dock onlyshowrunning YES # Only show the apps that are currently running. Apps cannot be pinned. - m dock position BOTTOM # Change Dock's position to the bottom of the screen - m dock position LEFT # Change Dock's position to the left of the screen - m dock position RIGHT # Change Dock's position to the right of the screen - m dock addblankspace # Add a blank space (separator) to the Dock - m dock addrecentitems # Add a stack containg your recent items to the Dock - # (You can change the stack's type by right clicking on it) - m dock prune # Remove all items from dock + m dock addblankspace # Add a blank space (separator) to the Dock + m dock addrecentitems # Add a stack containg your recent items to the Dock + # (You can change the stack's type by right clicking on it) ``` #### File Vault: ``` - usage: m filevault [ status | enable | disable | standbykey | help ] - - Examples: + Usage: m filevault status # FileVault Status m filevault enable # Enable FileVault m filevault disable # Disable FileVault @@ -408,21 +348,10 @@ usage: m [OPTIONS] COMMAND [help] #### Finder: ``` - usage: m finder [ showhiddenfiles | showfileextensions | showdesktop | help ] - - Examples: - m finder showhiddenfiles # get the current status - m finder showhiddenfiles YES # show hidden files - m finder showhiddenfiles NO # don't show hidden files - - m finder showextensions # get the current status - m finder showextensions YES # show all file extensions - m finder showextensions NO # don't show all file extensions - - m finder showdesktop # get the current desktop status - m finder showdesktop YES # enable the desktop - m finder showdesktop NO # disable the desktop - + Usage: + m finder showhiddenfiles [ YES | NO ] # whether to show hidden files + m finder showextensions [ YES | NO ] # whether to show all file extensions + m finder showdesktop [ YES | NO ] # whether to enable the desktop m finder statusbar [ YES | NO ] # whether to show the status bar m finder posixtitlepath [ YES | NO ] # whether to show the full POSIX title in the window title m finder remotedsstore [ YES | NO ] # whether to allow dsstore files to be created on remote volumes @@ -453,9 +382,7 @@ usage: m [OPTIONS] COMMAND [help] #### Firewall: ``` - usage: m firewall [ status | enable | disable | list | add | remove | help ] - - Examples: + Usage: m firewall status # Show status m firewall enable # Enable firewall m firewall disable # Disable firewall @@ -470,9 +397,7 @@ usage: m [OPTIONS] COMMAND [help] #### Full Screen: ``` - usage: m fullscreen [ sortbymostrecentlyused | switchonactivation | separatedisplays | help ] - - Examples: + Usage: m fullscreen sortbymostrecentlyused [ YES | NO ] # Whether to the full screen apps reorder based on activity m fullscreen switchonactivation [ YES | NO ] # Whether to switch to full screen app when activating the application (say by clicking in the dock) m fullscreen separatedisplays [ YES | NO ] # Whether each display has its own set of full screen apps @@ -480,9 +405,7 @@ usage: m [OPTIONS] COMMAND [help] #### Gatekeeper: ``` - usage: m gatekeeper [ status | list | ls | enable | disable | create | help ] - - Examples: + Usage: m gatekeeper status # gatekeeper status m gatekeeper list # list rules @@ -498,9 +421,7 @@ usage: m [OPTIONS] COMMAND [help] #### Group: ``` - usage: m group [ list | ls | info | adduser | removeuser | ismember | help ] - - Examples: + Usage: m group list # get list of groups m group info mygroup # display group information @@ -513,45 +434,37 @@ usage: m [OPTIONS] COMMAND [help] #### Hostname: ``` - usage: m hostname [ help ] - - Examples: + Usage: m hostname # get the current hostname information (computername, hostname, localhostname and netbiosname) - m hostname newhostname # set a new hostname (computername, hostname, localhostname, netbiosname) - - m hostname help # only shows this help + m hostname # set a new hostname (computername, hostname, localhostname, netbiosname) ``` #### Hot Corners: ``` - usage: m hotcorners set [ bottomleft | bottomright | topright | topleft ] - [ - donothing | - missioncontrol | - showapplicationwindows | - desktop | - startscreensaver | - disablescreensaver | - dashboard | - sleepdisplay | - launchpad | - notificationcenter - ] + Usage: + m hotcorners set [ bottomleft | bottomright | topright | topleft ] [ + donothing | + missioncontrol | + showapplicationwindows | + desktop | + startscreensaver | + disablescreensaver | + dashboard | + sleepdisplay | + launchpad | + notificationcenter + ] ``` #### Info: ``` - usage: m info [ help ] - - Examples: + Usage: m info # print macOS operating system version information ``` ### iTunes: ``` - usage: m itunes [ status | play | pause | next | prev | mute | unmute | vol up | vol down | vol # | stop | quit | autobackup | mediakeys | help ] - - Examples: + Usage: m itunes status # Show status m itunes play # Play track m itunes pause # Pause track @@ -570,83 +483,58 @@ usage: m [OPTIONS] COMMAND [help] #### Keyboard: ``` - usage: m keyboard [ - accentedpress | - spellchecking | - textsubstitution | - usefunctionkeys | - inputfieldaccess | - autodim | - autodimdelay | - keyrepeatrate | - keyrepeatdelay | - help - ] - - Examples: + Usage: m keyboard accentedpress [ YES | NO ] # Whether to enable press and hold to show accented characters m keyboard spellchecking [ YES | NO ] # Whether to enable spell check indication (red squiggly lines) m keyboard textsubstitution [ YES | NO ] # Whether to substitute quotes, dashes, spelling corrections, etc automatically m keyboard usefunctionkeys [ YES | NO ] # Whether to use F1 function keys or alternate function keys (brightness, etc) m keyboard inputfieldaccess [ # Specify which input fields can be tabbed through - BASIC | - ALL_EXCEPT_DROPDOWNS | - ALL + basic | + allexceptdropdowns | + all ] m keyboard autodim [ YES | NO ] # Whether to automatically dim the keyboard brightness when idle - m keyboard autodimdelay 2 # How long to wait before dimming the keyboard brightness - m keyboard keyrepeatrate 4 # How quickly a held key repeats - m keyboard keyrepeatdelay 1.2 # How long a key needs to be held before repeating + m keyboard autodimdelay x # How long to wait before dimming the keyboard brightness + m keyboard keyrepeatrate x # How quickly a held key repeats + m keyboard keyrepeatdelay x.x # How long a key needs to be held before repeating ``` #### Launchpad: ``` - usage: m launchpad [ prune | help ] - - Examples: + Usage: m launchpad prune # Remove all items from launchpad ``` #### Locale: ``` - usage: m locale [ onlywifi | help ] - - Examples: + Usage: m locale language # Specify the language to use (eg en_US) m locale unit [ metric | english ] # Specify the measurement unit ``` #### Location: ``` - usage: m location [ prune | help ] - - Examples: + Usage: m location enable # Enable the location service m location diable # Disable the location service ``` #### Lock: ``` - usage: m lock [ help ] - - Examples: + Usage: m lock # lock session ``` #### Menubar: ``` - usage: m menubar [ autohide | airplay | help ] - - Examples: + Usage: m menubar autohide [ YES | NO ] # Whether to autohide the menu bar m menubar airplay [ YES | NO ] # Whether to show the airplay options in the menu bar ``` #### Mission Control: ``` - usage: m missioncontrol [ showcenter | help ] - - Examples: + Usage: m missioncontrol dashboardvisible [ YES | NO ] # m missioncontrol groupwindowsbyapp [ YES | NO ] # m missioncontrol animationspeed x.x # @@ -654,9 +542,7 @@ usage: m [OPTIONS] COMMAND [help] #### Network: ``` - usage: m network [ ls | list | location | help ] - - Examples: + Usage: m network ls # list network interfaces m network location # get current location m network location ls # list locations @@ -670,57 +556,42 @@ usage: m [OPTIONS] COMMAND [help] #### Nosleep: ``` - usage: m nosleep [ until | help ] + Usage: + m nosleep until # no sleep until number of seconds elaspes + m nosleep until # no sleep until the script ends + m nosleep until pid # no sleep until the process id ends Examples: - m nosleep until 3600 # no sleep until 3600 seconds - m nosleep until my_script.sh # no sleep until the script ends - - m nosleep until pid 64377 # no sleep until the process id ends + m nosleep until 3600 + m nosleep until my_script.sh + m nosleep until pid 64377 ``` #### Notification: ``` - usage: m notification [ showcenter | help ] - - Examples: - m notification showcenter # get the current status - m notification showcenter YES # enable the notification center - m notification showcenter NO # disable the notification center - m notification bannertime x # disable the notification center - + Usage: + m notification showcenter [ YES | NO ] # whether to enable the notification center + m notification bannertime x # disable the notification center ``` #### Ntp: ``` - usage: m ntp [ status | enable | disable | set | help ] - - Examples: + Usage: m ntp status # status of the network time service m ntp enable # enable clock to use network time m ntp disable # disable clock to use network time - m ntp set timehost1.net.sap.corp # set network time server + m ntp set # set network time server + + Examples: + m ntp set timehost1.net.sap.corp ``` #### Power: ``` - usage: m power [ - disksleeptime | - displaysleeptime | - hibernationdelay | - sleepdelay | - powernap | - powerbuttonsleeps | - appnapp | - restartonhang | - persistmemory | - help - ] - - Every command that has two entries requires both the battery setting and the - plugged setting (in that order). + Usage: + Every command that has two entries requires both the battery setting and the + plugged setting (in that order). - Examples: m power disksleeptime x x # Time until disks sleep m power displaysleeptime x x # Time until displays sleep m power hibernationdelay x x # Time until system hibernates @@ -734,9 +605,7 @@ usage: m [OPTIONS] COMMAND [help] #### Printer: ``` - usage: m printer [ settings | name | queue | drivers | web | quitwhenfinished | help ] - - Examples: + Usage: m printer settings # Printer settings m printer name # Display printer names on system m printer queue # Display items in printer queue on system @@ -747,18 +616,14 @@ usage: m [OPTIONS] COMMAND [help] #### Restart: ``` - usage: m restart [ -f | --force | help ] - - Examples: - m restart # restart computer (needs confirmation) - m restart -f # restart computer (without confirmation) + Usage: + m restart # restart computer (needs confirmation) + m restart --force # restart computer (without confirmation) ``` #### Safeboot: ``` - usage: m safeboot [ status | enable | disable | help ] - - Examples: + Usage: m safeboot status # get the boot args m safeboot enable # enable safe boot m safeboot disable # disable safeboot @@ -766,9 +631,7 @@ usage: m [OPTIONS] COMMAND [help] #### Screen Capture: ``` - usage: m screencapture [ help ] - - Examples: + Usage: m screencapture type [ # Specify the type of the screenshots png | jpg | @@ -776,29 +639,22 @@ usage: m [OPTIONS] COMMAND [help] pdf ] m screencapture location /path # The location the screenshots will be saved to - m screencapture filename "prefix" # The filename the screenshots will be saved under (suffixed by date) + m screencapture filename # The filename the screenshots will be saved under (suffixed by date) m screencapture shadow [ YES | NO ] # Whether the screenshots will contain a drop shadow ``` #### Screensaver: ``` - usage: m screensaver [ status | askforpassword | passworddelay | help ] - - Examples: - m screensaver # launch screensaver - - m screensaver status # get the current status - m screensaver askforpassword # get password requirement to unlock - m screensaver askforpassword YES # enable password requirement to unlock - m screensaver askforpassword NO # disable password requirement to unlock - m screensaver passworddelay x # the length of time before screensaver requires password + Usage: + m screensaver # launch screensaver + m screensaver status # get the current status + m screensaver askforpassword [ YES | NO ] # whether to enable password requirement to unlock + m screensaver passworddelay x # the length of time before screensaver requires password ``` #### Scrolling: ``` - usage: m scrolling [ direction | barvisibility | bounce | autoscrolldelay | momentum | help ] - - Examples: + Usage: m scrolling direction [ natural | inverted ] # What direction the content moves when swiping m scrolling barvisibility [ onlywhenscrolling | always ] # When to show scroll bars m scrolling bounce [ YES | NO ] # Whether to bounce at the end of scrolling @@ -808,46 +664,44 @@ usage: m [OPTIONS] COMMAND [help] #### Service: ``` - usage: m service [ --status-all | --list | --ls | start | stop | load | unload | help ] - - - Examples: + Usage: m service --status-all # list all services m service --list # list all services m service --ls # list all services - m service --ls com.apple.sessionlogoutd # show information about a specific service + m service --ls # show information about a specific service + + m service start # start a service + m service stop # stop a service - m service start com.apple.sessionlogoutd # start a service - m service stop com.apple.sessionlogoutd # stop a service + m service load # load a service + m service unload # unload a service - m service load com.apple.sessionlogoutd # load a service - m service unload com.apple.sessionlogoutd # unload a service + Examples: + m service --ls com.apple.sessionlogoutd + m service start com.apple.sessionlogoutd + m service stop com.apple.sessionlogoutd + m service load com.apple.sessionlogoutd + m service unload com.apple.sessionlogoutd ``` #### Shutdown: ``` - usage: m shutdown [-f | --force | help ] - - Examples: + Usage: m shutdown # shutdown computer (needs confirmation) m shutdown -f # shutdown computer (without confirmation) ``` #### Sleep: ``` - usage: m sleep [ help ] - - Examples: + Usage: m sleep # put the mac to sleep ``` #### Sound: ``` - usage: m sound [ startupchime | volumefeedback | ui | speechrecognition | speechtotext | voiceover | powerchime | help ] - - Examples: + Usage m sound startupchime [ YES | NO ] # whether the startup chime is used m sound volumefeedback [ YES | NO ] # whether or not you hear feedback when the volume is changed m sound ui [ YES | NO ] [ x.x ] # whether the UI bleeps and bloops are used @@ -859,17 +713,13 @@ usage: m [OPTIONS] COMMAND [help] #### Spotlight: ``` - usage: m spotlight [ shortcutkeys | help ] - - Examples: + Usage: m spotlight shortcutkeys [ YES | NO ] # Whether to enable the Cmd-Space shortcuts ``` #### System: ``` - usage: m system [ quarantine | automaticapptermination | documentversioning | crashreporter | savetoicloudbydefault | savewindowsonquit | help ] - - Examples: + Usage: m system quarantine [ YES | NO ] # Whether to enable app quarantine m system automaticapptermination [ YES | NO ] # Whether to enable automatic app termination m system documentversioning [ YES | NO ] # Whether to enable document versioning @@ -880,9 +730,7 @@ usage: m [OPTIONS] COMMAND [help] #### Time Machine: ``` - usage: m timemachine [ enable | disable | help ] - - Examples: + Usage: m timemachine usenewdisks [ YES | NO ] # Whether to use new disks for backups m timemachine useallnetworkvolumes [ YES | NO ] # Whether to use unsupported network volumes for backups m timemachine localbackups [ YES | NO ] # Whether to enable local backups @@ -891,30 +739,26 @@ usage: m [OPTIONS] COMMAND [help] #### Timezone: ``` - usage: m timezone [ list | ls | set | help ] + Usage: + m timezone # get current timezone + m timezone ls # list available timezones + m timezone set # set timezone Examples: - m timezone # get current timezone - m timezone ls # list available timezones - m timezone set Europe/Berlin # set timezone + m timezone set Europe/Berlin ``` #### Tooltips: ``` - usage: m tooltips [ delay | autowrap | fontsize | fontname | help ] - - Examples: + Usage: m tooltips delay x # Set the delay before the tooltip shows up m tooltips autowrap [ YES | NO ] # Whether tooltips should wrap - m tooltips fontsize x.x # The size of the font in the tooltip - m tooltips fontname # The name of the font in the tooltip + m tooltips fontsize x # The size of the font in the tooltip ``` #### Trash: ``` - usage: m trash [ status | clean | warn | help ] - - Examples: + Usage: m trash status # get trash info m trash clean # clean trash m trash warn [ YES | NO ] # warn when emptying trash @@ -922,22 +766,21 @@ usage: m [OPTIONS] COMMAND [help] #### Update ``` - usage: m update [ list | install | help ] - - Examples: + Usage: m update list # list available updates - m update install all # install all the available updates - m update install iTunesX-12.4.1 RAWCameraUpdate6.20-6.20 # install specific updates + m update install [ all | ] # which updates to install m update automaticinstall [ YES | NO ] # whether automatic installs should be enabled m update automaticdownload [ YES | NO ] # whether automatic downloads should be enabled m update interval [ daily | weekly | biweekly | monthly | x ] # how often to check for updates + + Examples: + m update install all # install all the available updates + m update install iTunesX-12.4.1 RAWCameraUpdate6.20-6.20 # install specific updates ``` #### User ``` - usage: m user [ list | ls | info | create | delete | autologin | fastswitching | guest | loginattemptsbeforehint | help ] - - Examples: + Usage: m user ls # list users m user info demouser # display user information @@ -975,16 +818,14 @@ usage: m [OPTIONS] COMMAND [help] #### VPN: ``` - usage: m vpn [ ls | list | start | stop | status | help ] - - Examples: + Usage: m vpn ls # list VPN connections m vpn start # interactive mode m vpn start VPN # start vpn connection named VPN m vpn start VPN USER # start a vpn connection with a given user m vpn start VPN USER PASS # start a vpn connection with a given user and password - m vpn start VPN USER PASS SECRET # start a vpn connection with a given user, password, and secret + m vpn start VPN USER PASS SECRET # start a vpn connection with a given user,password, and secret m vpn stop VPN # stop vpn connection named VPN m vpn status VPN # status vpn connection named VPN @@ -993,17 +834,16 @@ usage: m [OPTIONS] COMMAND [help] #### Wallpaper: ``` - usage: m wallpaper [ /path/to/file.jpg | help ] + Usage: + m wallpaper # set wallpaper Examples: - m wallpaper ./wallpapers/tree.jpg # set wallpaper + m wallpaper ./wallpapers/tree.jpg ``` #### Wifi: ``` - usage: m wifi [ scan | off | on | connect | help ] - - Examples: + Usage: m wifi status # wifi status m wifi scan # scan wifi m wifi showpassword [ESSID] # show wifi network password (default: current) @@ -1017,9 +857,7 @@ usage: m [OPTIONS] COMMAND [help] #### Windows: ``` - usage: m windows [ miniturizeondoubleclick | help ] - - Examples: + Usage: m windows miniturizeondoubleclick [ YES | NO ] # Whether to miniturize windows on a double click of the title bar ``` diff --git a/plugins/airdrop b/plugins/airdrop index 2d1ac7f..0aaacef 100755 --- a/plugins/airdrop +++ b/plugins/airdrop @@ -10,11 +10,11 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m airdrop [ onlywifi | help ] + Usage: + m airdrop onlywifi [ YES | NO ] # Whether to allow all interfaces (or only wifi) to be airdropped to Examples: - m airdrop onlywifi YES # allow airdropping only via WIFI - m airdrop onlywifi NO # allow airdropping via any network interface + m airdrop onlywifi YES __EOF__ } diff --git a/plugins/airport b/plugins/airport index 22cec47..d6861f1 100755 --- a/plugins/airport +++ b/plugins/airport @@ -11,21 +11,14 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m airport [ - disconnectonlogout | - preferrednetworks | - nonpreferrednetworks | - rememberrecents | - secureadhocnetworks | - securechangenetworks | - securetogglepower | - help - ] - - Examples: + Usage: m airport disconnectonlogout [ YES | NO ] # whether to disconnect from wifi when logging out - m airport rememberrecents [ YES | NO ] # whether to remember recent networks - + m airport nonpreferrednetworks [ # how to join non-preferred networks if preferred + Prompt | # networks are unavailable + JoinOpen | + KeepLooking | + DoNothing + ] m airport preferrednetworks [ # what to do when preferred networks are available Automatic | Preferred | @@ -33,14 +26,7 @@ help(){ Recent | Strongest ] - - m airport nonpreferrednetworks [ # how to join non-preferred networks if preferred - Prompt | # networks are unavailable - JoinOpen | - KeepLooking | - DoNothing - ] - + m airport rememberrecents [ YES | NO ] # whether to remember recent networks m airport secureadhocnetworks [ YES | NO ] # whether a password is required to create a # computer-to-computer network m airport securechangenetworks [ YES | NO ] # whether a password is required to change diff --git a/plugins/animations b/plugins/animations index 874ff6b..51ca078 100755 --- a/plugins/animations +++ b/plugins/animations @@ -10,9 +10,7 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m animations [ mail | help ] - - Examples: + Usage: m animations mail [ YES | NO ] # Whether to use animations in mail m animations inputs [ YES | NO ] # Whether to use animations interacting with inputs m animations finder [ YES | NO ] # Whether to use animations in finder/desktop diff --git a/plugins/appearance b/plugins/appearance index 65ea9bb..7dcb5a4 100755 --- a/plugins/appearance +++ b/plugins/appearance @@ -10,15 +10,13 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m appearance [ darkmode | transparency | antialiasthreshold | sidebariconsize | maincolor | highlightcolor | help ] - - Examples: + Usage: m appearance darkmode [ YES | NO ] # Whether to use dark versions of interface elements m appearance transparency [ YES | NO ] # Whether to allow the OS to make certain elements semi-transparent m appearance antialiasthreshold x # The threshold above which antialiasing is turned on m appearance sidebariconsize [ small | medium | large ] # The size of the icons in various window sidebars m appearance maincolor [ blue | graphite ] # The color used for the majority of the interface elements - m appearance highlightcolor [ # The color used for the majority of the interface elements + m appearance highlightcolor [ # The color used for highlights graphite | cayenne | asparagus | clover | teal | midnight | plum | tin | nickel | mocha | fern | moss | @@ -33,6 +31,9 @@ help(){ sky | lavender | carnation | licorice | snow ] + + Examples: + m appearance antialiasthreshold 8 # Only a font size of 8pt or above will be anti-aliased __EOF__ } diff --git a/plugins/bluetooth b/plugins/bluetooth index b614727..3928cf1 100755 --- a/plugins/bluetooth +++ b/plugins/bluetooth @@ -2,9 +2,7 @@ help(){ cat<<__EOF__ - usage: m bluetooth [ status | enable | disable | help ] - - Examples: + Usage: m bluetooth status # bluetooth status m bluetooth enable # turn on bluetooth m bluetooth disable # turn off bluetooth diff --git a/plugins/dashboard b/plugins/dashboard index ee73fd4..9220d22 100755 --- a/plugins/dashboard +++ b/plugins/dashboard @@ -20,9 +20,7 @@ _mcli_toggle_dashboard_keyboard_shortcuts(){ help(){ cat<<__EOF__ - usage: m dashboard [ enable | disable | help ] - - Examples: + Usage: m dashboard enable # Enable the dashboard m dashboard disable # Disable the dashboard __EOF__ diff --git a/plugins/datetime b/plugins/datetime index 2b0ab7d..3f3f6d5 100755 --- a/plugins/datetime +++ b/plugins/datetime @@ -10,9 +10,7 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m datetime [ 24hourclock | usentpserver | ntpserver | international | menubarformat | help ] - - Examples: + Usage: m datetime 24hourclock [ YES | NO ] # Whether to show the time using a 24 hour clock m datetime usentpserver [ YES | NO ] # Whether the current date time can be set via NTP m datetime ntpserver hostname # The NTP server to use to set the time diff --git a/plugins/debugmode b/plugins/debugmode index 1a68411..60cf0ea 100755 --- a/plugins/debugmode +++ b/plugins/debugmode @@ -2,8 +2,9 @@ help(){ cat<<__EOF__ - usage: m debugmode [ enable | disable ] # whether extra debugging options should - # be exposed for various applications + Usage: + m debugmode enable # whether extra debugging options should be exposed for various applications + m debugmode disable __EOF__ } diff --git a/plugins/dialogs b/plugins/dialogs index d2da233..759b3c7 100755 --- a/plugins/dialogs +++ b/plugins/dialogs @@ -7,9 +7,7 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m dialogs [ autoexpand | help ] - - Examples: + Usage: m dialogs autoexpand [ YES | NO ] # Whether print, save and other dialogs auto-expand __EOF__ } diff --git a/plugins/dir b/plugins/dir index 07cae4b..b3df9a1 100755 --- a/plugins/dir +++ b/plugins/dir @@ -14,9 +14,7 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m dir [ tree | size | delete | help ] - - Examples: + Usage: m dir tree # tree view of folders in the current path m dir tree /path # tree view of folders in a specific path diff --git a/plugins/disk b/plugins/disk index d4827fd..c186f10 100755 --- a/plugins/disk +++ b/plugins/disk @@ -10,33 +10,31 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m disk [ ls | list | info | fs | filesystems | ejectall | verify | repair | remotesharing | help ] + Usage: + m disk ls # list disks + m disk list # list disks + m disk list /dev/disk0 # list a specific disk - Examples: - m disk ls # list disks - m disk list # list disks - m disk list /dev/disk0 # list a specific disk + m disk fs # list available filesystems for formatting + m disk filesystems # list available filesystems for formatting - m disk fs # list available filesystems for formatting - m disk filesystems # list available filesystems for formatting + m disk info /dev/disk0 # display information - m disk info /dev/disk0 # display information + m disk ejectall # eject all mountable volumes - m disk ejectall # eject all mountable volumes + m disk verify volume /Volume/MyVol # verify volume + m disk verify disk /dev/disk0 # verify disk - m disk verify volume /Volume/MyVol # verify volume - m disk verify disk /dev/disk0 # verify disk + m disk repair volume /Volume/MyVol # repair volume + m disk repair disk /dev/disk0 # repair disk - m disk repair volume /Volume/MyVol # repair volume - m disk repair disk /dev/disk0 # repair disk + m disk format MS-DOS MYNAME /dev/disk2 # format the entire disk with a windows format (MS-DOS) + m disk format volume MS-DOS MYNAME /Volumes/myvol # format the volume with a windows format (MS-DOS) - m disk format MS-DOS MYNAME /dev/disk2 # format the entire disk with a windows format (MS-DOS) - m disk format volume MS-DOS MYNAME /Volumes/myvol # format the volume with a windows format (MS-DOS) + m disk reformat /Volumes/myvol # reformat a volume + m disk rename CURRENTNAME NEWNAME # rename a volume - m disk reformat /Volumes/myvol # reformat a volume - m disk rename CURRENTNAME NEWNAME # rename a volume - - m disk remotesharing [ YES | NO ] # whether disks are allowed to be shared remotely + m disk remotesharing [ YES | NO ] # whether disks are allowed to be shared remotely __EOF__ } diff --git a/plugins/diskimages b/plugins/diskimages index e583344..310328c 100755 --- a/plugins/diskimages +++ b/plugins/diskimages @@ -10,9 +10,7 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m diskimages [ automount | verification | help ] - - Examples: + Usage: m diskimages automount [ YES | NO ] # Whether to automount disk images m diskimages verification [ YES | NO ] # Whether to verify disk image integrity __EOF__ diff --git a/plugins/diskutility b/plugins/diskutility index ff440f5..5a7676b 100755 --- a/plugins/diskutility +++ b/plugins/diskutility @@ -10,9 +10,7 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m diskutility [ advancedoptions | showhiddenpartitions | showunsupportednetworks | help ] - - Examples: + Usage: m diskutility advancedoptions [ YES | NO ] # Whether to enable advanced disk utility options m diskutility showhiddenpartitions [ YES | NO ] # Whether to show hidden partitions m diskutility showunsupportednetworks [ YES | NO ] # Whether to show unsupported networks diff --git a/plugins/display b/plugins/display index 4eee0bc..41f0632 100755 --- a/plugins/display +++ b/plugins/display @@ -11,12 +11,9 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m display [ status | autobrightness | help ] - - Example: + Usage: m display status # status of displays - m display autobrightness [ YES | NO ] # whether to enable the ambient light sensor - # to automatically darken/brighten the screen + m display autobrightness [ YES | NO ] # whether to enable the ambient light sensor to automatically darken/brighten the screen __EOF__ } diff --git a/plugins/dns b/plugins/dns index 4c383c8..85b4f9c 100755 --- a/plugins/dns +++ b/plugins/dns @@ -2,9 +2,7 @@ help(){ cat<<__EOF__ - usage: m dns [ flush | help ] - - Examples: + Usage: m dns flush # flushes local DNS __EOF__ } diff --git a/plugins/dock b/plugins/dock index 3c3b22f..f86c88f 100755 --- a/plugins/dock +++ b/plugins/dock @@ -10,55 +10,32 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m dock [ - enable | - disable | - activeindicators | - bounceonappactivity | - bounceonapplaunch | - autohidedelay | - autohidespeed | - autohide | - fullscreendelay | - itunesnotifications | - magnification | - magnificationsize | - hiddenappdimming | - iconsize | - onlyshowrunning | - position | - addblankspace | - addrecentitems | - prune | - help - ] - - Examples: - m dock enable # Shows the Dock - m dock disable # Causes the Dock to be hidden and never reappear - m dock activeindicators YES # Show the active indicators under the app icons - m dock bounceonappactivity # Bounce an app's icon when it has activity - m dock bounceonapplaunch # Bounce an app's icon when it is launching - m dock autohidedelay x.x # Changes how long the Dock takes to show up when auto-hide is enabled - m dock autohidespeed x.x # Changes how long the Dock takes to slide into/out of view after the - # delay has expired - m dock autohide YES # Enable Dock's auto hide feature - m dock autohide NO # Disable Dock's auto hide feature - m dock fullscreendelay YES # Whether to have a delay when showing the dock in full screen mode - m dock itunesnotifications NO # Whether to show iTunes notifications in the dock - m dock magnification YES # Turn magnification on - m dock magnification NO # Turn magnification off - m dock magnificationsize x # Set the max size of the icons as the cursor gets closer to them - m dock hiddenappdimming YES # Show apps that have been hidden as semi-transparent - m dock iconsize x # Set the size of the icons when the dock is at rest - m dock onlyshowrunning YES # Only show the apps that are currently running. Apps cannot be pinned. - m dock position BOTTOM # Change Dock's position to the bottom of the screen - m dock position LEFT # Change Dock's position to the left of the screen - m dock position RIGHT # Change Dock's position to the right of the screen - m dock addblankspace # Add a blank space (separator) to the Dock - m dock addrecentitems # Add a stack containg your recent items to the Dock - # (You can change the stack's type by right clicking on it) - m dock prune # Remove all items from dock + Usage: + m dock enable # Shows the Dock + m dock disable # Causes the Dock to be hidden and never reappear + m dock activeindicators [ YES | NO ] # Whether to show the active indicators under the app icons + m dock autohide [ YES | NO ] # Whether to enable Dock's auto hide feature + m dock autohidedelay x.x # Changes how long the Dock takes to show up when auto-hide is enabled + m dock autohidespeed x.x # Changes how long the Dock takes to slide into/out of view after the delay has expired + m dock bounceonappactivity [ YES | NO ] # Whether to bounce an app's icon when it has activity + m dock bounceonapplaunch [ YES | NO ] # Whether to bounce an app's icon when it is launching + m dock fullscreendelay [ YES | NO ] # Whether to have a delay when showing the dock in full screen mode + m dock hiddenappdimming [ YES | NO ] # Whether to show apps that have been hidden as semi-transparent + m dock iconsize x # Set the size of the icons when the dock is at rest + m dock itunesnotifications [ YES | NO ] # Whether to show iTunes notifications in the dock + m dock magnification [ YES | NO ] # Whether to turn magnification on + m dock magnificationsize x # Set the max size of the icons as the cursor gets closer to them + m dock onlyshowrunning [ YES | NO ] # Only show the apps that are currently running. Apps cannot be pinned. + m dock position [ # Change Dock's position to the bottom of the screen + BOTTOM | + LEFT | + RIGHT + ] + m dock prune # Remove all items from dock + + m dock addblankspace # Add a blank space (separator) to the Dock + m dock addrecentitems # Add a stack containg your recent items to the Dock + # (You can change the stack's type by right clicking on it) __EOF__ } diff --git a/plugins/filevault b/plugins/filevault index 34e707c..083edcd 100755 --- a/plugins/filevault +++ b/plugins/filevault @@ -7,9 +7,7 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m filevault [ status | enable | disable | standbykey | help ] - - Examples: + Usage: m filevault status # FileVault Status m filevault enable # Enable FileVault m filevault disable # Disable FileVault diff --git a/plugins/finder b/plugins/finder index 4c0f188..381dc5b 100755 --- a/plugins/finder +++ b/plugins/finder @@ -12,21 +12,10 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m finder [ showhiddenfiles | showfileextensions | showdesktop | help ] - - Examples: - m finder showhiddenfiles # get the current status - m finder showhiddenfiles YES # show hidden files - m finder showhiddenfiles NO # don't show hidden files - - m finder showextensions # get the current status - m finder showextensions YES # show all file extensions - m finder showextensions NO # don't show all file extensions - - m finder showdesktop # get the current desktop status - m finder showdesktop YES # enable the desktop - m finder showdesktop NO # disable the desktop - + Usage: + m finder showhiddenfiles [ YES | NO ] # whether to show hidden files + m finder showextensions [ YES | NO ] # whether to show all file extensions + m finder showdesktop [ YES | NO ] # whether to enable the desktop m finder statusbar [ YES | NO ] # whether to show the status bar m finder posixtitlepath [ YES | NO ] # whether to show the full POSIX title in the window title m finder remotedsstore [ YES | NO ] # whether to allow dsstore files to be created on remote volumes diff --git a/plugins/firewall b/plugins/firewall index d0584aa..9ab5a5b 100755 --- a/plugins/firewall +++ b/plugins/firewall @@ -2,9 +2,7 @@ help(){ cat<<__EOF__ - usage: m firewall [ status | enable | disable | list | add | remove | help ] - - Examples: + Usage: m firewall status # Show status m firewall enable # Enable firewall m firewall disable # Disable firewall diff --git a/plugins/fullscreen b/plugins/fullscreen index 96757ac..47de949 100755 --- a/plugins/fullscreen +++ b/plugins/fullscreen @@ -10,9 +10,7 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m fullscreen [ sortbymostrecentlyused | switchonactivation | separatedisplays | help ] - - Examples: + Usage: m fullscreen sortbymostrecentlyused [ YES | NO ] # Whether to the full screen apps reorder based on activity m fullscreen switchonactivation [ YES | NO ] # Whether to switch to full screen app when activating the application (say by clicking in the dock) m fullscreen separatedisplays [ YES | NO ] # Whether each display has its own set of full screen apps diff --git a/plugins/gatekeeper b/plugins/gatekeeper index 6eee0c1..2d5ab9c 100755 --- a/plugins/gatekeeper +++ b/plugins/gatekeeper @@ -4,9 +4,7 @@ help(){ cat<<__EOF__ - usage: m gatekeeper [ status | list | ls | enable | disable | create | help ] - - Examples: + Usage: m gatekeeper status # gatekeeper status m gatekeeper list # list rules diff --git a/plugins/group b/plugins/group index cf15bbf..c768a14 100755 --- a/plugins/group +++ b/plugins/group @@ -2,9 +2,7 @@ help(){ cat<<__EOF__ - usage: m group [ list | ls | info | adduser | removeuser | ismember | help ] - - Examples: + Usage: m group list # get list of groups m group info mygroup # display group information diff --git a/plugins/hostname b/plugins/hostname index 5e01320..e61fb45 100755 --- a/plugins/hostname +++ b/plugins/hostname @@ -3,13 +3,9 @@ help(){ cat<<__EOF__ - usage: m hostname [ help ] - - Examples: + Usage: m hostname # get the current hostname information (computername, hostname, localhostname and netbiosname) - m hostname newhostname # set a new hostname (computername, hostname, localhostname, netbiosname) - - m hostname help # only shows this help + m hostname # set a new hostname (computername, hostname, localhostname, netbiosname) __EOF__ } diff --git a/plugins/hotcorners b/plugins/hotcorners index 24ff30d..1cb304b 100755 --- a/plugins/hotcorners +++ b/plugins/hotcorners @@ -7,19 +7,19 @@ declare command="$(basename "$0")" help(){ cat<<__EOF__ - usage: m hotcorners set [ bottomleft | bottomright | topright | topleft ] - [ - donothing | - missioncontrol | - showapplicationwindows | - desktop | - startscreensaver | - disablescreensaver | - dashboard | - sleepdisplay | - launchpad | - notificationcenter - ] + Usage: + m hotcorners set [ bottomleft | bottomright | topright | topleft ] [ + donothing | + missioncontrol | + showapplicationwindows | + desktop | + startscreensaver | + disablescreensaver | + dashboard | + sleepdisplay | + launchpad | + notificationcenter + ] __EOF__ } diff --git a/plugins/info b/plugins/info index bb1ec6d..debb5d0 100755 --- a/plugins/info +++ b/plugins/info @@ -3,9 +3,7 @@ help(){ cat<<__EOF__ - usage: m info [ help ] - - Examples: + Usage: m info # print macOS operating system version information __EOF__ } diff --git a/plugins/itunes b/plugins/itunes index a423c07..c2394ca 100755 --- a/plugins/itunes +++ b/plugins/itunes @@ -7,9 +7,7 @@ declare subcommand="$1" help () { cat<<__EOF__ - usage: m itunes [ status | play | pause | next | prev | mute | unmute | vol up | vol down | vol # | stop | quit | autobackup | mediakeys | help ] - - Examples: + Usage: m itunes status # Show status m itunes play # Play track m itunes pause # Pause track @@ -22,7 +20,7 @@ help () { m itunes vol # # Set volume level m itunes stop # Stop track m itunes quit # Quit iTunes - m itunes autobackup [ YES | NO ] # Whether to backup devices after sync + m itunes autobackup [ YES | NO ] # Whether to backup devices after sync m itunes mediakeys [ YES | NO ] # Whether to enable iTunes media keys __EOF__ } diff --git a/plugins/keyboard b/plugins/keyboard index bc3e758..41b97f0 100755 --- a/plugins/keyboard +++ b/plugins/keyboard @@ -10,33 +10,20 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m keyboard [ - accentedpress | - spellchecking | - textsubstitution | - usefunctionkeys | - inputfieldaccess | - autodim | - autodimdelay | - keyrepeatrate | - keyrepeatdelay | - help - ] - - Examples: + Usage: m keyboard accentedpress [ YES | NO ] # Whether to enable press and hold to show accented characters m keyboard spellchecking [ YES | NO ] # Whether to enable spell check indication (red squiggly lines) m keyboard textsubstitution [ YES | NO ] # Whether to substitute quotes, dashes, spelling corrections, etc automatically m keyboard usefunctionkeys [ YES | NO ] # Whether to use F1 function keys or alternate function keys (brightness, etc) m keyboard inputfieldaccess [ # Specify which input fields can be tabbed through - BASIC | - ALL_EXCEPT_DROPDOWNS | - ALL + basic | + allexceptdropdowns | + all ] m keyboard autodim [ YES | NO ] # Whether to automatically dim the keyboard brightness when idle - m keyboard autodimdelay 2 # How long to wait before dimming the keyboard brightness - m keyboard keyrepeatrate 4 # How quickly a held key repeats - m keyboard keyrepeatdelay 1.2 # How long a key needs to be held before repeating + m keyboard autodimdelay x # How long to wait before dimming the keyboard brightness + m keyboard keyrepeatrate x # How quickly a held key repeats + m keyboard keyrepeatdelay x.x # How long a key needs to be held before repeating __EOF__ } @@ -95,13 +82,13 @@ inputfieldaccess() { local mode case "$1" in - [aA][lL][lL]) + all) mode="3" ;; - [aA][lL][lL]_[eE][xX][cC][eE][pP][tT]_[dD][rR][oO][pP][dD][oO][wW][nN][sS]) + allexceptdropdowns) mode="2" ;; - [bB][aA][sS][iI][cC]) + basic) mode="1" ;; esac diff --git a/plugins/launchpad b/plugins/launchpad index a6aca0c..2d55a61 100755 --- a/plugins/launchpad +++ b/plugins/launchpad @@ -7,9 +7,7 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m launchpad [ prune | help ] - - Examples: + Usage: m launchpad prune # Remove all items from launchpad __EOF__ } diff --git a/plugins/locale b/plugins/locale index 8af5e24..4eb64cb 100755 --- a/plugins/locale +++ b/plugins/locale @@ -10,9 +10,7 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m locale [ onlywifi | help ] - - Examples: + Usage: m locale language # Specify the language to use (eg en_US) m locale unit [ metric | english ] # Specify the measurement unit __EOF__ diff --git a/plugins/location b/plugins/location index 6d7db2a..f597f28 100755 --- a/plugins/location +++ b/plugins/location @@ -7,9 +7,7 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m location [ prune | help ] - - Examples: + Usage: m location enable # Enable the location service m location diable # Disable the location service __EOF__ diff --git a/plugins/menubar b/plugins/menubar index cf07861..02c8731 100755 --- a/plugins/menubar +++ b/plugins/menubar @@ -10,9 +10,7 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m menubar [ autohide | airplay | help ] - - Examples: + Usage: m menubar autohide [ YES | NO ] # Whether to autohide the menu bar m menubar airplay [ YES | NO ] # Whether to show the airplay options in the menu bar diff --git a/plugins/missioncontrol b/plugins/missioncontrol index 979faf0..17b766e 100755 --- a/plugins/missioncontrol +++ b/plugins/missioncontrol @@ -10,9 +10,7 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m missioncontrol [ showcenter | help ] - - Examples: + Usage: m missioncontrol dashboardvisible [ YES | NO ] # m missioncontrol groupwindowsbyapp [ YES | NO ] # m missioncontrol animationspeed x.x # diff --git a/plugins/network b/plugins/network index 2e70c66..441fe51 100755 --- a/plugins/network +++ b/plugins/network @@ -7,9 +7,7 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m network [ ls | list | location | help ] - - Examples: + Usage: m network ls # list network interfaces m network location # get current location m network location ls # list locations diff --git a/plugins/nosleep b/plugins/nosleep index 991a8f7..b96e166 100755 --- a/plugins/nosleep +++ b/plugins/nosleep @@ -3,13 +3,15 @@ help(){ cat<<__EOF__ - usage: m nosleep [ until | help ] + Usage: + m nosleep until # no sleep until number of seconds elaspes + m nosleep until # no sleep until the script ends + m nosleep until pid # no sleep until the process id ends Examples: - m nosleep until 3600 # no sleep until 3600 seconds - m nosleep until my_script.sh # no sleep until the script ends - - m nosleep until pid 64377 # no sleep until the process id ends + m nosleep until 3600 + m nosleep until my_script.sh + m nosleep until pid 64377 __EOF__ } diff --git a/plugins/notification b/plugins/notification index cb2b032..ce4f39b 100755 --- a/plugins/notification +++ b/plugins/notification @@ -10,13 +10,10 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m notification [ showcenter | help ] - - Examples: - m notification showcenter # get the current status - m notification showcenter YES # enable the notification center - m notification showcenter NO # disable the notification center - m notification bannertime x # disable the notification center + Usage: + m notification enable # enable the notification center + m notification disable # disable the notification center + m notification bannertime x # change the time that banners stay on the screen for __EOF__ } diff --git a/plugins/ntp b/plugins/ntp index 93cb7c5..c2c8d13 100755 --- a/plugins/ntp +++ b/plugins/ntp @@ -3,13 +3,14 @@ help(){ cat<<__EOF__ - usage: m ntp [ status | enable | disable | set | help ] - - Examples: + Usage: m ntp status # status of the network time service m ntp enable # enable clock to use network time m ntp disable # disable clock to use network time - m ntp set timehost1.net.sap.corp # set network time server + m ntp set # set network time server + + Examples: + m ntp set timehost1.net.sap.corp __EOF__ } diff --git a/plugins/power b/plugins/power index d11e5b9..5cb1f5a 100755 --- a/plugins/power +++ b/plugins/power @@ -16,23 +16,10 @@ _set_power_setting(){ help(){ cat<<__EOF__ - usage: m power [ - disksleeptime | - displaysleeptime | - hibernationdelay | - sleepdelay | - powernap | - powerbuttonsleeps | - appnapp | - restartonhang | - persistmemory | - help - ] - - Every command that has two entries requires both the battery setting and the - plugged setting (in that order). - - Examples: + Usage: + Every command that has two entries requires both the battery setting and the + plugged setting (in that order). + m power disksleeptime x x # Time until disks sleep m power displaysleeptime x x # Time until displays sleep m power hibernationdelay x x # Time until system hibernates diff --git a/plugins/printer b/plugins/printer index a94b5d0..14aa6a4 100755 --- a/plugins/printer +++ b/plugins/printer @@ -10,10 +10,7 @@ declare subcommand="$1" help(){ cat<<__EOF__ - - usage: m printer [ settings | name | queue | drivers | web | quitwhenfinished | help ] - - Examples: + Usage: m printer settings # Printer settings m printer name # Display printer names on system m printer queue # Display items in printer queue on system diff --git a/plugins/restart b/plugins/restart index 29bbd31..54da6a1 100755 --- a/plugins/restart +++ b/plugins/restart @@ -3,11 +3,9 @@ help(){ cat<<__EOF__ - usage: m restart [ -f | --force | help ] - - Examples: - m restart # restart computer (needs confirmation) - m restart -f # restart computer (without confirmation) + Usage: + m restart # restart computer (needs confirmation) + m restart --force # restart computer (without confirmation) __EOF__ } diff --git a/plugins/safeboot b/plugins/safeboot index ed39fd1..aaaf88d 100755 --- a/plugins/safeboot +++ b/plugins/safeboot @@ -3,9 +3,7 @@ help(){ cat<<__EOF__ - usage: m safeboot [ status | enable | disable | help ] - - Examples: + Usage: m safeboot status # get the boot args m safeboot enable # enable safe boot m safeboot disable # disable safeboot diff --git a/plugins/screencapture b/plugins/screencapture index 8f3146d..b0671fe 100755 --- a/plugins/screencapture +++ b/plugins/screencapture @@ -12,9 +12,7 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m screencapture [ help ] - - Examples: + Usage: m screencapture type [ # Specify the type of the screenshots png | jpg | diff --git a/plugins/screensaver b/plugins/screensaver index b9d48b5..225366d 100755 --- a/plugins/screensaver +++ b/plugins/screensaver @@ -10,16 +10,11 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m screensaver [ status | askforpassword | help ] - - Examples: - m screensaver # launch screensaver - - m screensaver status # get the current status - m screensaver askforpassword # get password requirement to unlock - m screensaver askforpassword YES # enable password requirement to unlock - m screensaver askforpassword NO # disable password requirement to unlock - m screensaver passworddelay x # the length of time before screensaver requires password + Usage: + m screensaver # launch screensaver + m screensaver status # get the current status + m screensaver askforpassword [ YES | NO ] # whether to enable password requirement to unlock + m screensaver passworddelay x # the length of time before screensaver requires password __EOF__ } diff --git a/plugins/scrolling b/plugins/scrolling index 09f1f70..a865bcc 100755 --- a/plugins/scrolling +++ b/plugins/scrolling @@ -10,9 +10,7 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m scrolling [ direction | barvisibility | bounce | autoscrolldelay | momentum | help ] - - Examples: + Usage: m scrolling direction [ natural | inverted ] # What direction the content moves when swiping m scrolling barvisibility [ onlywhenscrolling | always ] # When to show scroll bars m scrolling bounce [ YES | NO ] # Whether to bounce at the end of scrolling diff --git a/plugins/service b/plugins/service index 416c6e2..58f2224 100755 --- a/plugins/service +++ b/plugins/service @@ -10,19 +10,23 @@ LAUNCHCTLPATHS=( \ help(){ cat<<__EOF__ - usage: m service [ --status-all | --list | --ls | start | stop | load | unload | help ] - - - Examples: + Usage: m service --status-all # list all services m service --list # list all services m service --ls # list all services - m service --ls com.apple.sessionlogoutd # show information about a specific service + m service --ls # show information about a specific service + + m service start # start a service + m service stop # stop a service + m service load # load a service + m service unload # unload a service + + Examples: + m service --ls com.apple.sessionlogoutd # show information about a specific service m service start com.apple.sessionlogoutd # start a service m service stop com.apple.sessionlogoutd # stop a service - m service load com.apple.sessionlogoutd # load a service m service unload com.apple.sessionlogoutd # unload a service diff --git a/plugins/shutdown b/plugins/shutdown index 170db9d..d773cb3 100755 --- a/plugins/shutdown +++ b/plugins/shutdown @@ -3,9 +3,7 @@ help(){ cat<<__EOF__ - usage: m shutdown [-f | --force | help ] - - Examples: + Usage: m shutdown # shutdown computer (needs confirmation) m shutdown -f # shutdown computer (without confirmation) __EOF__ diff --git a/plugins/sleep b/plugins/sleep index 8082fbb..13d3e6c 100755 --- a/plugins/sleep +++ b/plugins/sleep @@ -3,9 +3,7 @@ help(){ cat<<__EOF__ - usage: m sleep [ help ] - - Examples: + Usage: m sleep # put the mac to sleep __EOF__ } diff --git a/plugins/sound b/plugins/sound index 191656a..e0828da 100755 --- a/plugins/sound +++ b/plugins/sound @@ -10,9 +10,7 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m sound [ startupchime | volumefeedback | ui | speechrecognition | speechtotext | voiceover | powerchime | help ] - - Examples: + Usage m sound startupchime [ YES | NO ] # whether the startup chime is used m sound volumefeedback [ YES | NO ] # whether or not you hear feedback when the volume is changed m sound ui [ YES | NO ] [ x.x ] # whether the UI bleeps and bloops are used diff --git a/plugins/spotlight b/plugins/spotlight index 933a9d9..7a6298d 100755 --- a/plugins/spotlight +++ b/plugins/spotlight @@ -10,9 +10,7 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m spotlight [ shortcutkeys | help ] - - Examples: + Usage: m spotlight shortcutkeys [ YES | NO ] # Whether to enable the Cmd-Space shortcuts __EOF__ } diff --git a/plugins/system b/plugins/system index 5fe8a80..b56a0ec 100755 --- a/plugins/system +++ b/plugins/system @@ -10,9 +10,7 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m system [ quarantine | automaticapptermination | documentversioning | crashreporter | savetoicloudbydefault | savewindowsonquit | help ] - - Examples: + Usage: m system quarantine [ YES | NO ] # Whether to enable app quarantine m system automaticapptermination [ YES | NO ] # Whether to enable automatic app termination m system documentversioning [ YES | NO ] # Whether to enable document versioning diff --git a/plugins/timemachine b/plugins/timemachine index fec4167..95c4454 100755 --- a/plugins/timemachine +++ b/plugins/timemachine @@ -11,9 +11,7 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m timemachine [ enable | disable | help ] - - Examples: + Usage: m timemachine usenewdisks [ YES | NO ] # Whether to use new disks for backups m timemachine useallnetworkvolumes [ YES | NO ] # Whether to use unsupported network volumes for backups m timemachine localbackups [ YES | NO ] # Whether to enable local backups diff --git a/plugins/timezone b/plugins/timezone index fbb7e6b..01790f4 100755 --- a/plugins/timezone +++ b/plugins/timezone @@ -3,12 +3,13 @@ help(){ cat<<__EOF__ - usage: m timezone [ list | ls | set | help ] + Usage: + m timezone # get current timezone + m timezone ls # list available timezones + m timezone set # set timezone Examples: - m timezone # get current timezone - m timezone ls # list available timezones - m timezone set Europe/Berlin # set timezone + m timezone set Europe/Berlin __EOF__ } diff --git a/plugins/tooltips b/plugins/tooltips index 8cf95c5..8b56821 100755 --- a/plugins/tooltips +++ b/plugins/tooltips @@ -5,13 +5,10 @@ source "$( dirname "${BASH_SOURCE[0]}" )/../lib/keyboard_shortcuts.sh" help(){ cat<<__EOF__ - usage: m tooltips [ delay | autowrap | fontsize | fontname | help ] - - Examples: + Usage: m tooltips delay x # Set the delay before the tooltip shows up m tooltips autowrap [ YES | NO ] # Whether tooltips should wrap - m tooltips fontsize x.x # The size of the font in the tooltip - m tooltips fontname # The name of the font in the tooltip + m tooltips fontsize x # The size of the font in the tooltip __EOF__ } diff --git a/plugins/trash b/plugins/trash index 830bbaf..5955e36 100755 --- a/plugins/trash +++ b/plugins/trash @@ -3,9 +3,7 @@ help(){ cat<<__EOF__ - usage: m trash [ status | clean | warn | help ] - - Examples: + Usage: m trash status # get trash info m trash clean # clean trash m trash warn [ YES | NO ] # warn when emptying trash diff --git a/plugins/update b/plugins/update index 72c747e..3339403 100755 --- a/plugins/update +++ b/plugins/update @@ -10,16 +10,17 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m update [ list | install | help ] - - Examples: + Usage: m update list # list available updates - m update install all # install all the available updates - m update install iTunesX-12.4.1 RAWCameraUpdate6.20-6.20 # install specific updates + m update install [ all | ] # which updates to install m update automaticinstall [ YES | NO ] # whether automatic installs should be enabled m update automaticdownload [ YES | NO ] # whether automatic downloads should be enabled m update interval [ daily | weekly | biweekly | monthly | x ] # how often to check for updates + Examples: + m update install all # install all the available updates + m update install iTunesX-12.4.1 RAWCameraUpdate6.20-6.20 # install specific updates + __EOF__ } diff --git a/plugins/user b/plugins/user index f232a4f..15e81d1 100755 --- a/plugins/user +++ b/plugins/user @@ -12,9 +12,7 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m user [ list | ls | info | create | delete | autologin | fastswitching | guest | loginattemptsbeforehint | help ] - - Examples: + Usage: m user ls # list users m user info demouser # display user information diff --git a/plugins/vpn b/plugins/vpn index 4c2af87..53bdd5e 100755 --- a/plugins/vpn +++ b/plugins/vpn @@ -7,9 +7,7 @@ _SECRET="--secret" help(){ cat<<__EOF__ - usage: m vpn [ ls | list | start | stop | status | help ] - - Examples: + Usage: m vpn ls # list VPN connections m vpn start # interactive mode diff --git a/plugins/wallpaper b/plugins/wallpaper index 0caaa3e..43d46f9 100755 --- a/plugins/wallpaper +++ b/plugins/wallpaper @@ -3,10 +3,11 @@ help(){ cat<<__EOF__ - usage: m wallpaper [ /path/to/file.jpg | help ] + Usage: + m wallpaper # set wallpaper Examples: - m wallpaper ./wallpapers/tree.jpg # set wallpaper + m wallpaper ./wallpapers/tree.jpg __EOF__ } diff --git a/plugins/wifi b/plugins/wifi index 9fc5712..0320b8a 100755 --- a/plugins/wifi +++ b/plugins/wifi @@ -5,9 +5,7 @@ _W_DEVICE=${_W_DEVICE:-en0} help(){ cat<<__EOF__ - usage: m wifi [ scan | off | on | connect | help ] - - Examples: + Usage: m wifi status # wifi status m wifi scan # scan wifi m wifi showpassword [ESSID] # show wifi network password (default: current) diff --git a/plugins/windows b/plugins/windows index bc784dd..4e6839d 100755 --- a/plugins/windows +++ b/plugins/windows @@ -10,9 +10,7 @@ declare subcommand="$1" help(){ cat<<__EOF__ - usage: m windows [ miniturizeondoubleclick | help ] - - Examples: + Usage: m windows miniturizeondoubleclick [ YES | NO ] # Whether to miniturize windows on a double click of the title bar __EOF__ From 50248870ec19c7780038877c0db07377abaf5273 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sun, 8 Jan 2017 12:35:20 -0600 Subject: [PATCH 078/100] Allow yes/no combos to include on/off --- lib/converters.sh | 28 ++++++++++++++-------------- lib/defaults.sh | 4 ++-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/converters.sh b/lib/converters.sh index 2fedd62..02bb349 100644 --- a/lib/converters.sh +++ b/lib/converters.sh @@ -5,10 +5,10 @@ _mcli_convert_yes_no_to_boolean() { "") echo "" ;; - 1|[yY][eE][sS]|[tT][rR][uU][eE]) + 1|[yY][eE][sS]|[oO][nN]|[tT][rR][rU][eE]) echo "true" ;; - 0|[nN][oO]|[fF][aA][lL][sS][eE]) + 0|[nN][oO]|[oO][fF][fF]|[fF][aA][lL][sS][eE]) echo "false" ;; *) @@ -24,10 +24,10 @@ _mcli_convert_yes_no_to_on_off() { "") echo "" ;; - 1|[yY][eE][sS]|[tT][rR][uU][eE]) + 1|[yY][eE][sS]|[oO][nN]|[tT][rR][rU][eE]) echo "on" ;; - 0|[nN][oO]|[fF][aA][lL][sS][eE]) + 0|[nN][oO]|[oO][fF][fF]|[fF][aA][lL][sS][eE]) echo "off" ;; *) @@ -43,10 +43,10 @@ _mcli_convert_yes_no_to_enabled_disabled() { "") echo "" ;; - 1|[yY][eE][sS]|[tT][rR][uU][eE]) + 1|[yY][eE][sS]|[oO][nN]|[tT][rR][rU][eE]) echo "enabled" ;; - 0|[nN][oO]|[fF][aA][lL][sS][eE]) + 0|[nN][oO]|[oO][fF][fF]|[fF][aA][lL][sS][eE]) echo "disabled" ;; *) @@ -72,10 +72,10 @@ _mcli_convert_yes_no_to_load_unload() { "") echo "" ;; - 1|[yY][eE][sS]|[tT][rR][uU][eE]) + 1|[yY][eE][sS]|[oO][nN]|[tT][rR][rU][eE]) echo "load" ;; - 0|[nN][oO]|[fF][aA][lL][sS][eE]) + 0|[nN][oO]|[oO][fF][fF]|[fF][aA][lL][sS][eE]) echo "unload" ;; *) @@ -91,10 +91,10 @@ _mcli_convert_yes_no_to_inverted_boolean() { "") echo "" ;; - 1|[yY][eE][sS]|[tT][rR][uU][eE]) + 1|[yY][eE][sS]|[oO][nN]|[tT][rR][rU][eE]) echo "false" ;; - 0|[nN][oO]|[fF][aA][lL][sS][eE]) + 0|[nN][oO]|[oO][fF][fF]|[fF][aA][lL][sS][eE]) echo "true" ;; *) @@ -110,10 +110,10 @@ _mcli_convert_yes_no_to_yes_no() { "") echo "" ;; - 1|[yY][eE][sS]|[tT][rR][uU][eE]) + 1|[yY][eE][sS]|[oO][nN]|[tT][rR][rU][eE]) echo "YES" ;; - 0|[nN][oO]|[fF][aA][lL][sS][eE]) + 0|[nN][oO]|[oO][fF][fF]|[fF][aA][lL][sS][eE]) echo "NO" ;; *) @@ -129,10 +129,10 @@ _mcli_convert_yes_no_to_integer() { "") echo "" ;; - 1|[yY][eE][sS]|[tT][rR][uU][eE]) + 1|[yY][eE][sS]|[oO][nN]|[tT][rR][rU][eE]) echo "1" ;; - 0|[nN][oO]|[fF][aA][lL][sS][eE]) + 0|[nN][oO]|[oO][fF][fF]|[fF][aA][lL][sS][eE]) echo "0" ;; *) diff --git a/lib/defaults.sh b/lib/defaults.sh index 2fc575c..4cdc287 100644 --- a/lib/defaults.sh +++ b/lib/defaults.sh @@ -13,10 +13,10 @@ _mcli_read_boolean_as_yes_no() { local value="$(_mcli_read $@)" case "${value}" in - 0|[nN][oO]|[fF][aA][lL][sS][eE]) + 0|[nN][oO]|[oO][fF][fF]|[fF][aA][lL][sS][eE]) echo "NO" ;; - 1|[yY][eE][sS]|[tT][rU][eE]) + 1|[yY][eE][sS]|[oO][nN]|[tT][rR][rU][eE]) echo "YES" ;; esac From 23b836010c58f1279c3cf626c569318eea08f7b1 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sun, 8 Jan 2017 12:35:53 -0600 Subject: [PATCH 079/100] Fix matching on floats with more than one number --- lib/converters.sh | 2 +- lib/defaults.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/converters.sh b/lib/converters.sh index 02bb349..576534c 100644 --- a/lib/converters.sh +++ b/lib/converters.sh @@ -148,7 +148,7 @@ _mcli_convert_number_to_number() { "") echo "" ;; - [0-9][.][0-9]) + [0-9]*[.][0-9]*) echo "${choice}" ;; [0-9]*) diff --git a/lib/defaults.sh b/lib/defaults.sh index 4cdc287..0e0bab7 100644 --- a/lib/defaults.sh +++ b/lib/defaults.sh @@ -70,7 +70,7 @@ _mcli_defaults_number() { local transformed="$(_mcli_convert_number_to_number "${new_value}")" case "${transformed}" in - [0-9][.][0-9]) + [0-9]*[.][0-9]*) ${sudo} defaults write "${domain}" "${key}" -float "${transformed}" ;; [0-9]*) From 6d1ddaacb128ce9f0d2fd29d609f3592374f058e Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sun, 8 Jan 2017 12:38:39 -0600 Subject: [PATCH 080/100] Quote all the things --- lib/defaults.sh | 20 +++++++------------- plugins/airport | 14 +++++++------- plugins/animations | 3 +++ plugins/display | 2 +- plugins/dock | 30 +++++++++++++++--------------- plugins/finder | 3 +++ plugins/fullscreen | 6 +++--- plugins/keyboard | 18 +++++++++--------- plugins/network | 8 ++++---- plugins/notification | 14 ++++++++++++++ plugins/power | 7 +++++-- plugins/spotlight | 2 +- plugins/tooltips | 9 +++------ plugins/trash | 2 +- plugins/user | 18 +++++++++--------- 15 files changed, 85 insertions(+), 71 deletions(-) diff --git a/lib/defaults.sh b/lib/defaults.sh index 0e0bab7..c10b8cf 100644 --- a/lib/defaults.sh +++ b/lib/defaults.sh @@ -10,7 +10,7 @@ _mcli_read() { } _mcli_read_boolean_as_yes_no() { - local value="$(_mcli_read $@)" + local value="$(_mcli_read "$@")" case "${value}" in 0|[nN][oO]|[oO][fF][fF]|[fF][aA][lL][sS][eE]) @@ -23,25 +23,19 @@ _mcli_read_boolean_as_yes_no() { } _mcli_read_number() { - local value="$(_mcli_read $@)" + local value="$(_mcli_read "$@")" echo "${value}" } _mcli_read_string() { - local value="$(_mcli_read $@)" - - echo "${value}" -} - -_mcli_read_font() { - local value="$(_mcli_read $@)" + local value="$(_mcli_read "$@")" echo "${value}" } _mcli_read_inverted_boolean() { - local value="$(_mcli_read_boolean $@)" + local value="$(_mcli_read_boolean_as_yes_no "$@")" if [[ "${value}" == "YES" ]]; then echo "NO" @@ -51,15 +45,15 @@ _mcli_read_inverted_boolean() { } _mcli_defaults_yes_no_to_integer() { - _mcli_defaults_yes_no_to_type "integer" "convert_yes_no_to_boolean" $@ + _mcli_defaults_yes_no_to_type "integer" "convert_yes_no_to_integer" "$@" } _mcli_defaults_yes_no_to_boolean() { - _mcli_defaults_yes_no_to_type "boolean" "convert_yes_no_to_boolean" $@ + _mcli_defaults_yes_no_to_type "boolean" "convert_yes_no_to_boolean" "$@" } _mcli_defaults_yes_no_to_inverted_boolean() { - _mcli_defaults_yes_no_to_type "boolean" "convert_yes_no_to_inverted_boolean" $@ + _mcli_defaults_yes_no_to_type "boolean" "convert_yes_no_to_inverted_boolean" "$@" } _mcli_defaults_number() { diff --git a/plugins/airport b/plugins/airport index d6861f1..2c95d45 100755 --- a/plugins/airport +++ b/plugins/airport @@ -107,25 +107,25 @@ case "${subcommand}" in help ;; disconnectonlogout) - disconnectonlogout $@ + disconnectonlogout "$@" ;; nonpreferrednetworks) - preferrednetworks $@ + nonpreferrednetworks "$@" ;; preferrednetworks) - preferrednetworks $@ + preferrednetworks "$@" ;; rememberrecents) - rememberrecents $@ + rememberrecents "$@" ;; secureadhocnetworks) - secureadhocnetworks $@ + secureadhocnetworks "$@" ;; securechangenetworks) - securechangenetworks $@ + securechangenetworks "$@" ;; securetogglepower) - securetogglepower $@ + securetogglepower "$@" ;; *) help diff --git a/plugins/animations b/plugins/animations index 51ca078..c887ddb 100755 --- a/plugins/animations +++ b/plugins/animations @@ -105,6 +105,9 @@ case "${subcommand}" in inputs) inputs "$@" ;; + finder) + finder "$@" + ;; fullscreen) fullscreen "$@" ;; diff --git a/plugins/display b/plugins/display index 41f0632..769dd2e 100755 --- a/plugins/display +++ b/plugins/display @@ -37,7 +37,7 @@ case "${subcommand}" in display_status ;; autobrightness) - autobrightness $@ + autobrightness "$@" ;; *) help diff --git a/plugins/dock b/plugins/dock index f86c88f..fb0ba86 100755 --- a/plugins/dock +++ b/plugins/dock @@ -209,49 +209,49 @@ case "${subcommand}" in disable ;; activeindicators) - active_indicators $@ + active_indicators "$@" ;; bounceonappactivity) - bounce_on_app_activity $@ + bounce_on_app_activity "$@" ;; bounceonapplaunch) - bounce_on_app_launch $@ + bounce_on_app_launch "$@" ;; showdelay) - auto_hide_speed $@ + auto_hide_delay "$@" ;; autohidedelay) - auto_hide_delay $@ + auto_hide_delay "$@" ;; autohidespeed) - auto_hide_speed $@ + auto_hide_speed "$@" ;; autohide) - auto_hide $@ + auto_hide "$@" ;; fullscreendelay) - full_screen_delay $@ + full_screen_delay "$@" ;; itunesnotifications) - itunes_notifications $@ + itunes_notifications "$@" ;; magnification) - magnify $@ + magnify "$@" ;; magnificationsize) - magnification_size $@ + magnification_size "$@" ;; hiddenappdimming) - hidden_app_dimming $@ + hidden_app_dimming "$@" ;; iconsize) - icon_size $@ + icon_size "$@" ;; onlyshowrunning) - only_show_running $@ + only_show_running "$@" ;; position) - dock_position $@ + dock_position "$@" ;; addblankspace) add_blank_space diff --git a/plugins/finder b/plugins/finder index 381dc5b..12539b6 100755 --- a/plugins/finder +++ b/plugins/finder @@ -292,6 +292,9 @@ case "${subcommand}" in minimumplayablepreviewsize) minimumplayablepreviewsize "$@" ;; + datetype) + datetype "$@" + ;; defaultlocation) defaultlocation "$@" ;; diff --git a/plugins/fullscreen b/plugins/fullscreen index 47de949..b435dd1 100755 --- a/plugins/fullscreen +++ b/plugins/fullscreen @@ -50,13 +50,13 @@ case "${subcommand}" in help ;; sortbymostrecentlyused) - sortbymostrecentlyused + sortbymostrecentlyused "$@" ;; switchonactivation) - switchonactivation + switchonactivation "$@" ;; separatedisplays) - separatedisplays + separatedisplays "$@" ;; *) help diff --git a/plugins/keyboard b/plugins/keyboard index 41b97f0..57ae71a 100755 --- a/plugins/keyboard +++ b/plugins/keyboard @@ -137,31 +137,31 @@ case "${subcommand}" in help ;; accentedpress) - accentedpress $@ + accentedpress "$@" ;; spellchecking) - spellchecking $@ + spellchecking "$@" ;; textsubstitution) - textsubstitution $@ + textsubstitution "$@" ;; usefunctionkeys) - usefunctionkeys $@ + usefunctionkeys "$@" ;; inputfieldaccess) - inputfieldaccess $@ + inputfieldaccess "$@" ;; autodim) - autodim $@ + autodim "$@" ;; autodimdelay) - autodimdelay $@ + autodimdelay "$@" ;; keyrepeatrate) - keyrepeatrate $@ + keyrepeatrate "$@" ;; keyrepeatdelay) - keyrepeatdelay $@ + keyrepeatdelay "$@" ;; *) help diff --git a/plugins/network b/plugins/network index 441fe51..7cb88f0 100755 --- a/plugins/network +++ b/plugins/network @@ -95,16 +95,16 @@ case "${subcommand}" in list_netservices ;; location) - location $@ + location "$@" ;; defaultusername) - defaultusername $@ + defaultusername "$@" ;; wakeonethernet) - wakeonethernet $@ + wakeonethernet "$@" ;; guestaccess) - guestaccess $@ + guestaccess "$@" ;; *) help diff --git a/plugins/notification b/plugins/notification index ce4f39b..bbbd5ad 100755 --- a/plugins/notification +++ b/plugins/notification @@ -17,6 +17,14 @@ help(){ __EOF__ } +enable(){ + showcenter "YES" +} + +disable(){ + showcenter "NO" +} + showcenter(){ local choice="$(_mcli_convert_yes_no_to_load_unload $1)" @@ -42,6 +50,12 @@ case "${subcommand}" in showcenter) showcenter "$@" ;; + enable) + enable "$@" + ;; + disable) + disable "$@" + ;; bannertime) bannertime "$@" ;; diff --git a/plugins/power b/plugins/power index 5cb1f5a..faa818a 100755 --- a/plugins/power +++ b/plugins/power @@ -112,12 +112,15 @@ case "${subcommand}" in powerbuttonsleeps) powerbuttonsleeps "$@" ;; - appnapp) - appnapp "$@" + appnap) + appnap "$@" ;; restartonhang) restartonhang "$@" ;; + persistmemory) + persistmemory "$@" + ;; *) help ;; diff --git a/plugins/spotlight b/plugins/spotlight index 7a6298d..925cc7f 100755 --- a/plugins/spotlight +++ b/plugins/spotlight @@ -31,7 +31,7 @@ case "${subcommand}" in help ;; shortcutkeys) - shortcut_keys + shortcut_keys "$@" ;; *) help diff --git a/plugins/tooltips b/plugins/tooltips index 8b56821..54b233d 100755 --- a/plugins/tooltips +++ b/plugins/tooltips @@ -49,16 +49,13 @@ case "${subcommand}" in help ;; delay) - delay + delay "$@" ;; autowrap) - autowrap + autowrap "$@" ;; fontsize) - fontsize - ;; - fontname) - fontname + fontsize "$@" ;; *) help diff --git a/plugins/trash b/plugins/trash index 5955e36..2451f7f 100755 --- a/plugins/trash +++ b/plugins/trash @@ -35,7 +35,7 @@ case $1 in clean_trash ;; warn) - warn + warn "$@" ;; status) du -ch $HOME/.Trash/* 2>/dev/null | tail -n 1 | awk '{print "Size: ", $1}' diff --git a/plugins/user b/plugins/user index 15e81d1..bbc94b8 100755 --- a/plugins/user +++ b/plugins/user @@ -200,34 +200,34 @@ case $1 in user_ls ;; info) - user_info $@ + user_info "$@" ;; create) user_create ;; delete) - user_delete $@ + user_delete "$@" ;; autologin) - autologin $@ + autologin "$@" ;; fastswitching) - fastswitching $@ + fastswitching "$@" ;; guest) - guest $@ + guest "$@" ;; showsecure) - showsecure $@ + showsecure "$@" ;; loginpoweroptions) - loginpoweroptions $@ + loginpoweroptions "$@" ;; loginattemptsbeforehint) - loginattemptsbeforehint $@ + loginattemptsbeforehint "$@" ;; loginmessage) - loginmessage $@ + loginmessage "$@" ;; *) help From 50156544313a747d22c48d78c04886eea517a4db Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sun, 8 Jan 2017 12:43:05 -0600 Subject: [PATCH 081/100] Fix missing imports/command name extraction --- plugins/debugmode | 12 +++++++++--- plugins/dialogs | 3 +++ plugins/dir | 2 +- plugins/disk | 2 +- plugins/filevault | 3 +++ plugins/firewall | 10 +++++++++- plugins/gatekeeper | 8 +++++--- plugins/hotcorners | 3 +++ plugins/itunes | 5 ++++- plugins/location | 3 +++ plugins/network | 3 +++ plugins/power | 3 +++ plugins/screencapture | 2 -- plugins/tooltips | 15 ++++++++++----- plugins/trash | 9 ++++++++- plugins/update | 5 ++++- plugins/user | 2 +- 17 files changed, 70 insertions(+), 20 deletions(-) diff --git a/plugins/debugmode b/plugins/debugmode index 60cf0ea..e824cad 100755 --- a/plugins/debugmode +++ b/plugins/debugmode @@ -1,5 +1,13 @@ #!/usr/bin/env bash +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + help(){ cat<<__EOF__ Usage: @@ -50,16 +58,14 @@ _toggle_debug_mode(){ defaults write com.apple.Backup IncludeDebugMenu -bool "${enabled}" } -case $1 in +case "${subcommand}" in help) help ;; enable) - shift _toggle_debug_mode "true" ;; disable) - shift _toggle_debug_mode "false" ;; *) diff --git a/plugins/dialogs b/plugins/dialogs index 759b3c7..e70ca40 100755 --- a/plugins/dialogs +++ b/plugins/dialogs @@ -1,5 +1,8 @@ #!/usr/bin/env bash +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + declare command="$(basename "$0")" declare subcommand="$1" diff --git a/plugins/dir b/plugins/dir index b3df9a1..3c576b0 100755 --- a/plugins/dir +++ b/plugins/dir @@ -100,7 +100,7 @@ hide(){ chflags hidden "$1" } -case "$1" in +case "${subcommand}" in help) help ;; diff --git a/plugins/disk b/plugins/disk index c186f10..ce86c79 100755 --- a/plugins/disk +++ b/plugins/disk @@ -130,7 +130,7 @@ remotesharing(){ echo "${command} ${subcommand}: ${value}" } -case $1 in +case "${subcommand}" in help) help ;; diff --git a/plugins/filevault b/plugins/filevault index 083edcd..f2b448a 100755 --- a/plugins/filevault +++ b/plugins/filevault @@ -1,5 +1,8 @@ #!/usr/bin/env bash +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + declare command="$(basename "$0")" declare subcommand="$1" diff --git a/plugins/firewall b/plugins/firewall index 9ab5a5b..7fe7d1f 100755 --- a/plugins/firewall +++ b/plugins/firewall @@ -1,5 +1,13 @@ #!/usr/bin/env bash +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + help(){ cat<<__EOF__ Usage: @@ -16,7 +24,7 @@ help(){ __EOF__ } -case $1 in +case "${subcommand}" in help) help ;; diff --git a/plugins/gatekeeper b/plugins/gatekeeper index 2d5ab9c..d4ad65a 100755 --- a/plugins/gatekeeper +++ b/plugins/gatekeeper @@ -2,6 +2,11 @@ # TODO: add more functionalities +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + help(){ cat<<__EOF__ Usage: @@ -51,15 +56,12 @@ case $1 in spctl --status ;; list|ls) - shift gk_list "$*" ;; enable) - shift enable "$*" ;; disable) - shift disable "$*" ;; *) diff --git a/plugins/hotcorners b/plugins/hotcorners index 1cb304b..c33dad3 100755 --- a/plugins/hotcorners +++ b/plugins/hotcorners @@ -4,6 +4,9 @@ source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift help(){ cat<<__EOF__ diff --git a/plugins/itunes b/plugins/itunes index c2394ca..9bd6115 100755 --- a/plugins/itunes +++ b/plugins/itunes @@ -1,5 +1,8 @@ #!/usr/bin/env bash +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + declare command="$(basename "$0")" declare subcommand="$1" @@ -39,7 +42,7 @@ mediakeys(){ launchctl ${value} -w /System/Library/LaunchAgents/com.apple.rcd.plist 2> /dev/null } -case $1 in +case "${subcommand}" in help) help ;; diff --git a/plugins/location b/plugins/location index f597f28..491a544 100755 --- a/plugins/location +++ b/plugins/location @@ -1,5 +1,8 @@ #!/usr/bin/env bash +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + declare command="$(basename "$0")" declare subcommand="$1" diff --git a/plugins/network b/plugins/network index 7cb88f0..d4c9a66 100755 --- a/plugins/network +++ b/plugins/network @@ -1,5 +1,8 @@ #!/usr/bin/env bash +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + declare command="$(basename "$0")" declare subcommand="$1" diff --git a/plugins/power b/plugins/power index faa818a..565011d 100755 --- a/plugins/power +++ b/plugins/power @@ -1,5 +1,8 @@ #!/usr/bin/env bash +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + declare command="$(basename "$0")" declare subcommand="$1" diff --git a/plugins/screencapture b/plugins/screencapture index b0671fe..ab4de5c 100755 --- a/plugins/screencapture +++ b/plugins/screencapture @@ -1,7 +1,5 @@ #!/usr/bin/env bash -declare path_to_plistbuddy="/usr/libexec/PlistBuddy" - source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" diff --git a/plugins/tooltips b/plugins/tooltips index 54b233d..f1267b8 100755 --- a/plugins/tooltips +++ b/plugins/tooltips @@ -1,7 +1,12 @@ #!/usr/bin/env bash source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" -source "$( dirname "${BASH_SOURCE[0]}" )/../lib/keyboard_shortcuts.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift help(){ cat<<__EOF__ @@ -17,7 +22,7 @@ delay() { "NSInitialToolTipDelay" \ "$1")" - echo "Keyboard delay: ${value}" + echo "${command} ${subcommand}: ${value}" } autowrap() { @@ -25,7 +30,7 @@ autowrap() { "NSToolTipAutoWrappingDisabled" \ "$1")" - echo "Keyboard autowrap: ${value}" + echo "${command} ${subcommand}: ${value}" } fontsize() { @@ -33,7 +38,7 @@ fontsize() { "NSToolTipsFontSize" \ "$1")" - echo "Keyboard fontsize: ${value}" + echo "${command} ${subcommand}: ${value}" } fontname() { @@ -41,7 +46,7 @@ fontname() { "NSToolTipsFont" \ "$1")" - echo "Keyboard fontname: ${value}" + echo "${command} ${subcommand}: ${value}" } case "${subcommand}" in diff --git a/plugins/trash b/plugins/trash index 2451f7f..8bb4e55 100755 --- a/plugins/trash +++ b/plugins/trash @@ -1,5 +1,12 @@ #!/usr/bin/env bash +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift help(){ cat<<__EOF__ @@ -27,7 +34,7 @@ warn() { echo "${command} ${subcommand}: ${value}" } -case $1 in +case "${subcommand}" in help) help ;; diff --git a/plugins/update b/plugins/update index 3339403..61766b8 100755 --- a/plugins/update +++ b/plugins/update @@ -3,6 +3,9 @@ declare path_to_update_prefs="/Library/Preferences/com.apple.SoftwareUpdate" declare path_to_appstore_prefs="/Library/Preferences/com.apple.commerce" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + declare command="$(basename "$0")" declare subcommand="$1" @@ -91,7 +94,7 @@ interval(){ echo "${command} ${subcommand}: ${value}" } -case $1 in +case "${subcommand}" in help) help ;; diff --git a/plugins/user b/plugins/user index bbc94b8..3872e16 100755 --- a/plugins/user +++ b/plugins/user @@ -192,7 +192,7 @@ loginmessage(){ sudo touch $eficachedir } -case $1 in +case "${subcommand}" in help) help ;; From 414e98085c6d812b26308872a0f7ed9e85bce279 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sun, 8 Jan 2017 12:45:10 -0600 Subject: [PATCH 082/100] Fix places where we weren't using our helpers Some places can't be replaced, but these could --- plugins/appearance | 36 +++++++++++++++++++++++++++++------- plugins/datetime | 9 +++++++-- plugins/sound | 6 +++--- plugins/system | 6 +++++- 4 files changed, 44 insertions(+), 13 deletions(-) diff --git a/plugins/appearance b/plugins/appearance index 7dcb5a4..9d5b13b 100755 --- a/plugins/appearance +++ b/plugins/appearance @@ -41,8 +41,14 @@ darkmode(){ local choice="$(_mcli_convert_yes_no_to_boolean "$1")" local mode="$(if [[ "${choice}" == "true" ]]; then echo "Dark"; else echo "Light"; fi)" - defaults write NSGlobalDomain AppleInterfaceStyle "${mode}" - defaults write NSGlobalDomain NSFullScreenDarkMenu -boolean "${choice}" + value="$(_mcli_defaults_string "NSGlobalDomain" \ + "AppleInterfaceStyle" \ + "${mode}")" + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "NSFullScreenDarkMenu" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" } transparency(){ @@ -76,8 +82,14 @@ sidebariconsize(){ ;; esac - defaults write NSGlobalDomain NSTableViewDefaultSizeMode -integer "${size}" - defaults write NSGlobalDomain NSNavPanelIconViewIconSizeForOpenMode -integer "${size}" + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "NSTableViewDefaultSizeMode" \ + "${size}")" + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "NSNavPanelIconViewIconSizeForOpenMode" \ + "${size}")" + + echo "${command} ${subcommand}: ${value}" } maincolor(){ @@ -95,7 +107,11 @@ maincolor(){ ;; esac - defaults write NSGlobalDomain AppleAquaColorVariant -int $color + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "AppleAquaColorVariant" \ + "${color}")" + + echo "${command} ${subcommand}: ${value}" } highlightcolor(){ @@ -205,8 +221,14 @@ highlightcolor(){ color="$1";; esac - defaults write NSGlobalDomain AppleHighlightColor -string "${color}" - defaults write com.apple.systempreferences AppleOtherHighlightColor -string "${color}" + value="$(_mcli_defaults_string "NSGlobalDomain" \ + "AppleHighlightColor" \ + "${color}")" + value="$(_mcli_defaults_string "com.apple.systempreferences" \ + "AppleOtherHighlightColor" \ + "${color}")" + + echo "${command} ${subcommand}: ${value}" } case "${subcommand}" in diff --git a/plugins/datetime b/plugins/datetime index 3f3f6d5..f154d7f 100755 --- a/plugins/datetime +++ b/plugins/datetime @@ -23,13 +23,18 @@ __EOF__ local choice="$(_mcli_convert_yes_no_to_boolean "$1")" local hour_format="$(if [[ "${choice}" == "true" ]]; then echo "H"; else echo "h"; fi)" - defaults delete NSGlobalDomain AppleICUTimeFormatStrings > /dev/null 2&>1 + defaults delete NSGlobalDomain AppleICUTimeFormatStrings &> /dev/null defaults write NSGlobalDomain AppleICUTimeFormatStrings -dict-add "1" "${hour_format}:mm" defaults write NSGlobalDomain AppleICUTimeFormatStrings -dict-add "2" "${hour_format}:mm:ss" defaults write NSGlobalDomain AppleICUTimeFormatStrings -dict-add "3" "${hour_format}:mm:ss z" defaults write NSGlobalDomain AppleICUTimeFormatStrings -dict-add "4" "${hour_format}:mm:ss zzzz" - defaults write NSGlobalDomain AppleICUForce24HourTime -bool "${choice}" + + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "AppleICUForce24HourTime" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" } usentpserver(){ diff --git a/plugins/sound b/plugins/sound index e0828da..56f51de 100755 --- a/plugins/sound +++ b/plugins/sound @@ -63,6 +63,9 @@ speechrecognition(){ } speechtotext(){ + value="$(_mcli_defaults_delete "com.apple.speech.synthesis.general.prefs" \ + "TimeAnnouncementPrefs" \ + "sudo")" value="$(_mcli_defaults_yes_no_to_boolean "com.apple.speech.synthesis.general.prefs" \ "TalkingAlertsSpeakTextFlag" \ "$1" \ @@ -75,9 +78,6 @@ speechtotext(){ "SpokenUIUseSpeakingHotKeyFlag" \ "$1" \ "sudo")" - value="$(_mcli_defaults_delete "com.apple.speech.synthesis.general.prefs" \ - "TimeAnnouncementPrefs" \ - "sudo")" echo "${command} ${subcommand}: ${value}" } diff --git a/plugins/system b/plugins/system index b56a0ec..35d9ad9 100755 --- a/plugins/system +++ b/plugins/system @@ -40,7 +40,9 @@ automaticapptermination() { documentversioning(){ local choice="$(_mcli_convert_yes_no_to_boolean "$1")" - defaults write NSGlobalDomain ApplePersistence -bool "${choice}" + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "ApplePersistence" \ + "$1")" if [[ "${choice}" == "true" ]]; then sudo mkdir /.DocumentRevisions-V100 2> /dev/null @@ -49,6 +51,8 @@ documentversioning(){ sudo rm -rf /.DocumentRevisions-V1* defaults write NSGlobalDomain AutosavingDelay -int 0 fi + + echo "${command} ${subcommand}: ${value}" } crashreporter(){ From c0fb4d3e2ed8bcc3bddbbd192369ecfa6dcea9e3 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sun, 8 Jan 2017 12:47:06 -0600 Subject: [PATCH 083/100] Fix calls to incorrect defaults helpers --- plugins/dashboard | 12 ++++++------ plugins/finder | 6 +++--- plugins/keyboard | 24 ++++++++++++------------ plugins/screencapture | 6 +++--- plugins/sound | 2 +- plugins/tooltips | 12 ++++++------ plugins/update | 8 ++++---- 7 files changed, 35 insertions(+), 35 deletions(-) diff --git a/plugins/dashboard b/plugins/dashboard index 9220d22..4413f3d 100755 --- a/plugins/dashboard +++ b/plugins/dashboard @@ -27,9 +27,9 @@ __EOF__ } enable(){ - value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dashboard" \ - "mcx-disabled" \ - "NO")" + value="$(_mcli_defaults_yes_no_to_inverted_boolean "com.apple.dashboard" \ + "mcx-disabled" \ + "YES")" _mcli_toggle_dashboard_keyboard_shortcuts "${value}" @@ -37,9 +37,9 @@ enable(){ } disable(){ - value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dashboard" \ - "mcx-disabled" \ - "YES")" + value="$(_mcli_defaults_yes_no_to_inverted_boolean "com.apple.dashboard" \ + "mcx-disabled" \ + "NO")" _mcli_toggle_dashboard_keyboard_shortcuts "${value}" diff --git a/plugins/finder b/plugins/finder index 12539b6..8bc190a 100755 --- a/plugins/finder +++ b/plugins/finder @@ -206,9 +206,9 @@ springing(){ } minimumplayablepreviewsize(){ - value="$(_mcli_defaults_yes_no_to_integer "com.apple.finder" \ - "QLInlinePreviewMinimumSupportedSize" \ - "$1")" + value="$(_mcli_defaults_number "com.apple.finder" \ + "QLInlinePreviewMinimumSupportedSize" \ + "$1")" echo "${command} ${subcommand}: ${value}" } diff --git a/plugins/keyboard b/plugins/keyboard index 57ae71a..1591c39 100755 --- a/plugins/keyboard +++ b/plugins/keyboard @@ -93,9 +93,9 @@ inputfieldaccess() { ;; esac - value="$(_mcli_defaults_integer "NSGlobalDomain" \ - "AppleKeyboardUIMode" \ - "${mode}")" + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "AppleKeyboardUIMode" \ + "${mode}")" echo "${command} ${subcommand}: ${value}" } @@ -109,25 +109,25 @@ autodim() { } autodimdelay() { - value="$(_mcli_defaults_integer "com.apple.iokit.AmbientLightSensor" \ - "Keyboard Dim Time" \ - "$1")" + value="$(_mcli_defaults_number "com.apple.iokit.AmbientLightSensor" \ + "Keyboard Dim Time" \ + "$1")" echo "${command} ${subcommand}: ${value}" } keyrepeatrate() { - value="$(_mcli_defaults_integer "NSGlobalDomain" \ - "KeyRepeat" \ - "$1")" + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "KeyRepeat" \ + "$1")" echo "${command} ${subcommand}: ${value}" } keyrepeatdelay() { - value="$(_mcli_defaults_integer "NSGlobalDomain" \ - "InitialKeyRepeat" \ - "$1")" + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "InitialKeyRepeat" \ + "$1")" echo "${command} ${subcommand}: ${value}" } diff --git a/plugins/screencapture b/plugins/screencapture index ab4de5c..ab4f51b 100755 --- a/plugins/screencapture +++ b/plugins/screencapture @@ -49,9 +49,9 @@ filename(){ } shadow(){ - value="$(_mcli_defaults_string "com.apple.screencapture" \ - "disable-shadow" \ - "$1")" + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.screencapture" \ + "disable-shadow" \ + "$1")" echo "${command} ${subcommand}: ${value}" } diff --git a/plugins/sound b/plugins/sound index 56f51de..7078a4b 100755 --- a/plugins/sound +++ b/plugins/sound @@ -46,7 +46,7 @@ ui(){ value="$(_mcli_defaults_yes_no_to_boolean "com.apple.finder" \ "FinderSounds" \ "$1")" - value="$(_mcli_defaults_number "com.apple.systemsound" \ + _mcli_defaults_number "com.apple.systemsound" \ "com.apple.sound.beep.volume" \ "$1")" diff --git a/plugins/tooltips b/plugins/tooltips index f1267b8..f25fa8e 100755 --- a/plugins/tooltips +++ b/plugins/tooltips @@ -18,9 +18,9 @@ __EOF__ } delay() { - value="$(_mcli_defaults_yes_no_to_integer "NSGlobalDomain" \ - "NSInitialToolTipDelay" \ - "$1")" + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "NSInitialToolTipDelay" \ + "$1")" echo "${command} ${subcommand}: ${value}" } @@ -34,9 +34,9 @@ autowrap() { } fontsize() { - value="$(_mcli_defaults_yes_no_to_number "NSGlobalDomain" \ - "NSToolTipsFontSize" \ - "$1")" + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "NSToolTipsFontSize" \ + "$1")" echo "${command} ${subcommand}: ${value}" } diff --git a/plugins/update b/plugins/update index 61766b8..804386d 100755 --- a/plugins/update +++ b/plugins/update @@ -86,10 +86,10 @@ interval(){ interval="$1";; esac - value="$(_mcli_defaults_yes_no_to_integer "${path_to_update_prefs}" \ - "ScheduleFrequency" \ - "${interval}" \ - "sudo")" + value="$(_mcli_defaults_number "${path_to_update_prefs}" \ + "ScheduleFrequency" \ + "${interval}" \ + "sudo")" echo "${command} ${subcommand}: ${value}" } From 4662455fad085f87bf2b133e0b95cc0ddeeb92d8 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sun, 8 Jan 2017 12:50:39 -0600 Subject: [PATCH 084/100] Fix issues with commands being called with no arguments --- plugins/dir | 4 ++++ plugins/disk | 2 ++ plugins/filevault | 2 ++ plugins/finder | 4 ++++ plugins/firewall | 16 ++++++++++++++++ plugins/hotcorners | 2 ++ plugins/itunes | 2 ++ plugins/network | 8 ++++++++ plugins/notification | 4 +++- plugins/power | 12 ++++++++++-- plugins/sound | 4 +++- plugins/spotlight | 2 ++ plugins/system | 2 +- 13 files changed, 59 insertions(+), 5 deletions(-) diff --git a/plugins/dir b/plugins/dir index 3c576b0..a641273 100755 --- a/plugins/dir +++ b/plugins/dir @@ -93,10 +93,14 @@ delete(){ } show(){ + [ -z "$1" ] && help && return + chflags nohidden "$1" } hide(){ + [ -z "$1" ] && help && return + chflags hidden "$1" } diff --git a/plugins/disk b/plugins/disk index ce86c79..8e463df 100755 --- a/plugins/disk +++ b/plugins/disk @@ -116,6 +116,8 @@ rename(){ } remotesharing(){ + [ -z "$1" ] && help && exit 1 + local loaded="$(_mcli_convert_yes_no_to_load_unload "$1")" value="$(_mcli_defaults_yes_no_to_boolean "com.apple.NetworkBrowser" \ diff --git a/plugins/filevault b/plugins/filevault index f2b448a..1042358 100755 --- a/plugins/filevault +++ b/plugins/filevault @@ -19,6 +19,8 @@ __EOF__ } standbykey(){ + [ -z "$1" ] && help && return + choice="$(_mcli_convert_yes_no_to_integer "$1")" sudo pmset -a destroyfvkeyonstandby "${choice}" diff --git a/plugins/finder b/plugins/finder index 8bc190a..a8b9763 100755 --- a/plugins/finder +++ b/plugins/finder @@ -141,10 +141,14 @@ stoppreviewswhenscrolling(){ infopanesexpanded() { local choice="$(_mcli_convert_yes_no_to_boolean "$1")" + if [ -n "${choice}" ]; then defaults write com.apple.finder FXInfoPanesExpanded -dict \ General -boolean "${choice}" \ OpenWith -boolean "${choice}" \ Privileges -boolean "${choice}" + fi + + defaults read com.apple.finder FXInfoPanesExpanded } showrecenttags() { diff --git a/plugins/firewall b/plugins/firewall index 7fe7d1f..25d3049 100755 --- a/plugins/firewall +++ b/plugins/firewall @@ -40,22 +40,38 @@ case "${subcommand}" in autoallowsignedapps) choice="$(_mcli_convert_yes_no_to_on_off "$1")" + if [ -n "${choice}" ]; then sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setallowsigned "${choice}" + else + sudo /usr/libexec/ApplicationFirewall/socketfilterfw --getallowsigned + fi ;; blockall) choice="$(_mcli_convert_yes_no_to_on_off "$1")" + if [ -n "${choice}" ]; then sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setblockall "${choice}" + else + sudo /usr/libexec/ApplicationFirewall/socketfilterfw --getblockall + fi ;; logging) choice="$(_mcli_convert_yes_no_to_on_off "$1")" + if [ -n "${choice}" ]; then sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setloggingmode "${choice}" + else + sudo /usr/libexec/ApplicationFirewall/socketfilterfw --getloggingmode + fi ;; stealth) choice="$(_mcli_convert_yes_no_to_on_off "$1")" + if [ -n "${choice}" ]; then sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setstealthmode "${choice}" + else + sudo /usr/libexec/ApplicationFirewall/socketfilterfw --getstealthmode + fi ;; list) sudo /usr/libexec/ApplicationFirewall/socketfilterfw --list diff --git a/plugins/hotcorners b/plugins/hotcorners index c33dad3..b1b7d52 100755 --- a/plugins/hotcorners +++ b/plugins/hotcorners @@ -94,6 +94,8 @@ set(){ ;; esac + [ -z "${corner}" ] || [ -z "${action}" ] || [ -z "${modifier}" ] && help && return + defaults write com.apple.dock wvous-${corner}-corner -integer $action defaults write com.apple.dock wvous-${corner}-modifier -integer $modifier } diff --git a/plugins/itunes b/plugins/itunes index 9bd6115..f7025a9 100755 --- a/plugins/itunes +++ b/plugins/itunes @@ -37,6 +37,8 @@ autobackup(){ } mediakeys(){ + [ -z "$1" ] && help && return + value="$(_mcli_convert_yes_no_to_load_unload "$1")" launchctl ${value} -w /System/Library/LaunchAgents/com.apple.rcd.plist 2> /dev/null diff --git a/plugins/network b/plugins/network index d4c9a66..081217f 100755 --- a/plugins/network +++ b/plugins/network @@ -46,13 +46,21 @@ defaultusername(){ defaults delete com.apple.NetworkAuthorization UseDefaultName defaults delete com.apple.NetworkAuthorization DefaultName fi + + defaults read com.apple.NetworkAuthorization UseDefaultName + defaults read com.apple.NetworkAuthorization DefaultName } wakeonethernet(){ choice="$(_mcli_convert_yes_no_to_integer "$1")" + if [ -n "${choice}" ]; then sudo pmset -a womp "${choice}" sudo pmset -a ring "${choice}" + fi + + sudo pmset -g | grep womp + sudo pmset -g | grep ring } guestaccess(){ diff --git a/plugins/notification b/plugins/notification index bbbd5ad..27c11ef 100755 --- a/plugins/notification +++ b/plugins/notification @@ -26,7 +26,9 @@ disable(){ } showcenter(){ - local choice="$(_mcli_convert_yes_no_to_load_unload $1)" + [ -z "$1" ] && help && return + + local choice="$(_mcli_convert_yes_no_to_load_unload "$1")" launchctl "${choice}" -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist diff --git a/plugins/power b/plugins/power index 565011d..6fdb059 100755 --- a/plugins/power +++ b/plugins/power @@ -13,8 +13,12 @@ _set_power_setting(){ local battery_value="$2" local plugged_value="$2" - sudo pmset -b "${setting}" "${battery_value}" - sudo pmset -c "${setting}" "${plugged_value}" + if [ -n "${battery_value}" ] && [ -n "${plugged_value}" ]; then + sudo pmset -b "${setting}" "${battery_value}" + sudo pmset -c "${setting}" "${plugged_value}" + else + sudo pmset -g | grep "[[:space:]]${setting}[[:space:]]" + fi } help(){ @@ -77,7 +81,11 @@ appnapp(){ restartonhang(){ value="$(_mcli_convert_yes_no_to_on_off "$1")" + if [ -n "${value}" ]; then sudo /usr/sbin/systemsetup -setrestartfreeze "${value}" + else + sudo /usr/sbin/systemsetup -getrestartfreeze + fi } persistmemory(){ diff --git a/plugins/sound b/plugins/sound index 7078a4b..6348cf3 100755 --- a/plugins/sound +++ b/plugins/sound @@ -26,7 +26,7 @@ startupchime(){ if [[ "${choice}" == "true" ]]; then sudo nvram -d SystemAudioVolume - else + elif [[ "${choice}" == "false" ]]; then sudo nvram SystemAudioVolume=" " fi } @@ -85,6 +85,8 @@ speechtotext(){ voiceover(){ local choice="$(_mcli_convert_yes_no_to_load_unload "$1")" + [ -z "${choice}" ] && return + sudo sh -c "launchctl ${choice} -w /System/Library/LaunchAgents/com.apple.VoiceOver.plist 2> /dev/null" sudo sh -c "launchctl ${choice} -w /System/Library/LaunchAgents/com.apple.ScreenReaderUIServer.plist 2> /dev/null" sudo sh -c "launchctl ${choice} -w /System/Library/LaunchAgents/com.apple.scrod.plist 2> /dev/null" diff --git a/plugins/spotlight b/plugins/spotlight index 925cc7f..d8a4190 100755 --- a/plugins/spotlight +++ b/plugins/spotlight @@ -19,6 +19,8 @@ shortcut_keys() { local spotlight_keyboard_shortcut_ids=(64 65) local enabled="$(_mcli_convert_yes_no_to_boolean "$1")" + [ -z "$1" ] && help && return + for keyboard_shortcut_id in "${spotlight_keyboard_shortcut_ids[@]}"; do _mcli_keyboard_shortcut_toggle $keyboard_shortcut_id $enabled done diff --git a/plugins/system b/plugins/system index 35d9ad9..a94a325 100755 --- a/plugins/system +++ b/plugins/system @@ -47,7 +47,7 @@ documentversioning(){ if [[ "${choice}" == "true" ]]; then sudo mkdir /.DocumentRevisions-V100 2> /dev/null defaults delete NSGlobalDomain AutosavingDelay 2> /dev/null - else + elif [[ "${choice}" == "false" ]]; then sudo rm -rf /.DocumentRevisions-V1* defaults write NSGlobalDomain AutosavingDelay -int 0 fi From ada82f988f2b493a8ececbb7c81116eabf81c982 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sun, 8 Jan 2017 12:51:56 -0600 Subject: [PATCH 085/100] Change return text to be better --- lib/defaults.sh | 25 ++++++++++++++++++++++--- plugins/dashboard | 2 +- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/lib/defaults.sh b/lib/defaults.sh index c10b8cf..5c0cad5 100644 --- a/lib/defaults.sh +++ b/lib/defaults.sh @@ -39,11 +39,24 @@ _mcli_read_inverted_boolean() { if [[ "${value}" == "YES" ]]; then echo "NO" - else + elif [[ "${value}" == "NO" ]]; then echo "YES" + else + echo "ERROR" fi } +_mcli_invert_boolean() { + case "$1" in + 0|[nN][oO]|[oO][fF][fF]|[fF][aA][lL][sS][eE]) + echo "YES" + ;; + 1|[yY][eE][sS]|[oO][nN]|[tT][rR][rU][eE]) + echo "NO" + ;; + esac +} + _mcli_defaults_yes_no_to_integer() { _mcli_defaults_yes_no_to_type "integer" "convert_yes_no_to_integer" "$@" } @@ -53,7 +66,9 @@ _mcli_defaults_yes_no_to_boolean() { } _mcli_defaults_yes_no_to_inverted_boolean() { - _mcli_defaults_yes_no_to_type "boolean" "convert_yes_no_to_inverted_boolean" "$@" + local result="$(_mcli_defaults_yes_no_to_type "boolean" "convert_yes_no_to_inverted_boolean" "$@")" + + _mcli_invert_boolean "${result}" } _mcli_defaults_number() { @@ -126,5 +141,9 @@ _mcli_defaults_yes_no_to_type() { ${sudo} defaults write "${domain}" "${key}" -${type} "${transformed}" fi - _mcli_read_boolean "${domain}" "${key}" + if [[ "${transformed}" != "ERROR" ]]; then + _mcli_read_boolean_as_yes_no "${domain}" "${key}" "${sudo}" + else + echo "ERROR" + fi } diff --git a/plugins/dashboard b/plugins/dashboard index 4413f3d..13ef791 100755 --- a/plugins/dashboard +++ b/plugins/dashboard @@ -43,7 +43,7 @@ disable(){ _mcli_toggle_dashboard_keyboard_shortcuts "${value}" - echo "${command} ${subcommand}: ${value}" + echo "${command} enable: ${value}" } case "${subcommand}" in From a62b94eadacd14728abb7474617817b54f99d379 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sun, 8 Jan 2017 12:52:58 -0600 Subject: [PATCH 086/100] Add missing sudos --- plugins/display | 3 ++- plugins/network | 6 ++++-- plugins/notification | 2 +- plugins/scrolling | 3 ++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/plugins/display b/plugins/display index 769dd2e..73afd73 100755 --- a/plugins/display +++ b/plugins/display @@ -24,7 +24,8 @@ display_status(){ autobrightness() { value="$(_mcli_defaults_yes_no_to_integer "${path_to_plist}" \ "Automatic Display Enabled" \ - "$1")" + "$1" \ + "sudo")" echo "${command} ${subcommand}: ${value}" } diff --git a/plugins/network b/plugins/network index 081217f..9cc1b3a 100755 --- a/plugins/network +++ b/plugins/network @@ -66,10 +66,12 @@ wakeonethernet(){ guestaccess(){ value="$(_mcli_defaults_yes_no_to_boolean "/Library/Preferences/com.apple.AppleFileServer" \ "guestAccess" \ - "$1")" + "$1" \ + "sudo")" value="$(_mcli_defaults_yes_no_to_boolean "/Library/Preferences/com.apple.smb.server" \ "AllowGuestAccess" \ - "$1")" + "$1" \ + "sudo")" echo "${command} ${subcommand}: ${value}" } diff --git a/plugins/notification b/plugins/notification index 27c11ef..02a9b79 100755 --- a/plugins/notification +++ b/plugins/notification @@ -30,7 +30,7 @@ showcenter(){ local choice="$(_mcli_convert_yes_no_to_load_unload "$1")" - launchctl "${choice}" -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist + sudo launchctl "${choice}" -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist value="$(_mcli_convert_exit_status_to_enabled_disabled "ps -A | grep apsd | grep -v grep")" diff --git a/plugins/scrolling b/plugins/scrolling index a865bcc..2ad02ab 100755 --- a/plugins/scrolling +++ b/plugins/scrolling @@ -60,7 +60,8 @@ barvisibility(){ bounce(){ value="$(_mcli_defaults_yes_no_to_boolean "/Library/Preferences/.GlobalPreferences" \ "NSScrollViewRubberbanding" \ - "$1")" + "$1" \ + "sudo")" echo "${command} ${subcommand}: ${value}" } From 5f8cd93725d9b972fb6fcd2fd37a9e5ba3eb7b7a Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sun, 8 Jan 2017 12:54:00 -0600 Subject: [PATCH 087/100] Style and nameing changes --- lib/defaults.sh | 1 + plugins/dock | 1 + plugins/finder | 8 ++++---- plugins/firewall | 8 ++++---- plugins/hotcorners | 4 ++-- plugins/network | 4 +--- plugins/power | 4 ++-- plugins/spotlight | 2 +- plugins/system | 2 +- plugins/user | 6 +++--- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/defaults.sh b/lib/defaults.sh index 5c0cad5..4906928 100644 --- a/lib/defaults.sh +++ b/lib/defaults.sh @@ -128,6 +128,7 @@ _mcli_defaults_delete() { fi } +# shellcheck disable=SC2086 _mcli_defaults_yes_no_to_type() { local type="$1" local transformer="$2" diff --git a/plugins/dock b/plugins/dock index fb0ba86..419f714 100755 --- a/plugins/dock +++ b/plugins/dock @@ -187,6 +187,7 @@ add_recent_items(){ killall Dock } +# shellcheck disable=SC2086 prune(){ echo "remove all items from the Dock" defaults write com.apple.dock checked-for-launchpad -bool true diff --git a/plugins/finder b/plugins/finder index a8b9763..5865410 100755 --- a/plugins/finder +++ b/plugins/finder @@ -142,10 +142,10 @@ infopanesexpanded() { local choice="$(_mcli_convert_yes_no_to_boolean "$1")" if [ -n "${choice}" ]; then - defaults write com.apple.finder FXInfoPanesExpanded -dict \ - General -boolean "${choice}" \ - OpenWith -boolean "${choice}" \ - Privileges -boolean "${choice}" + defaults write com.apple.finder FXInfoPanesExpanded -dict \ + General -boolean "${choice}" \ + OpenWith -boolean "${choice}" \ + Privileges -boolean "${choice}" fi defaults read com.apple.finder FXInfoPanesExpanded diff --git a/plugins/firewall b/plugins/firewall index 25d3049..7390fd3 100755 --- a/plugins/firewall +++ b/plugins/firewall @@ -41,7 +41,7 @@ case "${subcommand}" in choice="$(_mcli_convert_yes_no_to_on_off "$1")" if [ -n "${choice}" ]; then - sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setallowsigned "${choice}" + sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setallowsigned "${choice}" else sudo /usr/libexec/ApplicationFirewall/socketfilterfw --getallowsigned fi @@ -50,7 +50,7 @@ case "${subcommand}" in choice="$(_mcli_convert_yes_no_to_on_off "$1")" if [ -n "${choice}" ]; then - sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setblockall "${choice}" + sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setblockall "${choice}" else sudo /usr/libexec/ApplicationFirewall/socketfilterfw --getblockall fi @@ -59,7 +59,7 @@ case "${subcommand}" in choice="$(_mcli_convert_yes_no_to_on_off "$1")" if [ -n "${choice}" ]; then - sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setloggingmode "${choice}" + sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setloggingmode "${choice}" else sudo /usr/libexec/ApplicationFirewall/socketfilterfw --getloggingmode fi @@ -68,7 +68,7 @@ case "${subcommand}" in choice="$(_mcli_convert_yes_no_to_on_off "$1")" if [ -n "${choice}" ]; then - sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setstealthmode "${choice}" + sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setstealthmode "${choice}" else sudo /usr/libexec/ApplicationFirewall/socketfilterfw --getstealthmode fi diff --git a/plugins/hotcorners b/plugins/hotcorners index b1b7d52..ab57fc4 100755 --- a/plugins/hotcorners +++ b/plugins/hotcorners @@ -96,8 +96,8 @@ set(){ [ -z "${corner}" ] || [ -z "${action}" ] || [ -z "${modifier}" ] && help && return - defaults write com.apple.dock wvous-${corner}-corner -integer $action - defaults write com.apple.dock wvous-${corner}-modifier -integer $modifier + defaults write com.apple.dock "wvous-${corner}-corner" -integer "${action}" + defaults write com.apple.dock "wvous-${corner}-modifier" -integer "${modifier}" } case "${subcommand}" in diff --git a/plugins/network b/plugins/network index 9cc1b3a..7aadf22 100755 --- a/plugins/network +++ b/plugins/network @@ -55,12 +55,10 @@ wakeonethernet(){ choice="$(_mcli_convert_yes_no_to_integer "$1")" if [ -n "${choice}" ]; then - sudo pmset -a womp "${choice}" - sudo pmset -a ring "${choice}" + sudo pmset -a womp "${choice}" fi sudo pmset -g | grep womp - sudo pmset -g | grep ring } guestaccess(){ diff --git a/plugins/power b/plugins/power index 6fdb059..de0228a 100755 --- a/plugins/power +++ b/plugins/power @@ -70,7 +70,7 @@ powerbuttonsleeps(){ echo "${command} ${subcommand}: ${value}" } -appnapp(){ +appnap(){ value="$(_mcli_defaults_yes_no_to_inverted_boolean "NSGlobalDomain" \ "NSAppSleepDisabled" \ "$1")" @@ -82,7 +82,7 @@ restartonhang(){ value="$(_mcli_convert_yes_no_to_on_off "$1")" if [ -n "${value}" ]; then - sudo /usr/sbin/systemsetup -setrestartfreeze "${value}" + sudo /usr/sbin/systemsetup -setrestartfreeze "${value}" else sudo /usr/sbin/systemsetup -getrestartfreeze fi diff --git a/plugins/spotlight b/plugins/spotlight index d8a4190..875ea65 100755 --- a/plugins/spotlight +++ b/plugins/spotlight @@ -22,7 +22,7 @@ shortcut_keys() { [ -z "$1" ] && help && return for keyboard_shortcut_id in "${spotlight_keyboard_shortcut_ids[@]}"; do - _mcli_keyboard_shortcut_toggle $keyboard_shortcut_id $enabled + _mcli_keyboard_shortcut_toggle "${keyboard_shortcut_id}" "${enabled}" done echo "${command} ${subcommand}: ${enabled}" diff --git a/plugins/system b/plugins/system index a94a325..4224e67 100755 --- a/plugins/system +++ b/plugins/system @@ -49,7 +49,7 @@ documentversioning(){ defaults delete NSGlobalDomain AutosavingDelay 2> /dev/null elif [[ "${choice}" == "false" ]]; then sudo rm -rf /.DocumentRevisions-V1* - defaults write NSGlobalDomain AutosavingDelay -int 0 + defaults write NSGlobalDomain AutosavingDelay -integer 0 fi echo "${command} ${subcommand}: ${value}" diff --git a/plugins/user b/plugins/user index 3872e16..d562840 100755 --- a/plugins/user +++ b/plugins/user @@ -184,12 +184,12 @@ loginmessage(){ # Otherwise you will need to touch $kextdir to generate it. # Refresh system kext cache - sudo mkdir -p $kextdir 2> /dev/null + sudo mkdir -p "${kextdir}" 2> /dev/null # Refresh CoreStorage EFI Cache - sudo mkdir -p $eficachedir 2> /dev/null + sudo mkdir -p "${eficachedir}" 2> /dev/null - sudo touch $eficachedir + sudo touch "${eficachedir}" } case "${subcommand}" in From f6631d2a54ada09320b7b5ffd0ab88ee788524bd Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sun, 8 Jan 2017 12:54:42 -0600 Subject: [PATCH 088/100] Remove tooltip font stuff which no longer works --- lib/defaults.sh | 15 +-------------- plugins/tooltips | 8 -------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/lib/defaults.sh b/lib/defaults.sh index 4906928..dd9b5b6 100644 --- a/lib/defaults.sh +++ b/lib/defaults.sh @@ -87,20 +87,7 @@ _mcli_defaults_number() { ;; esac - _mcli_read_integer "${domain}" "${key}" -} - -_mcli_defaults_font() { - local domain="$1" - local key="$2" - local new_value="$3" - local sudo="$4" - - if [ -n "${new_value}" ]; then - ${sudo} defaults write "${domain}" "${key}" -font "${transformed}" - fi - - _mcli_read_font "${domain}" "${key}" + _mcli_read_number "${domain}" "${key}" } _mcli_defaults_string() { diff --git a/plugins/tooltips b/plugins/tooltips index f25fa8e..b1c6a25 100755 --- a/plugins/tooltips +++ b/plugins/tooltips @@ -41,14 +41,6 @@ fontsize() { echo "${command} ${subcommand}: ${value}" } -fontname() { - value="$(_mcli_defaults_font "NSGlobalDomain" \ - "NSToolTipsFont" \ - "$1")" - - echo "${command} ${subcommand}: ${value}" -} - case "${subcommand}" in help) help From 0ad4199e853761be2e2ead5d3c6ad342ef63b89e Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sun, 8 Jan 2017 12:55:09 -0600 Subject: [PATCH 089/100] Fix variable and function call bugs --- lib/defaults.sh | 2 +- plugins/dock | 4 ++-- plugins/power | 2 +- plugins/sound | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/defaults.sh b/lib/defaults.sh index dd9b5b6..984ba27 100644 --- a/lib/defaults.sh +++ b/lib/defaults.sh @@ -97,7 +97,7 @@ _mcli_defaults_string() { local sudo="$4" if [ -n "${new_value}" ]; then - ${sudo} defaults write "${domain}" "${key}" -string "${transformed}" + ${sudo} defaults write "${domain}" "${key}" -string "${new_value}" fi _mcli_read_string "${domain}" "${key}" diff --git a/plugins/dock b/plugins/dock index 419f714..3711e16 100755 --- a/plugins/dock +++ b/plugins/dock @@ -41,12 +41,12 @@ __EOF__ enable(){ auto_hide "NO" - show_delay 0.25 + auto_hide_delay 0.25 } disable(){ auto_hide "YES" - show_delay 999999 + auto_hide_delay 999999 } active_indicators(){ diff --git a/plugins/power b/plugins/power index de0228a..234bd07 100755 --- a/plugins/power +++ b/plugins/power @@ -11,7 +11,7 @@ declare subcommand="$1" _set_power_setting(){ local setting="$1" local battery_value="$2" - local plugged_value="$2" + local plugged_value="$3" if [ -n "${battery_value}" ] && [ -n "${plugged_value}" ]; then sudo pmset -b "${setting}" "${battery_value}" diff --git a/plugins/sound b/plugins/sound index 6348cf3..7c6c00b 100755 --- a/plugins/sound +++ b/plugins/sound @@ -48,7 +48,7 @@ ui(){ "$1")" _mcli_defaults_number "com.apple.systemsound" \ "com.apple.sound.beep.volume" \ - "$1")" + "$2" echo "${command} ${subcommand}: ${value}" } From 965cc8305521d82aa410ff343ae0bf02e3c97575 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sun, 8 Jan 2017 12:55:27 -0600 Subject: [PATCH 090/100] Fix enabled/disabled instead of enable/disable --- lib/converters.sh | 19 +++++++++++++++++++ plugins/timemachine | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/converters.sh b/lib/converters.sh index 576534c..43f4645 100644 --- a/lib/converters.sh +++ b/lib/converters.sh @@ -55,6 +55,25 @@ _mcli_convert_yes_no_to_enabled_disabled() { esac } +_mcli_convert_yes_no_to_enable_disable() { + local choice="$1" + + case "${choice}" in + "") + echo "" + ;; + 1|[yY][eE][sS]|[oO][nN]|[tT][rR][rU][eE]) + echo "enable" + ;; + 0|[nN][oO]|[oO][fF][fF]|[fF][aA][lL][sS][eE]) + echo "disable" + ;; + *) + echo "ERROR" + ;; + esac +} + _mcli_convert_exit_status_to_enabled_disabled() { local command="$1" diff --git a/plugins/timemachine b/plugins/timemachine index 95c4454..e8b27ab 100755 --- a/plugins/timemachine +++ b/plugins/timemachine @@ -36,7 +36,7 @@ useallnetworkvolumes(){ } localbackups(){ - value="$(_mcli_convert_yes_no_to_enabled_disabled "$1")" + value="$(_mcli_convert_yes_no_to_enable_disable "$1")" sudo tmutil ${value}local } From 1c0df25202c40fc7c3028b9f691098405a0de346 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sun, 8 Jan 2017 12:55:45 -0600 Subject: [PATCH 091/100] Remove wildcards since they aren't very useful --- plugins/appearance | 5 ----- 1 file changed, 5 deletions(-) diff --git a/plugins/appearance b/plugins/appearance index 9d5b13b..3a11ba6 100755 --- a/plugins/appearance +++ b/plugins/appearance @@ -102,9 +102,6 @@ maincolor(){ graphite) color="6" ;; - *) - color="$1" - ;; esac value="$(_mcli_defaults_number "NSGlobalDomain" \ @@ -217,8 +214,6 @@ highlightcolor(){ color="0.000000 0.000000 0.000000";; snow) color="1.000000 1.000000 1.000000";; - *) - color="$1";; esac value="$(_mcli_defaults_string "NSGlobalDomain" \ From 2a59df2074eb92146c2e7052bdf50d6ad7aa3e51 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sun, 8 Jan 2017 12:55:50 -0600 Subject: [PATCH 092/100] Docs fix --- plugins/service | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/service b/plugins/service index 58f2224..24fd3b7 100755 --- a/plugins/service +++ b/plugins/service @@ -24,11 +24,11 @@ help(){ m service unload # unload a service Examples: - m service --ls com.apple.sessionlogoutd # show information about a specific service - m service start com.apple.sessionlogoutd # start a service - m service stop com.apple.sessionlogoutd # stop a service - m service load com.apple.sessionlogoutd # load a service - m service unload com.apple.sessionlogoutd # unload a service + m service --ls com.apple.sessionlogoutd + m service start com.apple.sessionlogoutd + m service stop com.apple.sessionlogoutd + m service load com.apple.sessionlogoutd + m service unload com.apple.sessionlogoutd __EOF__ } From 2d3e66043ecccee80157949634450f964ad24f5f Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sun, 8 Jan 2017 14:33:04 -0600 Subject: [PATCH 093/100] Add autoplay to disk --- Readme.md | 2 +- plugins/disk | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 2634164..409e2a9 100644 --- a/Readme.md +++ b/Readme.md @@ -275,7 +275,7 @@ usage: m [OPTIONS] COMMAND [help] m disk rename CURRENTNAME NEWNAME # rename a volume m disk remotesharing [ YES | NO ] # whether disks are allowed to be shared remotely - + m disk autoplay [ YES | NO ] # whether the system should open a window when a drive is inserted ``` #### Disk Images: diff --git a/plugins/disk b/plugins/disk index 8e463df..a31d582 100755 --- a/plugins/disk +++ b/plugins/disk @@ -35,6 +35,7 @@ help(){ m disk rename CURRENTNAME NEWNAME # rename a volume m disk remotesharing [ YES | NO ] # whether disks are allowed to be shared remotely + m disk autoplay [ YES | NO ] # whether the system should open a window when a drive is inserted __EOF__ } @@ -132,6 +133,38 @@ remotesharing(){ echo "${command} ${subcommand}: ${value}" } +autoplay(){ + local choice="$(_mcli_convert_yes_no_to_boolean "$1")" + local inverted_choice="$(_mcli_convert_yes_no_to_inverted_boolean "$1")" + local action; + + case "$1" in + [nN][oO]) + action="1" + ;; + [yY][eE][sS]) + action="2" + ;; + esac + + # Blank CD automatic action. + sudo defaults write /Library/Preferences/com.apple.digihub com.apple.digihub.blank.cd.appeared -dict action "${action}" + + # Music CD automatic action. + sudo defaults write /Library/Preferences/com.apple.digihub com.apple.digihub.cd.music.appeared -dict action "${action}" + + # Picture CD automatic action. + sudo defaults write /Library/Preferences/com.apple.digihub com.apple.digihub.cd.picture.appeared -dict action "${action}" + + # Blank DVD automatic action. + sudo defaults write /Library/Preferences/com.apple.digihub com.apple.digihub.blank.dvd.appeared -dict action "${action}" + + # Video DVD automatic action. + sudo defaults write /Library/Preferences/com.apple.digihub com.apple.digihub.dvd.video.appeared -dict action "${action}" + + echo "${command} ${subcommand}: ${choice}" +} + case "${subcommand}" in help) help @@ -166,6 +199,9 @@ case "${subcommand}" in remotesharing) remotesharing "$@" ;; + autoplay) + autoplay "$@" + ;; *) help ;; From 5bcbddc410f1ec399c7ec0a9294f1210990b7476 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sun, 8 Jan 2017 16:16:51 -0600 Subject: [PATCH 094/100] Add mouse plugin --- Readme.md | 26 +++ plugins/mouse | 605 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 631 insertions(+) create mode 100755 plugins/mouse diff --git a/Readme.md b/Readme.md index 409e2a9..3366338 100644 --- a/Readme.md +++ b/Readme.md @@ -78,6 +78,7 @@ usage: m [OPTIONS] COMMAND [help] location lock missioncontrol + mouse network nosleep notification @@ -540,6 +541,31 @@ usage: m [OPTIONS] COMMAND [help] m missioncontrol animationspeed x.x # ``` +#### Mouse: +``` + Usage: + onefingersingletap [ YES | NO ] + twofingersingletap [ YES | NO ] + threefingersingletap [ lookupdefinition | disable ] + onefingerdoubletap [ smartzoom | missioncontrol | disable ] + twofingerdoubletap [ smartzoom | missioncontrol | disable ] + twofingerhorizontalswipe [ switchpages | switchspaces | horizontalscroll | disable ] + threefingerhorizontalswipe [ switchpages | switchapps | disable ] + fourfingerhorizontalswipe [ switchapps | disable ] + threefingerverticalswipe [ missioncontrol | expose | disable ] + fourfingerverticalswipe [ missioncontrol | expose | disable ] + threefingerdrag [ YES | NO ] + twofingerpinch [ YES | NO ] + fourfingerpinch [ launchpad | disable ] + swipefromrightedge [ notificationcenter | disable ] + rotation [ YES | NO ] + dragging [ YES | NO ] + shaketoenlarge [ YES | NO ] + + mousemovement x.x x.x + trackpadmovement x.x x.x +``` + #### Network: ``` Usage: diff --git a/plugins/mouse b/plugins/mouse new file mode 100755 index 0000000..f424e8b --- /dev/null +++ b/plugins/mouse @@ -0,0 +1,605 @@ +#!/usr/bin/env bash + +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + +help(){ + cat<<__EOF__ + Usage: + onefingersingletap [ YES | NO ] + twofingersingletap [ YES | NO ] + threefingersingletap [ lookupdefinition | disable ] + onefingerdoubletap [ smartzoom | missioncontrol | disable ] + twofingerdoubletap [ smartzoom | missioncontrol | disable ] + twofingerhorizontalswipe [ switchpages | switchspaces | horizontalscroll | disable ] + threefingerhorizontalswipe [ switchpages | switchapps | disable ] + fourfingerhorizontalswipe [ switchapps | disable ] + threefingerverticalswipe [ missioncontrol | expose | disable ] + fourfingerverticalswipe [ missioncontrol | expose | disable ] + threefingerdrag [ YES | NO ] + twofingerpinch [ YES | NO ] + fourfingerpinch [ launchpad | disable ] + swipefromrightedge [ notificationcenter | disable ] + rotation [ YES | NO ] + dragging [ YES | NO ] + shaketoenlarge [ YES | NO ] + + mousemovement x.x x.x + trackpadmovement x.x x.x +__EOF__ +} + +onefingersingletap(){ + # Toggle Tap-To-Click on Internal Touchpad + value="$(_mcli_defaults_yes_no_to_integer "NSGlobalDomain" \ + "com.apple.mouse.tapBehavior" \ + "$1")" + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.AppleMultitouchTrackpad" \ + "Clicking" \ + "$1")" + + # Toggle Tap-To-Click on External Touchpad + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.driver.AppleBluetoothMultitouch.trackpad" \ + "Clicking" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +twofingersingletap(){ + # Toggle Secondary "Right" Click on Internal Touchpad + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "com.apple.trackpad.enableSecondaryClick" \ + "$1" \ + "sudo")" + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.AppleMultitouchTrackpad" \ + "TrackpadRightClick" \ + "$1")" + + # Toggle Secondary "Right" Click on External Touchpad + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.driver.AppleBluetoothMultitouch.trackpad" \ + "TrackpadRightClick" \ + "$1")" + + local mode="$(if [[ "${value}" == "true" ]]; then + echo "TwoButton"; + elif [[ "${value}" == "false" ]]; then + echo "OneButton"; + fi)" + + # Toggle Secondary "Right" Click on Magic Mouse + value="$(_mcli_defaults_string "com.apple.driver.AppleBluetoothMultitouch.mouse" \ + "MouseButtonMode" \ + "${mode}")" + + echo "${command} ${subcommand}: ${value}" +} + +threefingersingletap(){ + local mode + + case "$1" in + lookupdefinition) + mode="2";; + disabled) + mode="0";; + *) + mode="$1";; + esac + + # For Internal Trackpad + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "com.apple.trackpad.threeFingerTapGesture" \ + "${mode}" \ + "sudo")" + value="$(_mcli_defaults_number "com.apple.AppleMultitouchTrackpad" \ + "TrackpadThreeFingerTapGesture" \ + "${mode}")" + + # For External Trackpad + value="$(_mcli_defaults_number "com.apple.driver.AppleBluetoothMultitouch.trackpad" \ + "TrackpadThreeFingerTapGesture" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +onefingerdoubletap(){ + local mode + + case "$1" in + smartzoom) + mode="1";; + missioncontrol) + mode="3";; + disabled) + mode="0";; + *) + mode="$1";; + esac + + value="$(_mcli_defaults_number "com.apple.driver.AppleBluetoothMultitouch.mouse" \ + "MouseOneFingerDoubleTapGesture" \ + "${mode}")" + + echo "${command} ${subcommand}: ${value}" +} + +twofingerdoubletap(){ + local mode + + case $1 in + smartzoom) + mode="1";; + missioncontrol) + mode="3";; + disabled) + mode="0";; + *) + mode="$1";; + esac + + # Internal Trackpad + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "com.apple.trackpad.twoFingerDoubleTapGesture" \ + "${mode}" \ + "sudo")" + value="$(_mcli_defaults_number "com.apple.AppleMultitouchTrackpad" \ + "TrackpadTwoFingerDoubleTapGesture" \ + "${mode}")" + + # External Trackpad + value="$(_mcli_defaults_number "com.apple.driver.AppleBluetoothMultitouch.trackpad" \ + "TrackpadTwoFingerDoubleTapGesture" \ + "${mode}")" + + # External Mouse + value="$(_mcli_defaults_number "com.apple.driver.AppleBluetoothMultitouch.mouse" \ + "MouseTwoFingerDoubleTapGesture" \ + "${mode}")" + + echo "${command} ${subcommand}: ${value}" +} + +twofingerhorizontalswipe(){ + local mode + local navigatewithscrolls="NO" + + case $1 in + disabled) + mode="0";; + horizontalscroll) + mode="0";; + switchpages) + mode="1";; + switchspaces) + mode="2";; + *) + mode="$1";; + esac + + # Internal/External Trackpads + [[ "${mode}" == "1" ]] && navigatewithscrolls="YES" + + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "AppleEnableSwipeNavigateWithScrolls" \ + "${navigatewithscrolls}")" + + # External Mouse + value="$(_mcli_defaults_number "com.apple.driver.AppleBluetoothMultitouch.mouse" \ + "MouseTwoFingerHorizSwipeGesture" \ + "${mode}")" + + echo "${command} ${subcommand}: ${value}" +} + +threefingerhorizontalswipe(){ + local mode; + + case "$1" in + disabled) + mode="0";; + switchpages) + mode="1";; + switchapps) + mode="2";; + *) + mode="$1";; + esac + + # Internal Trackpad + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "com.apple.trackpad.threeFingerHorizSwipeGesture" \ + "${mode}" \ + "sudo")" + value="$(_mcli_defaults_number "com.apple.AppleMultitouchTrackpad" \ + "TrackpadThreeFingerHorizSwipeGesture" \ + "${mode}")" + + # External Trackpad + value="$(_mcli_defaults_number "com.apple.driver.AppleBluetoothMultitouch.trackpad" \ + "TrackpadThreeFingerHorizSwipeGesture" \ + "${mode}")" + + echo "${command} ${subcommand}: ${value}" +} + +fourfingerhorizontalswipe(){ + local mode; + + case "$1" in + switchapps) + mode="2";; + disabled) + mode="0";; + *) + mode="$1";; + esac + + # Internal Trackpad + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "com.apple.trackpad.fourFingerHorizSwipeGesture" \ + "${mode}" \ + "sudo")" + value="$(_mcli_defaults_number "com.apple.AppleMultitouchTrackpad" \ + "TrackpadFourFingerHorizSwipeGesture" \ + "${mode}")" + + # External Trackpad + value="$(_mcli_defaults_number "com.apple.driver.AppleBluetoothMultitouch.trackpad" \ + "TrackpadFourFingerHorizSwipeGesture" \ + "${mode}")" + + echo "${command} ${subcommand}: ${value}" +} + +threefingerverticalswipe(){ + local mode; + local missioncontrolenabled="NO"; + local exposeenabled="NO"; + + case "$1" in + missioncontrol) + mode="2";; + expose) + mode="2";; + disabled) + mode="1";; + *) + mode="$1";; + esac + + [[ "$1" == "missioncontrol" ]] && missioncontrolenabled="YES" + [[ "$1" == "expose" ]] && exposeenabled="YES" + + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ + "showMissionControlGestureEnabled" \ + "${missioncontrolenabled}")" + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ + "showAppExposeGestureEnabled" \ + "${exposeenabled}")" + + # Internal Trackpad + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "com.apple.trackpad.threeFingerVertSwipeGesture" \ + "${mode}" \ + "sudo")" + value="$(_mcli_defaults_number "com.apple.AppleMultitouchTrackpad" \ + "TrackpadThreeFingerVertSwipeGesture" \ + "${mode}")" + + # External Trackpad + value="$(_mcli_defaults_number "com.apple.driver.AppleBluetoothMultitouch.trackpad" \ + "TrackpadThreeFingerVertSwipeGesture" \ + "${mode}")" + + echo "${command} ${subcommand}: ${value}" +} + +fourfingerverticalswipe(){ + local mode; + local missioncontrolenabled="NO"; + local exposeenabled="NO"; + + case "$1" in + missioncontrol) + mode="2";; + expose) + mode="2";; + disabled) + mode="1";; + *) + mode="$1";; + esac + + [[ "$1" == "missioncontrol" ]] && missioncontrolenabled="YES" + [[ "$1" == "expose" ]] && exposeenabled="YES" + + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ + "showMissionControlGestureEnabled" \ + "${missioncontrolenabled}")" + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ + "showAppExposeGestureEnabled" \ + "${exposeenabled}")" + + # Internal Trackpad + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "com.apple.trackpad.fourFingerVertSwipeGesture" \ + "${mode}" \ + "sudo")" + value="$(_mcli_defaults_number "com.apple.AppleMultitouchTrackpad" \ + "TrackpadFourFingerVertSwipeGesture" \ + "${mode}")" + + # External Trackpad + value="$(_mcli_defaults_number "com.apple.driver.AppleBluetoothMultitouch.trackpad" \ + "TrackpadFourFingerVertSwipeGesture" \ + "${mode}")" + + echo "${command} ${subcommand}: ${value}" +} + +threefingerdrag(){ + # Internal Trackpad + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "com.apple.trackpad.threeFingerDragGesture" \ + "$1" \ + "sudo")" + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.AppleMultitouchTrackpad" \ + "TrackpadThreeFingerDrag" \ + "$1")" + + # External Trackpad + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.driver.AppleBluetoothMultitouch.trackpad" \ + "TrackpadThreeFingerDrag" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +twofingerpinch(){ + # Internal Trackpad + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "com.apple.trackpad.pinchGesture" \ + "$1" \ + "sudo")" + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.AppleMultitouchTrackpad" \ + "TrackpadPinch" \ + "$1")" + + # External Trackpad + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.driver.AppleBluetoothMultitouch.trackpad" \ + "TrackpadPinch" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +fourfingerpinch(){ + local mode; + local launchpadenabled="NO"; + + case "$1" in + launchpad) + mode="2";; + disabled) + mode="0";; + *) + mode="$1";; + esac + + [[ "$1" == "launchpad" ]] && launchpadenabled="YES" + + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ + "showLaunchpadGestureEnabled" \ + "${launchpadenabled}")" + + # Internal Trackpad + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "com.apple.trackpad.fourFingerPinchSwipeGesture" \ + "${mode}" \ + "sudo")" + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "com.apple.trackpad.fiveFingerPinchSwipeGesture" \ + "${mode}" \ + "sudo")" + value="$(_mcli_defaults_number "com.apple.AppleMultitouchTrackpad" \ + "TrackpadFourFingerPinchGesture" \ + "${mode}")" + value="$(_mcli_defaults_number "com.apple.AppleMultitouchTrackpad" \ + "TrackpadFiveFingerPinchGesture" \ + "${mode}")" + + # External Trackpad + value="$(_mcli_defaults_number "com.apple.driver.AppleBluetoothMultitouch.trackpad" \ + "TrackpadFourFingerPinchGesture" \ + "${mode}")" + value="$(_mcli_defaults_number "com.apple.driver.AppleBluetoothMultitouch.trackpad" \ + "TrackpadFiveFingerPinchGesture" \ + "${mode}")" + + echo "${command} ${subcommand}: ${value}" +} + +swipefromrightedge(){ + local mode + + case "$1" in + notificationcenter) + mode="3";; + disabled) + mode="0";; + *) + mode="$1";; + esac + + # Internal Trackpad + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "com.apple.trackpad.twoFingerFromRightEdgeSwipeGesture" \ + "${mode}" \ + "sudo")" + value="$(_mcli_defaults_number "com.apple.AppleMultitouchTrackpad" \ + "TrackpadTwoFingerFromRightEdgeSwipeGesture" \ + "${mode}")" + + # External Trackpad + value="$(_mcli_defaults_number "com.apple.driver.AppleBluetoothMultitouch.trackpad" \ + "TrackpadTwoFingerFromRightEdgeSwipeGesture" \ + "${mode}")" + + echo "${command} ${subcommand}: ${value}" +} + +rotation(){ + # Internal Trackpad + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "com.apple.trackpad.rotateGesture" \ + "$1" \ + "sudo")" + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.AppleMultitouchTrackpad" \ + "TrackpadRotate" \ + "$1")" + + # External Trackpad + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.driver.AppleBluetoothMultitouch.trackpad" \ + "TrackpadRotate" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +dragging(){ + # Internal Trackpad + value="$(_mcli_defaults_yes_no_to_integer "com.apple.AppleMultitouchTrackpad" \ + "Dragging" \ + "$1")" + + # External Trackpad + value="$(_mcli_defaults_yes_no_to_integer "com.apple.driver.AppleBluetoothMultitouch.trackpad" \ + "Dragging" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +shaketoenlarge(){ + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "CGDisableCursorLocationMagnification" \ + "$1" \ + "sudo")" + + echo "${command} ${subcommand}: ${value}" +} + +mousemovement(){ + local scaling="$1" + local scrolling_speed="$2" + + # Sets the Speed With Which Mouse Movement Moves the Cursor + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "com.apple.mouse.scaling" \ + "${scaling}")" + + # Sets the Speed With Which the Mouse Scrolls Content + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "com.apple.mouse.scrolling" \ + "${scrolling_speed}")" +} + +trackpadmovement(){ + local scaling="$1" + local scrolling_speed="$2" + + # Sets the Speed With Which Trackpad Movement Moves the Cursor + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "com.apple.trackpad.scaling" \ + "${scaling}" \ + "sudo")" + + # Sets the Speed With Which the Trackpad Scrolls Content + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "com.apple.trackpad.scrolling" \ + "${scrolling_speed}" \ + "sudo")" +} + +case "${subcommand}" in + help) + help + ;; + onefingersingletap) + onefingersingletap "$@" + ;; + twofingersingletap) + twofingersingletap "$@" + ;; + threefingersingletap) + threefingersingletap "$@" + ;; + onefingerdoubletap) + onefingerdoubletap "$@" + ;; + twofingerdoubletap) + twofingerdoubletap "$@" + ;; + twofingerhorizontalswipe) + twofingerhorizontalswipe "$@" + ;; + threefingerhorizontalswipe) + threefingerhorizontalswipe "$@" + ;; + fourfingerhorizontalswipe) + fourfingerhorizontalswipe "$@" + ;; + threefingerverticalswipe) + threefingerverticalswipe "$@" + ;; + fourfingerverticalswipe) + fourfingerverticalswipe "$@" + ;; + threefingerdrag) + threefingerdrag "$@" + ;; + twofingerpinch) + twofingerpinch "$@" + ;; + fourfingerpinch) + fourfingerpinch "$@" + ;; + fourfingerpull) + fourfingerpull "$@" + ;; + fivefingerpinch) + fivefingerpinch "$@" + ;; + swipefromrightedge) + swipefromrightedge "$@" + ;; + rotation) + rotation "$@" + ;; + dragging) + dragging "$@" + ;; + shaketoenlarge) + shaketoenlarge "$@" + ;; + mousemovement) + mousemovement "$@" + ;; + trackpadmovement) + trackpadmovement "$@" + ;; + *) + help + ;; +esac + +[ -n "${subcommand}" ] && [ -n "$1" ] && killall NotificationCenter && echo "Restart your computer for this to take effect" + +# vim: ts=4 sw=4 softtabstop=4 expandtab From f42677c71f40b06bd8b0148ba67228c18fd8d67e Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sun, 8 Jan 2017 16:32:58 -0600 Subject: [PATCH 095/100] Add toggleshortcut to keyboard --- Readme.md | 19 ++++++++++--------- plugins/keyboard | 33 ++++++++++++++++++++++++--------- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/Readme.md b/Readme.md index 3366338..cb43755 100644 --- a/Readme.md +++ b/Readme.md @@ -485,19 +485,20 @@ usage: m [OPTIONS] COMMAND [help] #### Keyboard: ``` Usage: - m keyboard accentedpress [ YES | NO ] # Whether to enable press and hold to show accented characters - m keyboard spellchecking [ YES | NO ] # Whether to enable spell check indication (red squiggly lines) - m keyboard textsubstitution [ YES | NO ] # Whether to substitute quotes, dashes, spelling corrections, etc automatically - m keyboard usefunctionkeys [ YES | NO ] # Whether to use F1 function keys or alternate function keys (brightness, etc) - m keyboard inputfieldaccess [ # Specify which input fields can be tabbed through + m keyboard accentedpress [ YES | NO ] # Whether to enable press and hold to show accented characters + m keyboard spellchecking [ YES | NO ] # Whether to enable spell check indication (red squiggly lines) + m keyboard textsubstitution [ YES | NO ] # Whether to substitute quotes, dashes, spelling corrections, etc automatically + m keyboard usefunctionkeys [ YES | NO ] # Whether to use F1 function keys or alternate function keys (brightness, etc) + m keyboard inputfieldaccess [ # Specify which input fields can be tabbed through basic | allexceptdropdowns | all ] - m keyboard autodim [ YES | NO ] # Whether to automatically dim the keyboard brightness when idle - m keyboard autodimdelay x # How long to wait before dimming the keyboard brightness - m keyboard keyrepeatrate x # How quickly a held key repeats - m keyboard keyrepeatdelay x.x # How long a key needs to be held before repeating + m keyboard autodim [ YES | NO ] # Whether to automatically dim the keyboard brightness when idle + m keyboard autodimdelay x # How long to wait before dimming the keyboard brightness + m keyboard keyrepeatrate x # How quickly a held key repeats + m keyboard keyrepeatdelay x.x # How long a key needs to be held before repeating + m keyboard toggleshortcut [ ON | OFF ] # Toggle a shortcut by its ID either on or off ``` #### Launchpad: diff --git a/plugins/keyboard b/plugins/keyboard index 1591c39..378d4fe 100755 --- a/plugins/keyboard +++ b/plugins/keyboard @@ -1,5 +1,7 @@ #!/usr/bin/env bash +declare path_to_plistbuddy="/usr/libexec/PlistBuddy" + source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" @@ -11,19 +13,20 @@ declare subcommand="$1" help(){ cat<<__EOF__ Usage: - m keyboard accentedpress [ YES | NO ] # Whether to enable press and hold to show accented characters - m keyboard spellchecking [ YES | NO ] # Whether to enable spell check indication (red squiggly lines) - m keyboard textsubstitution [ YES | NO ] # Whether to substitute quotes, dashes, spelling corrections, etc automatically - m keyboard usefunctionkeys [ YES | NO ] # Whether to use F1 function keys or alternate function keys (brightness, etc) - m keyboard inputfieldaccess [ # Specify which input fields can be tabbed through + m keyboard accentedpress [ YES | NO ] # Whether to enable press and hold to show accented characters + m keyboard spellchecking [ YES | NO ] # Whether to enable spell check indication (red squiggly lines) + m keyboard textsubstitution [ YES | NO ] # Whether to substitute quotes, dashes, spelling corrections, etc automatically + m keyboard usefunctionkeys [ YES | NO ] # Whether to use F1 function keys or alternate function keys (brightness, etc) + m keyboard inputfieldaccess [ # Specify which input fields can be tabbed through basic | allexceptdropdowns | all ] - m keyboard autodim [ YES | NO ] # Whether to automatically dim the keyboard brightness when idle - m keyboard autodimdelay x # How long to wait before dimming the keyboard brightness - m keyboard keyrepeatrate x # How quickly a held key repeats - m keyboard keyrepeatdelay x.x # How long a key needs to be held before repeating + m keyboard autodim [ YES | NO ] # Whether to automatically dim the keyboard brightness when idle + m keyboard autodimdelay x # How long to wait before dimming the keyboard brightness + m keyboard keyrepeatrate x # How quickly a held key repeats + m keyboard keyrepeatdelay x.x # How long a key needs to be held before repeating + m keyboard toggleshortcut [ ON | OFF ] # Toggle a shortcut by its ID either on or off __EOF__ } @@ -132,6 +135,15 @@ keyrepeatdelay() { echo "${command} ${subcommand}: ${value}" } +toggleshortcut() { + local enabled="$(_mcli_convert_yes_no_to_boolean "$1")" + local keyboard_shortcut_id="$2" + local plist_path="/Users/$(whoami)/Library/Preferences/com.apple.symbolichotkeys.plist" + + ${path_to_plistbuddy} -c "Delete :AppleSymbolicHotKeys:${keyboard_shortcut_id}:enabled" "${plist_path}" 2> /dev/null + ${path_to_plistbuddy} -c "Add :AppleSymbolicHotKeys:${keyboard_shortcut_id}:enabled bool ${enabled}" "${plist_path}" 2> /dev/null +} + case "${subcommand}" in help) help @@ -163,6 +175,9 @@ case "${subcommand}" in keyrepeatdelay) keyrepeatdelay "$@" ;; + toggleshortcut) + toggleshortcut "$@" + ;; *) help ;; From 95a81225c6451ffa498a578157cec6f8e9e87b90 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sun, 8 Jan 2017 16:41:44 -0600 Subject: [PATCH 096/100] Add loginitems plugin --- Readme.md | 6 ++++++ plugins/loginitems | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100755 plugins/loginitems diff --git a/Readme.md b/Readme.md index cb43755..d4c2d99 100644 --- a/Readme.md +++ b/Readme.md @@ -527,6 +527,12 @@ usage: m [OPTIONS] COMMAND [help] m lock # lock session ``` +#### Login Items: +``` + Usage: + m loginitems add [ YES | NO ] # Add a login item. Optionally specifying wheither it should be hidden. +``` + #### Menubar: ``` Usage: diff --git a/plugins/loginitems b/plugins/loginitems new file mode 100755 index 0000000..1f07183 --- /dev/null +++ b/plugins/loginitems @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + +help(){ + cat<<__EOF__ + Usage: + m loginitems add [ YES | NO ] # Add a login item. Optionally specifying wheither it should be hidden. +__EOF__ +} + +add(){ + local application_path="$1" + local hidden="$(_mcli_convert_yes_no_to_boolean "$2")" + + osascript -e "tell application \"System Events\" to make login item at end with properties {path:\"${application_path}\", hidden:${hidden}}" &> /dev/null +} + +case "${subcommand}" in + help) + help + ;; + add) + add "$@" + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab From 3deb7af74c139ac877aca954b26be06d105ef055 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sun, 8 Jan 2017 19:21:43 -0600 Subject: [PATCH 097/100] Fix standby key --- plugins/filevault | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/filevault b/plugins/filevault index 1042358..bed0c8c 100755 --- a/plugins/filevault +++ b/plugins/filevault @@ -21,7 +21,8 @@ __EOF__ standbykey(){ [ -z "$1" ] && help && return - choice="$(_mcli_convert_yes_no_to_integer "$1")" + choice="$(_mcli_convert_yes_no_to_inverted_boolean "$1")" + choice="$(_mcli_convert_yes_no_to_integer "${choice}")" sudo pmset -a destroyfvkeyonstandby "${choice}" } From 758ee28ab5417b024bed84a27bce8278ab518c23 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Sun, 8 Jan 2017 19:21:54 -0600 Subject: [PATCH 098/100] Add foldersfirst to finder --- plugins/finder | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugins/finder b/plugins/finder index 5865410..c5a652f 100755 --- a/plugins/finder +++ b/plugins/finder @@ -21,6 +21,7 @@ help(){ m finder remotedsstore [ YES | NO ] # whether to allow dsstore files to be created on remote volumes m finder extensionchangewarning [ YES | NO ] # whether to show the warning when changing a file's extension m finder quittable [ YES | NO ] # whether to finder is quittable + m finder foldersfirst [ YES | NO ] # whether to show folders above all other files in finder m finder clickthroughdestroysselection [ YES | NO ] # whether, when clicking through to a finder window, the current selection is destroyed m finder stoppreviewswhenselectionchanges [ YES | NO ] # whether to stop previews when selection changes m finder stoppreviewswhenscrolling [ YES | NO ] # whether to stop previews when scrolling @@ -114,6 +115,14 @@ quittable() { echo "${command} ${subcommand}: ${value}" } +foldersfirst() { + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.finder" \ + "_FXSortFoldersFirst" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + clickthroughdestroysselection(){ value="$(_mcli_defaults_yes_no_to_boolean "com.apple.finder" \ "ClickThroughDestroysSelection" \ @@ -272,6 +281,9 @@ case "${subcommand}" in quittable) quittable "$@" ;; + foldersfirst) + foldersfirst "$@" + ;; clickthroughdestroysselection) clickthroughdestroysselection "$@" ;; From 4c938c72c80b0be88743976c58bb714664413baf Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Mon, 9 Jan 2017 00:22:28 -0600 Subject: [PATCH 099/100] Fix missing subcommand --- plugins/gatekeeper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/gatekeeper b/plugins/gatekeeper index d4ad65a..f7337db 100755 --- a/plugins/gatekeeper +++ b/plugins/gatekeeper @@ -48,7 +48,7 @@ disable(){ fi } -case $1 in +case "${subcommand}" in help) help ;; From 6c60ca1fc9cf6ff0b90205be8c6d5a988a0e1543 Mon Sep 17 00:00:00 2001 From: The Grand Design Date: Mon, 9 Jan 2017 00:25:19 -0600 Subject: [PATCH 100/100] Remove extra 'killall' --- plugins/mouse | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/mouse b/plugins/mouse index f424e8b..af4f7d3 100755 --- a/plugins/mouse +++ b/plugins/mouse @@ -600,6 +600,4 @@ case "${subcommand}" in ;; esac -[ -n "${subcommand}" ] && [ -n "$1" ] && killall NotificationCenter && echo "Restart your computer for this to take effect" - # vim: ts=4 sw=4 softtabstop=4 expandtab