Skip to content

hechen/Swwwitch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Swwwitch

Build Status Swift Version

Just a switch tutorial.

Interface-c300

That switch your system theme needs your authorization. Just click OK.

System Event-c300

Under the hood

  1. Switch your system theme using AppleScript
  2. Hide / Show your desktop icons using NSTask(aka Process)
  3. MenuBar only when your Cocoa Application is agent.
  4. Start at login using serviceManagement (embed a helper login app to wake main application up.)

System Appearance Switch

tell application "System Events"
	tell appearance preferences
		set dark mode to not dark mode
	end tell
end tell

You can just using ScriptEditor to run this AppleScript to switch the dark theme and light one.

applescript://com.apple.scripteditor?action=new&name=Change%20Theme&script=tell%20application%20%22System%20Events%22%0D%09tell%20appearance%20preferences%0D%09%09set%20dark%20mode%20to%20not%20dark%20mode%0D%09end%20tell%0Dend%20tell

Hide / Show Desktop Icons

defaults write com.apple.finder CreateDesktop false
killall Finder

Input the two lines in your terminal, icons just hidden.

If you want recover your icons, just change false to true.

hide Desktop Icons

show Desktop Icons

Caffeinate

# enable caffeinate forever.
# never return.
caffeinate

# disable caffeinate
killall caffeinate 

Links

Checkout all command lines macOS Support