From 7484fb3130d689da2057e9fec28377ee1ca33a29 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 18 Aug 2025 23:07:57 +0000 Subject: [PATCH 1/2] feat: Add macOS appearance control commands This commit introduces new commands to control the macOS appearance (Dark/Light mode) from the command line. The following commands are added: - `mac appearance:dark`: Switches macOS to Dark Mode. - `mac appearance:light`: Switches macOS to Light Mode. - `mac appearance:toggle`: Toggles between Light and Dark Mode. A new `appearance` plugin was created to house the logic, which uses `osascript` to interact with the macOS System Events. The main `mac` script was updated to recognize these new commands and load the plugin. --- mac | 6 +++++- mac-cli/plugins/appearance | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 mac-cli/plugins/appearance diff --git a/mac b/mac index 95df6b7..2e1549d 100755 --- a/mac +++ b/mac @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash ########################################################################### #  mac CLI (mac command line tools) - macOS command line tools for developers ########################################################################### @@ -73,6 +73,9 @@ COMMANDS=( volume:ismute volume:mute volume:unmute + appearance:dark + appearance:light + appearance:toggle hidden:show hidden:hide screensaver @@ -178,3 +181,4 @@ source "$MAC/mac-cli/plugins/performance" source "$MAC/mac-cli/plugins/search" source "$MAC/mac-cli/plugins/ssh" source "$MAC/mac-cli/plugins/volume" +source "$MAC/mac-cli/plugins/appearance" diff --git a/mac-cli/plugins/appearance b/mac-cli/plugins/appearance new file mode 100644 index 0000000..dfd9ed1 --- /dev/null +++ b/mac-cli/plugins/appearance @@ -0,0 +1,27 @@ +#!/bin/sh + +#-------------------------------------------------------------------- +# Appearance Utilities +#-------------------------------------------------------------------- + +case "$fn" in + + # Switch to Dark Mode + "appearance:dark") + osascript -e 'tell application "System Events" to tell appearance preferences to set dark mode to true' + echo "${WHITEBOLD}Appearance:${NC} ${GREEN}Dark Mode${NC}" + ;; + + # Switch to Light Mode + "appearance:light") + osascript -e 'tell application "System Events" to tell appearance preferences to set dark mode to false' + echo "${WHITEBOLD}Appearance:${NC} ${GREEN}Light Mode${NC}" + ;; + + # Toggle between Light and Dark Mode + "appearance:toggle") + osascript -e 'tell application "System Events" to tell appearance preferences to set dark mode to not dark mode' + echo "${WHITEBOLD}Appearance:${NC} ${GREEN}Toggled${NC}" + ;; + +esac From 9d53244d2b1970416638cca28d11b4f0c6453b01 Mon Sep 17 00:00:00 2001 From: chetu3319 Date: Mon, 18 Aug 2025 19:58:16 -0700 Subject: [PATCH 2/2] Move appearance commands to general plugin Appearance-related commands (dark mode, light mode, toggle) were removed from the separate appearance plugin and integrated into the general plugin. The mac script was updated to reference the new command names and no longer sources the appearance plugin. --- mac | 9 ++++----- mac-cli/plugins/appearance | 27 --------------------------- mac-cli/plugins/general | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 32 deletions(-) delete mode 100644 mac-cli/plugins/appearance diff --git a/mac b/mac index 2e1549d..99e2a20 100755 --- a/mac +++ b/mac @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh ########################################################################### #  mac CLI (mac command line tools) - macOS command line tools for developers ########################################################################### @@ -73,9 +73,6 @@ COMMANDS=( volume:ismute volume:mute volume:unmute - appearance:dark - appearance:light - appearance:toggle hidden:show hidden:hide screensaver @@ -89,6 +86,9 @@ COMMANDS=( wifi:scan wifi:enable wifi:disable + appearance:dark-mode + appearance:light-mode + appearance:toggle-dark-mode eject-all battery info @@ -181,4 +181,3 @@ source "$MAC/mac-cli/plugins/performance" source "$MAC/mac-cli/plugins/search" source "$MAC/mac-cli/plugins/ssh" source "$MAC/mac-cli/plugins/volume" -source "$MAC/mac-cli/plugins/appearance" diff --git a/mac-cli/plugins/appearance b/mac-cli/plugins/appearance deleted file mode 100644 index dfd9ed1..0000000 --- a/mac-cli/plugins/appearance +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -#-------------------------------------------------------------------- -# Appearance Utilities -#-------------------------------------------------------------------- - -case "$fn" in - - # Switch to Dark Mode - "appearance:dark") - osascript -e 'tell application "System Events" to tell appearance preferences to set dark mode to true' - echo "${WHITEBOLD}Appearance:${NC} ${GREEN}Dark Mode${NC}" - ;; - - # Switch to Light Mode - "appearance:light") - osascript -e 'tell application "System Events" to tell appearance preferences to set dark mode to false' - echo "${WHITEBOLD}Appearance:${NC} ${GREEN}Light Mode${NC}" - ;; - - # Toggle between Light and Dark Mode - "appearance:toggle") - osascript -e 'tell application "System Events" to tell appearance preferences to set dark mode to not dark mode' - echo "${WHITEBOLD}Appearance:${NC} ${GREEN}Toggled${NC}" - ;; - -esac diff --git a/mac-cli/plugins/general b/mac-cli/plugins/general index 5883c41..ea8a818 100755 --- a/mac-cli/plugins/general +++ b/mac-cli/plugins/general @@ -221,6 +221,23 @@ case "$fn" in networksetup -setairportpower ${_W_DEVICE} off ;; + # Enable Dark Mode + "appearance:dark-mode") + echo "${GREEN}Enabling Dark Mode${NC}" + osascript -e 'tell application "System Events" to tell appearance preferences to set dark mode to true' + ;; + + # Disable Dark Mode + "appearance:light-mode") + echo "${GREEN}Disabling Dark Mode${NC}" + osascript -e 'tell application "System Events" to tell appearance preferences to set dark mode to false' + ;; + + # Toggle Dark Mode + "appearance:toggle-dark-mode") + echo "${GREEN}Toggling Dark Mode${NC}" + osascript -e 'tell application "System Events" to tell appearance preferences to set dark mode to not dark mode' + ;; # Add blank space to the dock "dock:add-space")