Alternatively, #'start-process-shell-command with NIL for buffer, #'set-process-filter should achieve the same thing. There's an argument :FILTER that would let you set a function that receives stdout from that process. I'd look into documentation of #'make-process. Personally, I'd reimplement it the way you suggest - I'd put the timer loop in C code to save on repeatedly starting a process, and then make it run emacsclient -e "(change-theme-for-lighting %d)", where %d is a sensor value, whenever that value crosses a threshold.Īlternatively, if you want to keep the entire business logic within Emacs Lisp code, there's some way to make it work too. It's a synchronous, blocking call (at least on my Emacs 26, running (shell-command-to-string "sleep 5") hangs the whole Emacs nicely for 5 seconds). It looks like it could the timer isn't the problem (they're just entries in a queue), but #'shell-command-to-string call might be. Permissions beyond the scope of this license may be available at. Synchronizing OSX, Terminal, and Emacs Dark/Light Appearance by Jeremy Friesen is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.īased on a work at. Why I Chose Emacs as My New Text Editor.Reducing Duplication in my Emacs Config.Many Small Tools Make Light Work (in Emacs). Enter Your Reply URL: Submit Note: Any submitted webmention won't show up until I next "build" my site. Reply by Email Did you reply somewhere else to this post? Submit your reply's URL as a webmention. I added this to my one of the files I load for Emacs. Load the appropriate Emacs theme based on OSX appearance "defaults read -g AppleInterfaceStyle") 0 4)) "Set theme based on OSX apperance state." (defun jnf-emacs-theme-by-osx-appearance () (shell-command "osascript -e 'tell application \"System Events\" to tell appearance preferences to set dark mode to not dark mode'") "Toggle system-wide Dark or Light setting." Later on this evening, I started tinkering to see about Emacs synchronizing with the Dark/Light mode of MacOS. eval "(modus-vivendi-theme-load)" 1> /dev/null Sh $HOME/.config/base16-shell/scripts/base16-google-dark.shĮditor -eval "(disable-theme 'modus-operandi)" \ # AppleInterfaceStyle is set, and that means we're now in "Dark" eval "(modus-operandi-theme-load)" 1> /dev/null Sh $HOME/.config/base16-shell/scripts/base16-google-light.shĮditor -eval "(disable-theme 'modus-vivendi)" \ # No value for AppleInterfaceStyle, so the OS has us in light # Second, determine what is the newly set appearance.Īppearance=`defaults read -g AppleInterfaceStyle 2>/dev/null` Osascript -e 'tell application "System Events" to tell appearance preferences to set dark mode to not dark mode' # if the terminal and Emacs should be "dark" or "light". It uses the state of the Operating System to determine # This script toggles the Operating System, Terminal, and Emacs Now, from the command-line, I can type dark to switch between Light and Dark mode.īelow is a copy of that script: #!/bin/sh This evening I wrote up a shell script to keep Macintosh Operating System ( MacOS ?), Emacs ( Emacs ?), and my Terminal synchronized. Throughout the day, I find myself toggling between Light and Dark modes. Synchronizing OSX, Terminal, and Emacs Dark/Light Appearance Composing Shell, Applescript, and Emacs Eval Jeremy Friesen wrote on :: Tags: Synchronizing OSX, Terminal, and Emacs Dark/Light Appearance Synchronizing OSX, Terminal, and Emacs Dark/Light Appearance // Take on Rules Skip to Main Content Take on Rules About
0 Comments
Leave a Reply. |