mnp / dispwatch Goto Github PK
View Code? Open in Web Editor NEWEmacs - Watch the current display for changes (ie plugging in a monitor) and run a hook.
License: GNU General Public License v3.0
Emacs - Watch the current display for changes (ie plugging in a monitor) and run a hook.
License: GNU General Public License v3.0
Hi,
Thanks for this package - I've been looking for something like this for awhile. It would be good to see on MELPA, so there's my vote!
I've seen this on 2 macbooks & an HP monitor... the values that come back from display-pixel-*
(which uses x-display-pixel-*
) seems to be a lie. Specifically, switching from one resolution to another seems to generate a myriad of values... I'm trying to get my lookup table working for OSX's 5 scaling factors, but I've gone through 7-8 by now by going up and down. I've seen similar screwups when I change font size and then ask for frame-width
... it often takes a while for the values to change or they're just inconsistent.
What IS consistent is the geometry values that you're using to detect changes. When you call display-monitor-attributes-list
it calls a different C function based on os (ns-display-monitor-attributes
in my case) and that seems to be more consistent.
Here's what I'm currently using as my hook:
(defun rwd/display-change (_disp) ; ignore this incoming var
(interactive)
(when window-system
(let* ((attr (frame-monitor-attributes))
(geom (assoc 'geometry attr))
(w (nth 3 geom))
(h (nth 4 geom))
(disp (format "%sx%s" w h)) ; calculated from actual geometry
(args (assoc disp rwd/displays))
(default (assoc "default" rwd/displays)))
(message "rwd/display-change %s" disp)
(unless args
(find-variable 'rwd/displays)
(insert (format "%S\n" (list disp 'w 'h "Font" 16)))
(message "Please extend rwd/displays with %S" disp)
(setq args default))
(apply 'rwd/display-setup (cdr args))
(rwd-fix-fullscreen)
(sleep-for 0.25)
(rwd-split-smart))))
I'm good for now, but you might want to consider having a geometry-change
hook. Happy to send a patch if you want.
I would like to use this script to change font size depending on monitor resolution. The problem is that I am interested in DPI, not in pixles. One can have 2 monitors with same number of pixels but different resolutions (e.g. if one is 15" and other is 17").
Is it possible to detect DPI change and trigger this hook as well?
Related discussion: https://emacs.stackexchange.com/questions/28390/quickly-adjusting-text-to-dpi-changes
Currently, the package tracks changes in (frame-monitor-attributes)
output, but this provides only partial information in the case of connecting/disconnecting multiple monitors, as it returns changes only for the monitor the main Emacs frame is on. How about using (display-monitor-attributes-list)
, which would return info for all monitors, instead?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.