diff --git a/.gitignore b/.gitignore index 1330247..90376a5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +tags *.log .DS_Store diff --git a/Readme.md b/Readme.md index 9af3b07..d4c2d99 100644 --- a/Readme.md +++ b/Readme.md @@ -45,32 +45,60 @@ usage: m [OPTIONS] COMMAND [help] COMMANDS: help + airdrop + airport + animations + appearance battery bluetooth + dashboard + datetime + debugmode + dialog dir disk + diskimages + diskutility display dns dock + filevault finder firewall + fullscreen gatekeeper + group hostname + hotcorners info - itunes + itunes + keyboard + launchpad + locale + location lock - ntp - printer + missioncontrol + mouse network nosleep notification + ntp + power + printer restart safeboot + screencapture screensaver + scrolling service shutdown sleep + sound + spotlight + system + timemachine timezone + tooltip trash update user @@ -78,7 +106,82 @@ usage: m [OPTIONS] COMMAND [help] vpn wallpaper wifi + windows + +``` + +#### Airdrop: +``` + Usage: + m airdrop onlywifi [ YES | NO ] # Whether to allow all interfaces (or only wifi) to be airdropped to + + Examples: + m airdrop onlywifi YES +``` +#### Airport: +``` + Usage: + m airport disconnectonlogout [ YES | NO ] # whether to disconnect from wifi when logging out + 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 | + Ranked | + Recent | + Strongest + ] + 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 + # networks + m airport securetogglepower [ YES | NO ] # whether a password is required to turn + # wi-fi on or off +``` + +#### Animations: +``` + 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 + 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 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 highlights + 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 + ] + + Examples: + m appearance antialiasthreshold 8 # Only a font size of 8pt or above will be anti-aliased ``` #### Battery: @@ -91,140 +194,219 @@ 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 ``` - -#### Disk: +#### Dashboard: +``` + Usage: + m dashboard enable # Enable the dashboard + m dashboard disable # Disable the dashboard ``` - usage: m disk [ ls | list | info | fs | filesystems | ejectall | verify | repair | help ] - - 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 +#### Date and Time: +``` + 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 + 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 +``` - m disk info /dev/disk0 # display information +#### Debug Mode: +``` + Usage: + m debugmode enable # whether extra debugging options should be exposed for various applications + m debugmode disable +``` - m disk ejectall # eject all mountable volumes +#### Dialog: +``` + Usage: + m dialogs autoexpand [ YES | NO ] # Whether print, save and other dialogs auto-expand +``` - m disk verify volume /Volume/MyVol # verify volume - m disk verify disk /dev/disk0 # verify disk +#### Dir: +``` + Usage: + m dir tree # tree view of folders in the current path + m dir tree /path # tree view of folders in a specific path - m disk repair volume /Volume/MyVol # repair volume - m disk repair disk /dev/disk0 # repair disk + 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 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 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 disk reformat /Volumes/myvol # reformat a volume - m disk rename CURRENTNAME NEWNAME # rename a volume + 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 ``` -#### Display: +#### Disk: ``` - usage: m display [ status | help ] + Usage: + m disk ls # list disks + m disk list # list disks + m disk list /dev/disk0 # list a specific disk - Example: - m display status # status of displays - m display help # show usage -``` + m disk fs # list available filesystems for formatting + m disk filesystems # list available filesystems for formatting -#### Dns: -``` - usage: m dns [ flush | help ] + m disk info /dev/disk0 # display information - Examples: - m dns flush # flushes local DNS + m disk ejectall # eject all mountable volumes -``` + m disk verify volume /Volume/MyVol # verify volume + m disk verify disk /dev/disk0 # verify disk -#### Dock: -``` - usage: m dock [ showdelay | autohide | magnification | position | addblankspace | addrecentitems | prune | help ] + m disk repair volume /Volume/MyVol # repair volume + m disk repair disk /dev/disk0 # repair disk - Examples: - 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 - m dock magnification YES # Turn magnification on - m dock magnification NO # Turn magnification off - 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 + 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 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 ``` -#### Dir: +#### Disk Images: +``` + Usage: + m diskimages automount [ YES | NO ] # Whether to automount disk images + m diskimages verification [ YES | NO ] # Whether to verify disk image integrity ``` - 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 +#### Disk Utility: +``` + 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 +``` - 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 +#### Display: +``` + 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 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 +#### Dns: +``` + Usage: + m dns flush # flushes local DNS - m dir size # calculate current folder size - m dir size /path # calculate folder size in a specific path +``` +#### 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) +``` + +#### File Vault: +``` + Usage: + 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: ``` - 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 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 + 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: ``` - 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 + Usage: + 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 +``` +#### Full Screen: +``` + 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 ``` #### Gatekeeper: ``` - usage: m gatekeeper [ status | list | ls | enable | disable | create | help ] - - Examples: + Usage: m gatekeeper status # gatekeeper status m gatekeeper list # list rules @@ -240,9 +422,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 @@ -255,221 +435,402 @@ 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 # set a new hostname (computername, hostname, localhostname, netbiosname) +``` - 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 ] - - Examples: + Usage: m info # print macOS operating system version information ``` -### Itunes: +### iTunes: +``` + Usage: + 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 ``` - 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 +#### 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 + 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 toggleshortcut [ ON | OFF ] # Toggle a shortcut by its ID either on or off ``` -#### Lock: +#### Launchpad: +``` + Usage: + m launchpad prune # Remove all items from launchpad ``` - usage: m lock [ help ] - Examples: +#### Locale: +``` + 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 enable # Enable the location service + m location diable # Disable the location service +``` + +#### Lock: +``` + Usage: m lock # lock session ``` -#### Ntp: +#### Login Items: +``` + Usage: + m loginitems add [ YES | NO ] # Add a login item. Optionally specifying wheither it should be hidden. ``` - 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 +#### Menubar: +``` + 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 ``` -#### Printer: +#### Mission Control: +``` + Usage: + m missioncontrol dashboardvisible [ YES | NO ] # + m missioncontrol groupwindowsbyapp [ YES | NO ] # + m missioncontrol animationspeed x.x # ``` - usage: m printer [ settings | name | queue | drivers | web | 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 +#### 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 ] -#### Network: + mousemovement x.x x.x + trackpadmovement x.x x.x ``` - 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 +#### Network: +``` + Usage: + 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: ``` - 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 ] + 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 # 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 # set network time server 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 ntp set timehost1.net.sap.corp +``` +#### Power: ``` + Usage: + Every command that has two entries requires both the battery setting and the + plugged setting (in that order). -#### Restart: + 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 + 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) ``` - usage: m restart [ -f | --force | help ] - Examples: - m restart # restart computer (needs confirmation) - m restart -f # restart computer (without confirmation) +#### Printer: +``` + Usage: + 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 ``` -#### Safeboot: +#### Restart: +``` + Usage: + m restart # restart computer (needs confirmation) + m restart --force # restart computer (without confirmation) ``` - usage: m safeboot [ status | enable | disable | help ] - Examples: +#### Safeboot: +``` + Usage: m safeboot status # get the boot args m safeboot enable # enable safe boot m safeboot disable # disable safeboot ``` -#### Screensaver: +#### Screen Capture: +``` + Usage: + 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 ``` - usage: m screensaver [ status | askforpassword | help ] - Examples: - m screensaver # launch screensaver +#### Screensaver: +``` + 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 +``` - 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 +#### Scrolling: +``` + 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 + 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 ] - - - 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 com.apple.sessionlogoutd # start a service - m service stop com.apple.sessionlogoutd # stop a service + m service start # start a service + m service stop # stop a service - m service load com.apple.sessionlogoutd # load a service - m service unload com.apple.sessionlogoutd # unload a service + m service load # load a service + m service unload # 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 [ 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 [ YES | NO ] # Whether to enable the Cmd-Space shortcuts +``` + +#### System: +``` + 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 + 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 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 ] + 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 ``` -#### Trash: +#### Tooltips: +``` + 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 # The size of the font in the tooltip ``` - usage: m trash [ status | clean | help ] - Examples: - m trash status # get trash info - m trash clean # clean trash +#### Trash: +``` + Usage: + m trash status # get trash info + m trash clean # clean trash + m trash warn [ YES | NO ] # warn when emptying trash ``` #### Update ``` - usage: m update [ list | install | help ] + Usage: + m update list # list available 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 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 # 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 | help ] - - Examples: - m user ls # list users - m user info demouser # display user information + Usage: + 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 + 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 + m user loginmessage "Your message" # the custom text to show on the login screen (enter nothing to remove message) ``` #### Volume: @@ -490,16 +851,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 @@ -508,17 +867,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) @@ -530,6 +888,12 @@ usage: m [OPTIONS] COMMAND [help] ``` +#### Windows: +``` + Usage: + m windows miniturizeondoubleclick [ YES | NO ] # Whether to miniturize windows on a double click of the title bar +``` + ## Contributing 1. Fork it! diff --git a/lib/converters.sh b/lib/converters.sh new file mode 100644 index 0000000..43f4645 --- /dev/null +++ b/lib/converters.sh @@ -0,0 +1,180 @@ +_mcli_convert_yes_no_to_boolean() { + local choice="$1" + + case "${choice}" in + "") + echo "" + ;; + 1|[yY][eE][sS]|[oO][nN]|[tT][rR][rU][eE]) + echo "true" + ;; + 0|[nN][oO]|[oO][fF][fF]|[fF][aA][lL][sS][eE]) + echo "false" + ;; + *) + echo "ERROR" + ;; + esac +} + +_mcli_convert_yes_no_to_on_off() { + local choice="$1" + + case "${choice}" in + "") + echo "" + ;; + 1|[yY][eE][sS]|[oO][nN]|[tT][rR][rU][eE]) + echo "on" + ;; + 0|[nN][oO]|[oO][fF][fF]|[fF][aA][lL][sS][eE]) + echo "off" + ;; + *) + echo "ERROR" + ;; + esac +} + +_mcli_convert_yes_no_to_enabled_disabled() { + local choice="$1" + + case "${choice}" in + "") + echo "" + ;; + 1|[yY][eE][sS]|[oO][nN]|[tT][rR][rU][eE]) + echo "enabled" + ;; + 0|[nN][oO]|[oO][fF][fF]|[fF][aA][lL][sS][eE]) + echo "disabled" + ;; + *) + echo "ERROR" + ;; + 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" + + if eval "${command} &> /dev/null" ; then + echo "enabled" + else + echo "disabled" + fi +} + +_mcli_convert_yes_no_to_load_unload() { + local choice="$1" + + case "${choice}" in + "") + echo "" + ;; + 1|[yY][eE][sS]|[oO][nN]|[tT][rR][rU][eE]) + echo "load" + ;; + 0|[nN][oO]|[oO][fF][fF]|[fF][aA][lL][sS][eE]) + echo "unload" + ;; + *) + echo "ERROR" + ;; + esac +} + +_mcli_convert_yes_no_to_inverted_boolean() { + local choice="$1" + + case "${choice}" in + "") + echo "" + ;; + 1|[yY][eE][sS]|[oO][nN]|[tT][rR][rU][eE]) + echo "false" + ;; + 0|[nN][oO]|[oO][fF][fF]|[fF][aA][lL][sS][eE]) + echo "true" + ;; + *) + echo "ERROR" + ;; + esac +} + +_mcli_convert_yes_no_to_yes_no() { + local choice="$1" + + case "${choice}" in + "") + echo "" + ;; + 1|[yY][eE][sS]|[oO][nN]|[tT][rR][rU][eE]) + echo "YES" + ;; + 0|[nN][oO]|[oO][fF][fF]|[fF][aA][lL][sS][eE]) + echo "NO" + ;; + *) + echo "ERROR" + ;; + esac +} + +_mcli_convert_yes_no_to_integer() { + local choice="$1" + + case "${choice}" in + "") + echo "" + ;; + 1|[yY][eE][sS]|[oO][nN]|[tT][rR][rU][eE]) + echo "1" + ;; + 0|[nN][oO]|[oO][fF][fF]|[fF][aA][lL][sS][eE]) + echo "0" + ;; + *) + echo "ERROR" + ;; + esac +} + +_mcli_convert_number_to_number() { + local choice="$1" + + case "${choice}" in + "") + echo "" + ;; + [0-9]*[.][0-9]*) + echo "${choice}" + ;; + [0-9]*) + echo "${choice}" + ;; + *) + echo "ERROR" + ;; + esac +} diff --git a/lib/defaults.sh b/lib/defaults.sh new file mode 100644 index 0000000..984ba27 --- /dev/null +++ b/lib/defaults.sh @@ -0,0 +1,137 @@ +_mcli_read() { + local domain="$1" + local key="$2" + local sudo="$3" + + [ -n "${domain}" ] && [ -n "${key}" ] || return 1 + [[ -n "${sudo}" ]] && sudo="sudo" + + ${sudo} defaults read "${domain}" "${key}" 2> /dev/null +} + +_mcli_read_boolean_as_yes_no() { + local value="$(_mcli_read "$@")" + + case "${value}" in + 0|[nN][oO]|[oO][fF][fF]|[fF][aA][lL][sS][eE]) + echo "NO" + ;; + 1|[yY][eE][sS]|[oO][nN]|[tT][rR][rU][eE]) + echo "YES" + ;; + esac +} + +_mcli_read_number() { + local value="$(_mcli_read "$@")" + + echo "${value}" +} + +_mcli_read_string() { + local value="$(_mcli_read "$@")" + + echo "${value}" +} + +_mcli_read_inverted_boolean() { + local value="$(_mcli_read_boolean_as_yes_no "$@")" + + if [[ "${value}" == "YES" ]]; then + echo "NO" + 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" "$@" +} + +_mcli_defaults_yes_no_to_boolean() { + _mcli_defaults_yes_no_to_type "boolean" "convert_yes_no_to_boolean" "$@" +} + +_mcli_defaults_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() { + local domain="$1" + local key="$2" + local new_value="$3" + local sudo="$4" + local transformed="$(_mcli_convert_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_number "${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 "${new_value}" + fi + + _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 +} + +# shellcheck disable=SC2086 +_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 + + if [[ "${transformed}" != "ERROR" ]]; then + _mcli_read_boolean_as_yes_no "${domain}" "${key}" "${sudo}" + else + echo "ERROR" + fi +} 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/airdrop b/plugins/airdrop new file mode 100755 index 0000000..0aaacef --- /dev/null +++ b/plugins/airdrop @@ -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 airdrop onlywifi [ YES | NO ] # Whether to allow all interfaces (or only wifi) to be airdropped to + + Examples: + m airdrop onlywifi YES +__EOF__ +} + +onlywifi(){ + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.NetworkBrowser" \ + "BrowseAllInterfaces" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +case "${subcommand}" in + help) + help + ;; + onlywifi) + onlywifi $@ + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab diff --git a/plugins/airport b/plugins/airport new file mode 100755 index 0000000..2c95d45 --- /dev/null +++ b/plugins/airport @@ -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 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__ + Usage: + m airport disconnectonlogout [ YES | NO ] # whether to disconnect from wifi when logging out + 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 | + Ranked | + Recent | + Strongest + ] + 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 + # networks + m airport securetogglepower [ YES | NO ] # whether a password is required to turn + # wi-fi on or off +__EOF__ +} + +disconnectonlogout(){ + local choice="$(_mcli_convert_yes_no_to_yes_no "$1")" + + sudo "${path_to_airport_binary}" prefs DisconnectOnLogout="${choice}" + + value="$(sudo "${path_to_airport_binary}" prefs DisconnectOnLogout)" + + echo "${command} ${subcommand}: ${value}" +} + +nonpreferrednetworks(){ + [ -n "$1" ] && sudo "${path_to_airport_binary}" prefs JoinModeFallback="$1" + + value="$(sudo "${path_to_airport_binary}" prefs JoinModeFallback)" + + echo "${command} ${subcommand}: ${value}" +} + +preferrednetworks(){ + [ -n "$1" ] && sudo "${path_to_airport_binary}" prefs JoinMode="$1" + + value="$(sudo "${path_to_airport_binary}" prefs JoinMode)" + + echo "${command} ${subcommand}: ${value}" +} + +rememberrecents(){ + local choice="$(_mcli_convert_yes_no_to_yes_no "$1")" + + sudo "${path_to_airport_binary}" prefs RememberRecentNetworks="${choice}" + + value="$(sudo "${path_to_airport_binary}" prefs RememberRecentNetworks)" + + echo "${command} ${subcommand}: ${value}" +} + +secureadhocnetworks(){ + local choice="$(_mcli_convert_yes_no_to_yes_no "$1")" + + sudo "${path_to_airport_binary}" prefs RequireAdminIBSS="${choice}" + + value="$(sudo "${path_to_airport_binary}" prefs RequireAdminIBSS)" + + echo "${command} ${subcommand}: ${value}" +} + +securechangenetworks(){ + local choice="$(_mcli_convert_yes_no_to_yes_no "$1")" + + sudo "${path_to_airport_binary}" prefs RequireAdminNetworkChange="${choice}" + + value="$(sudo "${path_to_airport_binary}" prefs RequireAdminNetworkChange)" + + echo "${command} ${subcommand}: ${value}" +} + +securetogglepower(){ + local choice="$(_mcli_convert_yes_no_to_yes_no "$1")" + + sudo "${path_to_airport_binary}" prefs RequireAdminPowerToggle="${choice}" + + value="$(sudo "${path_to_airport_binary}" prefs RequireAdminPowerToggle)" + + echo "${command} ${subcommand}: ${value}" +} + +case "${subcommand}" in + help) + help + ;; + disconnectonlogout) + disconnectonlogout "$@" + ;; + nonpreferrednetworks) + nonpreferrednetworks "$@" + ;; + preferrednetworks) + preferrednetworks "$@" + ;; + rememberrecents) + rememberrecents "$@" + ;; + secureadhocnetworks) + secureadhocnetworks "$@" + ;; + securechangenetworks) + securechangenetworks "$@" + ;; + securetogglepower) + securetogglepower "$@" + ;; + *) + help + ;; +esac diff --git a/plugins/animations b/plugins/animations new file mode 100755 index 0000000..c887ddb --- /dev/null +++ b/plugins/animations @@ -0,0 +1,125 @@ +#!/usr/bin/env bash + +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + +help(){ + cat<<__EOF__ + 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 + 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 "$@" + ;; + finder) + finder "$@" + ;; + fullscreen) + fullscreen "$@" + ;; + windows) + windows "$@" + ;; + quicklook) + quicklook "$@" + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab diff --git a/plugins/appearance b/plugins/appearance new file mode 100755 index 0000000..3a11ba6 --- /dev/null +++ b/plugins/appearance @@ -0,0 +1,256 @@ +#!/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 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 highlights + 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 + ] + + Examples: + m appearance antialiasthreshold 8 # Only a font size of 8pt or above will be anti-aliased +__EOF__ +} + +darkmode(){ + local choice="$(_mcli_convert_yes_no_to_boolean "$1")" + local mode="$(if [[ "${choice}" == "true" ]]; then echo "Dark"; else echo "Light"; fi)" + + value="$(_mcli_defaults_string "NSGlobalDomain" \ + "AppleInterfaceStyle" \ + "${mode}")" + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "NSFullScreenDarkMenu" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +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 + + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "NSTableViewDefaultSizeMode" \ + "${size}")" + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "NSNavPanelIconViewIconSizeForOpenMode" \ + "${size}")" + + echo "${command} ${subcommand}: ${value}" +} + +maincolor(){ + local color + + case $1 in + blue) + color="1" + ;; + graphite) + color="6" + ;; + esac + + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "AppleAquaColorVariant" \ + "${color}")" + + echo "${command} ${subcommand}: ${value}" +} + +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";; + esac + + value="$(_mcli_defaults_string "NSGlobalDomain" \ + "AppleHighlightColor" \ + "${color}")" + value="$(_mcli_defaults_string "com.apple.systempreferences" \ + "AppleOtherHighlightColor" \ + "${color}")" + + echo "${command} ${subcommand}: ${value}" +} + +case "${subcommand}" in + help) + help + ;; + darkmode) + darkmode "$@" + ;; + transparency) + transparency "$@" + ;; + antialiasthreshold) + antialiasthreshold "$@" + ;; + sidebariconsize) + sidebariconsize "$@" + ;; + maincolor) + maincolor "$@" + ;; + highlightcolor) + highlightcolor "$@" + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab 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 new file mode 100755 index 0000000..13ef791 --- /dev/null +++ b/plugins/dashboard @@ -0,0 +1,64 @@ +#!/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 # Enable the dashboard + m dashboard disable # Disable the dashboard +__EOF__ +} + +enable(){ + value="$(_mcli_defaults_yes_no_to_inverted_boolean "com.apple.dashboard" \ + "mcx-disabled" \ + "YES")" + + _mcli_toggle_dashboard_keyboard_shortcuts "${value}" + + echo "${command} ${subcommand}: ${value}" +} + +disable(){ + value="$(_mcli_defaults_yes_no_to_inverted_boolean "com.apple.dashboard" \ + "mcx-disabled" \ + "NO")" + + _mcli_toggle_dashboard_keyboard_shortcuts "${value}" + + echo "${command} enable: ${value}" +} + +case "${subcommand}" in + help) + help + ;; + enable) + enable "$@" + ;; + disable) + disable "$@" + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab diff --git a/plugins/datetime b/plugins/datetime new file mode 100755 index 0000000..f154d7f --- /dev/null +++ b/plugins/datetime @@ -0,0 +1,87 @@ +#!/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 [ 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 + + 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" + + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "AppleICUForce24HourTime" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +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 diff --git a/plugins/debugmode b/plugins/debugmode new file mode 100755 index 0000000..e824cad --- /dev/null +++ b/plugins/debugmode @@ -0,0 +1,74 @@ +#!/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 debugmode enable # whether extra debugging options should be exposed for various applications + m debugmode disable +__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 "${subcommand}" in + help) + help + ;; + enable) + _toggle_debug_mode "true" + ;; + disable) + _toggle_debug_mode "false" + ;; + *) + help + ;; +esac diff --git a/plugins/dialogs b/plugins/dialogs new file mode 100755 index 0000000..e70ca40 --- /dev/null +++ b/plugins/dialogs @@ -0,0 +1,47 @@ +#!/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 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 diff --git a/plugins/dir b/plugins/dir index 198f00e..a641273 100755 --- a/plugins/dir +++ b/plugins/dir @@ -4,13 +4,19 @@ # * 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 + Usage: + 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,23 +24,26 @@ 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__ } 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 } @@ -83,24 +92,37 @@ delete(){ esac } +show(){ + [ -z "$1" ] && help && return + chflags nohidden "$1" +} + +hide(){ + [ -z "$1" ] && help && return + + chflags hidden "$1" +} -case "$1" in +case "${subcommand}" in help) help ;; tree) - shift tree_dirs "$@" ;; delete) - shift; delete "$@" ;; size) - shift folder_size "$@" ;; + show) + show "$@" + ;; + hide) + hide "$@" + ;; *) help ;; diff --git a/plugins/disk b/plugins/disk index 5be36d5..a31d582 100755 --- a/plugins/disk +++ b/plugins/disk @@ -1,32 +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 disk [ ls | list | info | fs | filesystems | ejectall | verify | repair | 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 autoplay [ YES | NO ] # whether the system should open a window when a drive is inserted __EOF__ } @@ -107,46 +116,92 @@ rename(){ } -case $1 in +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" \ + "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}" +} + +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 ;; 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 "$@" + ;; + autoplay) + autoplay "$@" + ;; *) help ;; diff --git a/plugins/diskimages b/plugins/diskimages new file mode 100755 index 0000000..310328c --- /dev/null +++ b/plugins/diskimages @@ -0,0 +1,70 @@ +#!/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 [ 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 diff --git a/plugins/diskutility b/plugins/diskutility new file mode 100755 index 0000000..5a7676b --- /dev/null +++ b/plugins/diskutility @@ -0,0 +1,62 @@ +#!/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 [ 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 diff --git a/plugins/display b/plugins/display index 85073c0..73afd73 100755 --- a/plugins/display +++ b/plugins/display @@ -1,12 +1,19 @@ #!/usr/bin/env bash +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__ - usage: m display [ status | help ] - - Example: - m display status # status of displays - m display help # show usage + 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,13 +21,25 @@ display_status(){ system_profiler SPDisplaysDataType } -case $1 in +autobrightness() { + value="$(_mcli_defaults_yes_no_to_integer "${path_to_plist}" \ + "Automatic Display Enabled" \ + "$1" \ + "sudo")" + + echo "${command} ${subcommand}: ${value}" +} + +case "${subcommand}" in help) help ;; status) display_status ;; + autobrightness) + autobrightness "$@" + ;; *) help ;; 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 366a84f..3711e16 100755 --- a/plugins/dock +++ b/plugins/dock @@ -1,99 +1,178 @@ #!/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 dock [ showdelay | autohide | magnification | position | addblankspace | addrecentitems | prune | help ] - - Examples: - 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 - m dock magnification YES # Turn magnification on - m dock magnification NO # Turn magnification off - 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__ } -show_delay(){ - case $1 in - [0-9][.][0-9]) - echo "New Auto-Hide time: "$1 - defaults write com.apple.dock autohide-time-modifier -float $1 - ;; - [0-9]) - echo "New Auto-Hide time: "$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)" - exit 0 - ;; - esac - killall Dock +enable(){ + auto_hide "NO" + auto_hide_delay 0.25 +} + +disable(){ + auto_hide "YES" + auto_hide_delay 999999 +} + +active_indicators(){ + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ + "show-process-indicators" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +bounce_on_app_activity(){ + value="$(_mcli_defaults_yes_no_to_inverted_boolean "com.apple.dock" \ + "no-bouncing" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +bounce_on_app_launch(){ + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ + "launchanim" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +auto_hide_speed(){ + value="$(_mcli_defaults_number "com.apple.dock" \ + "autohide-time-modifier" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +auto_hide_delay(){ + value="$(_mcli_defaults_number "com.apple.dock" \ + "autohide-delay" \ + "$1")" + + echo "${command} ${subcommand}: ${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 + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ + "autohide" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +full_screen_delay(){ + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ + "autohide-fullscreen-delayed" \ + "$1")" + + echo "${command} ${subcommand}: ${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")" + + echo "${command} ${subcommand}: ${value}" +} + +hidden_app_dimming(){ + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ + "showhidden" \ + "$1")" + + echo "${command} ${subcommand}: ${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 + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ + "magnification" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +magnification_size(){ + value="$(_mcli_defaults_number "com.apple.dock" \ + "largesize" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +icon_size(){ + value="$(_mcli_defaults_number "com.apple.dock" \ + "tilesize" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +only_show_running(){ + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.dock" \ + "static-only" \ + "$1")" + + echo "${command} ${subcommand}: ${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 + + value="$(_mcli_read "com.apple.dock" "orientation")" + + echo "${command} ${subcommand}: ${value}" } add_blank_space(){ @@ -108,42 +187,80 @@ add_recent_items(){ killall Dock } +# shellcheck disable=SC2086 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 } -case $1 in +case "${subcommand}" in help) help ;; + enable) + enable + ;; + disable) + disable + ;; + activeindicators) + active_indicators "$@" + ;; + bounceonappactivity) + bounce_on_app_activity "$@" + ;; + bounceonapplaunch) + bounce_on_app_launch "$@" + ;; showdelay) - shift - show_delay $@ + auto_hide_delay "$@" + ;; + autohidedelay) + auto_hide_delay "$@" + ;; + autohidespeed) + auto_hide_speed "$@" ;; autohide) - shift - auto_hide $@ + auto_hide "$@" + ;; + fullscreendelay) + full_screen_delay "$@" + ;; + itunesnotifications) + itunes_notifications "$@" ;; magnification) - shift - magnify $@ + magnify "$@" + ;; + magnificationsize) + magnification_size "$@" + ;; + hiddenappdimming) + hidden_app_dimming "$@" + ;; + iconsize) + icon_size "$@" + ;; + onlyshowrunning) + only_show_running "$@" ;; position) - shift - dock_position $@ + dock_position "$@" ;; addblankspace) - shift add_blank_space ;; addrecentitems) - shift add_recent_items ;; prune) - shift prune ;; *) @@ -151,4 +268,6 @@ case $1 in ;; esac +[ -n "${subcommand}" ] && [ -n "$1" ] && killall Dock + # vim: ts=4 sw=4 softtabstop=4 expandtab diff --git a/plugins/filevault b/plugins/filevault new file mode 100755 index 0000000..bed0c8c --- /dev/null +++ b/plugins/filevault @@ -0,0 +1,51 @@ +#!/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 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(){ + [ -z "$1" ] && help && return + + choice="$(_mcli_convert_yes_no_to_inverted_boolean "$1")" + choice="$(_mcli_convert_yes_no_to_integer "${choice}")" + + sudo pmset -a destroyfvkeyonstandby "${choice}" +} + +case "${subcommand}" in + help) + help + ;; + status) + sudo fdesetup status "$@" + ;; + enable) + sudo fdesetup enable "$@" + ;; + disable) + sudo fdesetup disable "$@" + ;; + standbykey) + standbykey "$@" + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab diff --git a/plugins/finder b/plugins/finder index 74841e3..c5a652f 100755 --- a/plugins/finder +++ b/plugins/finder @@ -1,136 +1,324 @@ #!/usr/bin/env bash -# TODO: add more functionalities +declare path_to_plistbuddy="/usr/libexec/PlistBuddy" -help(){ - cat<<__EOF__ - usage: m finder [ showhiddenfiles | showfileextensions | showdesktop | help ] +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" - Examples: - m finder showhiddenfiles # get the current status - m finder showhiddenfiles YES # show hidden files - m finder showhiddenfiles NO # don't show hidden files +[ $# -gt 0 ] && shift - 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 +help(){ + cat<<__EOF__ + 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 + 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 + 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 + ] - m finder showdesktop # get the current desktop status - m finder showdesktop YES # enable the desktop - m finder showdesktop NO # disable the desktop __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 + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.finder" \ + "AppleShowAllFiles" \ + "$1")" + + echo "${command} ${subcommand}: ${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 + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "AppleShowAllExtensions" \ + "$1")" + + echo "${command} ${subcommand}: ${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" - ;; + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.finder" \ + "CreateDesktop" \ + "$1")" + + 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")" + + 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 +} + +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}" +} + +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" \ + "$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")" + + 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() { + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.finder" \ + "ShowRecentTags" \ + "$1")" + + 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" + + case "$1" in + relative) + mode="true";; + absolute) + mode="false";; + *) + mode="$1";; esac - killall Finder + + $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_number "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 $1 in +case "${subcommand}" in help) help ;; showhiddenfiles) - shift hidden_files "$@" ;; showextensions) - shift file_extensions "$@" ;; showdesktop) - shift desktop "$@" ;; + statusbar) + statusbar "$@" + ;; + posixtitlepath) + posixtitlepath "$@" + ;; + remotedsstore) + remotedsstore "$@" + ;; + extensionchangewarning) + extensionchangewarning "$@" + ;; + quittable) + quittable "$@" + ;; + foldersfirst) + foldersfirst "$@" + ;; + clickthroughdestroysselection) + clickthroughdestroysselection "$@" + ;; + stoppreviewswhenselectionchanges) + stoppreviewswhenselectionchanges "$@" + ;; + stoppreviewswhenscrolling) + stoppreviewswhenscrolling "$@" + ;; + infopanesexpanded) + infopanesexpanded "$@" + ;; + showrecenttags) + showrecenttags "$@" + ;; + hidequicklookondeactivate) + hidequicklookondeactivate "$@" + ;; + springing) + springing "$@" + ;; + minimumplayablepreviewsize) + minimumplayablepreviewsize "$@" + ;; + datetype) + datetype "$@" + ;; + defaultlocation) + defaultlocation "$@" + ;; *) help ;; esac +[ -n "${subcommand}" ] && [ -n "$1" ] && killall Finder + # vim: ts=4 sw=4 softtabstop=4 expandtab diff --git a/plugins/firewall b/plugins/firewall index 52e2da6..7390fd3 100755 --- a/plugins/firewall +++ b/plugins/firewall @@ -1,23 +1,30 @@ #!/usr/bin/env bash -help(){ - cat<<__EOF__ - usage: m firewall [ status | enable | disable | list | add | remove | help ] +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" - 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 +declare command="$(basename "$0")" +declare subcommand="$1" +[ $# -gt 0 ] && shift + +help(){ + cat<<__EOF__ + Usage: + 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 +case "${subcommand}" in help) help ;; @@ -30,16 +37,52 @@ case $1 in disable) sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off ;; + 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 ;; 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 diff --git a/plugins/fullscreen b/plugins/fullscreen new file mode 100755 index 0000000..b435dd1 --- /dev/null +++ b/plugins/fullscreen @@ -0,0 +1,66 @@ +#!/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 [ 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 diff --git a/plugins/gatekeeper b/plugins/gatekeeper index 6eee0c1..f7337db 100755 --- a/plugins/gatekeeper +++ b/plugins/gatekeeper @@ -2,11 +2,14 @@ # TODO: add more functionalities +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + 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 @@ -45,7 +48,7 @@ disable(){ fi } -case $1 in +case "${subcommand}" in help) help ;; @@ -53,15 +56,12 @@ case $1 in spctl --status ;; list|ls) - shift gk_list "$*" ;; enable) - shift enable "$*" ;; disable) - shift disable "$*" ;; *) 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 763963e..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__ } @@ -19,16 +15,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}'" } diff --git a/plugins/hotcorners b/plugins/hotcorners new file mode 100755 index 0000000..ab57fc4 --- /dev/null +++ b/plugins/hotcorners @@ -0,0 +1,117 @@ +#!/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 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 + + [ -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}" +} + +case "${subcommand}" in + help) + help + ;; + set) + set "$@" + ;; + *) + help + ;; +esac + +[ -n "${subcommand}" ] && [ -n "$1" ] && killall Dock + +# vim: ts=4 sw=4 softtabstop=4 expandtab 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 161a8c4..f7025a9 100755 --- a/plugins/itunes +++ b/plugins/itunes @@ -1,29 +1,59 @@ #!/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 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 + Usage: + 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__ } -case $1 in +autobackup(){ + value="$(_mcli_defaults_yes_no_to_inverted_boolean "com.apple.iTunes" \ + "AutomaticDeviceBackupsDisabled" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +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 +} + +case "${subcommand}" in help) help ;; + autobackup) + autobackup "$@" + ;; + mediakeys) + mediakeys "$@" + ;; status) state=`osascript -e 'tell application "iTunes" to player state as string'` echo "iTunes is currently $state." diff --git a/plugins/keyboard b/plugins/keyboard new file mode 100755 index 0000000..378d4fe --- /dev/null +++ b/plugins/keyboard @@ -0,0 +1,186 @@ +#!/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 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 toggleshortcut [ ON | OFF ] # Toggle a shortcut by its ID either on or off +__EOF__ +} + +accentedpress() { + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "ApplePressAndHoldEnabled" \ + "$1")" + + echo "${command} ${subcommand}: ${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 "${command} ${subcommand}: ${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 "${command} ${subcommand}: ${value}" +} + +usefunctionkeys() { + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "com.apple.keyboard.fnState" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +inputfieldaccess() { + local mode + + case "$1" in + all) + mode="3" + ;; + allexceptdropdowns) + mode="2" + ;; + basic) + mode="1" + ;; + esac + + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "AppleKeyboardUIMode" \ + "${mode}")" + + echo "${command} ${subcommand}: ${value}" +} + +autodim() { + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.iokit.AmbientLightSensor" \ + "Automatic Keyboard Enabled" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +autodimdelay() { + value="$(_mcli_defaults_number "com.apple.iokit.AmbientLightSensor" \ + "Keyboard Dim Time" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +keyrepeatrate() { + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "KeyRepeat" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +keyrepeatdelay() { + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "InitialKeyRepeat" \ + "$1")" + + 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 + ;; + accentedpress) + accentedpress "$@" + ;; + spellchecking) + spellchecking "$@" + ;; + textsubstitution) + textsubstitution "$@" + ;; + usefunctionkeys) + usefunctionkeys "$@" + ;; + inputfieldaccess) + inputfieldaccess "$@" + ;; + autodim) + autodim "$@" + ;; + autodimdelay) + autodimdelay "$@" + ;; + keyrepeatrate) + keyrepeatrate "$@" + ;; + keyrepeatdelay) + keyrepeatdelay "$@" + ;; + toggleshortcut) + toggleshortcut "$@" + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab diff --git a/plugins/launchpad b/plugins/launchpad new file mode 100755 index 0000000..2d55a61 --- /dev/null +++ b/plugins/launchpad @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + +help(){ + cat<<__EOF__ + Usage: + 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 diff --git a/plugins/locale b/plugins/locale new file mode 100755 index 0000000..4eb64cb --- /dev/null +++ b/plugins/locale @@ -0,0 +1,46 @@ +#!/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 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 diff --git a/plugins/location b/plugins/location new file mode 100755 index 0000000..491a544 --- /dev/null +++ b/plugins/location @@ -0,0 +1,58 @@ +#!/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 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 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 diff --git a/plugins/menubar b/plugins/menubar new file mode 100755 index 0000000..02c8731 --- /dev/null +++ b/plugins/menubar @@ -0,0 +1,51 @@ +#!/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 [ 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 diff --git a/plugins/missioncontrol b/plugins/missioncontrol new file mode 100755 index 0000000..17b766e --- /dev/null +++ b/plugins/missioncontrol @@ -0,0 +1,67 @@ +#!/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 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 diff --git a/plugins/mouse b/plugins/mouse new file mode 100755 index 0000000..af4f7d3 --- /dev/null +++ b/plugins/mouse @@ -0,0 +1,603 @@ +#!/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 + +# vim: ts=4 sw=4 softtabstop=4 expandtab diff --git a/plugins/network b/plugins/network index 879f7e7..7aadf22 100755 --- a/plugins/network +++ b/plugins/network @@ -1,17 +1,25 @@ #!/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 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 + Usage: + 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__ } @@ -28,6 +36,43 @@ 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 + + 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}" + fi + + sudo pmset -g | grep womp +} + +guestaccess(){ + value="$(_mcli_defaults_yes_no_to_boolean "/Library/Preferences/com.apple.AppleFileServer" \ + "guestAccess" \ + "$1" \ + "sudo")" + value="$(_mcli_defaults_yes_no_to_boolean "/Library/Preferences/com.apple.smb.server" \ + "AllowGuestAccess" \ + "$1" \ + "sudo")" + + echo "${command} ${subcommand}: ${value}" +} location(){ case $1 in @@ -53,9 +98,7 @@ location(){ esac } - - -case $1 in +case "${subcommand}" in help) help ;; @@ -63,8 +106,16 @@ case $1 in list_netservices ;; location) - shift - location $@ + location "$@" + ;; + defaultusername) + defaultusername "$@" + ;; + wakeonethernet) + wakeonethernet "$@" + ;; + guestaccess) + guestaccess "$@" ;; *) help 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 7813748..02a9b79 100755 --- a/plugins/notification +++ b/plugins/notification @@ -1,52 +1,71 @@ #!/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 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 + 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__ } +enable(){ + showcenter "YES" +} + +disable(){ + showcenter "NO" +} + 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 + [ -z "$1" ] && help && return + + local choice="$(_mcli_convert_yes_no_to_load_unload "$1")" + + 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")" + + echo "${command} ${subcommand}: ${value}" +} + +bannertime(){ + value="$(_mcli_defaults_string "com.apple.notificationcenterui" \ + "bannerTime" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" } -case $1 in +case "${subcommand}" in help) help ;; showcenter) - shift showcenter "$@" ;; + enable) + enable "$@" + ;; + disable) + disable "$@" + ;; + bannertime) + bannertime "$@" + ;; *) 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 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 new file mode 100755 index 0000000..234bd07 --- /dev/null +++ b/plugins/power @@ -0,0 +1,140 @@ +#!/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 + +_set_power_setting(){ + local setting="$1" + local battery_value="$2" + local plugged_value="$3" + + 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(){ + cat<<__EOF__ + 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 + 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 + 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__ +} + +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}" +} + +appnap(){ + value="$(_mcli_defaults_yes_no_to_inverted_boolean "NSGlobalDomain" \ + "NSAppSleepDisabled" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +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(){ + 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 + ;; + disksleeptime) + disksleeptime "$@" + ;; + displaysleeptime) + displaysleeptime "$@" + ;; + hibernationdelay) + hibernationdelay "$@" + ;; + sleepdelay) + sleepdelay "$@" + ;; + powernap) + powernap "$@" + ;; + powerbuttonsleeps) + powerbuttonsleeps "$@" + ;; + appnap) + appnap "$@" + ;; + restartonhang) + restartonhang "$@" + ;; + persistmemory) + persistmemory "$@" + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab diff --git a/plugins/printer b/plugins/printer index 696b024..14aa6a4 100755 --- a/plugins/printer +++ b/plugins/printer @@ -1,21 +1,35 @@ #!/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 # 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 - usage: m printer [ settings | name | queue | drivers | web | help ] +__EOF__ +} - 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 +quitwhenfinished(){ + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.print.PrintingPrefs" \ + "Quit When Finished" \ + "$1")" -__EOF__ + echo "${command} ${subcommand}: ${value}" } -case $1 in +case "${subcommand}" in help) help ;; @@ -34,6 +48,9 @@ case $1 in web) cupsctl WebInterface=yes && open http://localhost:631/printers ;; + quitwhenfinished) + quitwhenfinished "$@" + ;; *) help ;; 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 new file mode 100755 index 0000000..ab4f51b --- /dev/null +++ b/plugins/screencapture @@ -0,0 +1,80 @@ +#!/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 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_yes_no_to_boolean "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 diff --git a/plugins/screensaver b/plugins/screensaver index 497844d..225366d 100755 --- a/plugins/screensaver +++ b/plugins/screensaver @@ -1,63 +1,59 @@ #!/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 screensaver [ status | askforpassword | help ] +declare command="$(basename "$0")" +declare subcommand="$1" - Examples: - m screensaver # launch screensaver +[ $# -gt 0 ] && shift - 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 +help(){ + cat<<__EOF__ + 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__ } 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_defaults_yes_no_to_integer "com.apple.screensaver" \ + "askForPassword" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" } -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 +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' \ + -e 'end tell') + + value="$(_mcli_convert_yes_no_to_enabled_disabled "${value}")" -case $1 in + echo "${command}: ${value}" +} + +case "${subcommand}" in help) help ;; askforpassword) - shift askforpassword $@ ;; + passworddelay) + passworddelay $@ + ;; status) status ;; diff --git a/plugins/scrolling b/plugins/scrolling new file mode 100755 index 0000000..2ad02ab --- /dev/null +++ b/plugins/scrolling @@ -0,0 +1,123 @@ +#!/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 [ 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" \ + "sudo")" + + 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 diff --git a/plugins/service b/plugins/service index 416c6e2..24fd3b7 100755 --- a/plugins/service +++ b/plugins/service @@ -10,21 +10,25 @@ 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 com.apple.sessionlogoutd # start a service - m service stop com.apple.sessionlogoutd # stop a service + m service start # start a service + m service stop # stop a service - m service load com.apple.sessionlogoutd # load a service - m service unload com.apple.sessionlogoutd # unload a service + m service load # load a service + m service unload # 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 __EOF__ } 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 new file mode 100755 index 0000000..7c6c00b --- /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 [ 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 + elif [[ "${choice}" == "false" ]]; then + 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")" + _mcli_defaults_number "com.apple.systemsound" \ + "com.apple.sound.beep.volume" \ + "$2" + + 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_delete "com.apple.speech.synthesis.general.prefs" \ + "TimeAnnouncementPrefs" \ + "sudo")" + 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")" + + echo "${command} ${subcommand}: ${value}" +} + +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" +} + +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 diff --git a/plugins/spotlight b/plugins/spotlight new file mode 100755 index 0000000..875ea65 --- /dev/null +++ b/plugins/spotlight @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +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 [ 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")" + + [ -z "$1" ] && help && return + + for keyboard_shortcut_id in "${spotlight_keyboard_shortcut_ids[@]}"; do + _mcli_keyboard_shortcut_toggle "${keyboard_shortcut_id}" "${enabled}" + done + + echo "${command} ${subcommand}: ${enabled}" +} + +case "${subcommand}" in + help) + help + ;; + shortcutkeys) + shortcut_keys "$@" + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab diff --git a/plugins/system b/plugins/system new file mode 100755 index 0000000..4224e67 --- /dev/null +++ b/plugins/system @@ -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 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")" + + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "ApplePersistence" \ + "$1")" + + if [[ "${choice}" == "true" ]]; then + sudo mkdir /.DocumentRevisions-V100 2> /dev/null + defaults delete NSGlobalDomain AutosavingDelay 2> /dev/null + elif [[ "${choice}" == "false" ]]; then + sudo rm -rf /.DocumentRevisions-V1* + defaults write NSGlobalDomain AutosavingDelay -integer 0 + fi + + echo "${command} ${subcommand}: ${value}" +} + +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 diff --git a/plugins/timemachine b/plugins/timemachine new file mode 100755 index 0000000..e8b27ab --- /dev/null +++ b/plugins/timemachine @@ -0,0 +1,71 @@ +#!/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 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_enable_disable "$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 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 new file mode 100755 index 0000000..b1c6a25 --- /dev/null +++ b/plugins/tooltips @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/converters.sh" +source "$( dirname "${BASH_SOURCE[0]}" )/../lib/defaults.sh" + +declare command="$(basename "$0")" +declare subcommand="$1" + +[ $# -gt 0 ] && shift + +help(){ + cat<<__EOF__ + 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 # The size of the font in the tooltip +__EOF__ +} + +delay() { + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "NSInitialToolTipDelay" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +autowrap() { + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "NSToolTipAutoWrappingDisabled" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +fontsize() { + value="$(_mcli_defaults_number "NSGlobalDomain" \ + "NSToolTipsFontSize" \ + "$1")" + + echo "${command} ${subcommand}: ${value}" +} + +case "${subcommand}" in + help) + help + ;; + delay) + delay "$@" + ;; + autowrap) + autowrap "$@" + ;; + fontsize) + fontsize "$@" + ;; + *) + help + ;; +esac + +# vim: ts=4 sw=4 softtabstop=4 expandtab diff --git a/plugins/trash b/plugins/trash index 9078723..8bb4e55 100755 --- a/plugins/trash +++ b/plugins/trash @@ -1,13 +1,19 @@ #!/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 trash [ status | clean | help ] - - Examples: - m trash status # get trash info - m trash clean # clean trash + Usage: + m trash status # get trash info + m trash clean # clean trash + m trash warn [ YES | NO ] # warn when emptying trash __EOF__ } @@ -18,13 +24,26 @@ clean_trash(){ echo "Done!" } -case $1 in +warn() { + value="$(_mcli_defaults_yes_no_to_boolean "com.apple.finder" \ + "WarnOnEmptyTrash" \ + "$1")" + + [ -n "$1" ] && killall Finder + + echo "${command} ${subcommand}: ${value}" +} + +case "${subcommand}" in help) help ;; 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}' diff --git a/plugins/update b/plugins/update index 7580a5b..804386d 100755 --- a/plugins/update +++ b/plugins/update @@ -1,19 +1,32 @@ #!/usr/bin/env bash +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" + +[ $# -gt 0 ] && shift + help(){ cat<<__EOF__ - usage: m update [ list | install | help ] - + Usage: + m update list # list available 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 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 # install all the available updates + m update install iTunesX-12.4.1 RAWCameraUpdate6.20-6.20 # install specific updates __EOF__ } - install_updates(){ # at least one package [ -z "$1" ] && help && exit 1 @@ -27,8 +40,61 @@ 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 +interval(){ + local interval + + case "$1" in + daily) + interval="1";; + weekly) + interval="7";; + biweekly) + interval="14";; + monthly) + interval="30";; + *) + interval="$1";; + esac + + value="$(_mcli_defaults_number "${path_to_update_prefs}" \ + "ScheduleFrequency" \ + "${interval}" \ + "sudo")" + + echo "${command} ${subcommand}: ${value}" +} + +case "${subcommand}" in help) help ;; @@ -36,9 +102,17 @@ case $1 in sudo softwareupdate --list ;; install) - shift install_updates "$@" ;; + automaticinstall) + automaticinstall "$@" + ;; + automaticdownload) + automaticdownload "$@" + ;; + interval) + interval "$@" + ;; *) help ;; diff --git a/plugins/user b/plugins/user index 7d9f516..d562840 100755 --- a/plugins/user +++ b/plugins/user @@ -1,21 +1,35 @@ #!/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 user [ list | ls | info | create | delete | help ] +declare login_pref_path="/Library/Preferences/com.apple.loginwindow" - Examples: - m user ls # list users - m user info demouser # display user information +declare command="$(basename "$0")" +declare subcommand="$1" - m user create # create a user, it will ask you the below information - Username: - Full name: - Shell [/bin/bash]: - Password: +[ $# -gt 0 ] && shift - m user delete demouser # delete user +help(){ + cat<<__EOF__ + Usage: + 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 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__ } @@ -47,11 +61,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) @@ -100,9 +109,90 @@ user_delete(){ fi } +autologin(){ + local username="$(if [[ "$1" != "disable" ]]; then echo "$1"; fi)" + + if [ -z "${username}" ]; then + sudo defaults delete "${login_pref_path}" autoLoginUser 2> /dev/null + sudo rm -f /etc/kcpassword + else + sudo defaults write "${login_pref_path}" autoLoginUser -string "$username" + fi +} +fastswitching(){ + value="$(_mcli_defaults_yes_no_to_boolean "NSGlobalDomain" \ + "MultipleSessionEnabled" \ + "$1")" -case $1 in + echo "${command} ${subcommand}: ${value}" +} + +guest(){ + value="$(_mcli_defaults_yes_no_to_integer "${login_pref_path}" \ + "GuestEnabled" \ + "$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}" +} + +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" \ + "$1" \ + "sudo")" + + 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 "${subcommand}" in help) help ;; @@ -110,16 +200,34 @@ case $1 in user_ls ;; info) - shift - user_info $@ + user_info "$@" ;; create) - shift user_create ;; delete) - shift - user_delete $@ + user_delete "$@" + ;; + autologin) + autologin "$@" + ;; + fastswitching) + fastswitching "$@" + ;; + guest) + guest "$@" + ;; + showsecure) + showsecure "$@" + ;; + loginpoweroptions) + loginpoweroptions "$@" + ;; + loginattemptsbeforehint) + loginattemptsbeforehint "$@" + ;; + loginmessage) + loginmessage "$@" ;; *) help 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 new file mode 100755 index 0000000..4e6839d --- /dev/null +++ b/plugins/windows @@ -0,0 +1,39 @@ +#!/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 [ 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