all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* List of monitor names
@ 2022-09-15  2:55 uzibalqa
  2022-09-15  5:04 ` Po Lu
  0 siblings, 1 reply; 7+ messages in thread
From: uzibalqa @ 2022-09-15  2:55 UTC (permalink / raw)
  To: uzibalqa via Users list for the GNU Emacs text editor

Can one get a list of monitor names that I can use to tell emacs where to put the frame?




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: List of monitor names
  2022-09-15  2:55 List of monitor names uzibalqa
@ 2022-09-15  5:04 ` Po Lu
  2022-09-15 10:52   ` uzibalqa
  0 siblings, 1 reply; 7+ messages in thread
From: Po Lu @ 2022-09-15  5:04 UTC (permalink / raw)
  To: uzibalqa; +Cc: uzibalqa via Users list for the GNU Emacs text editor

uzibalqa <uzibalqa@proton.me> writes:

> Can one get a list of monitor names that I can use to tell emacs where
> to put the frame?

How do you plan to use the monitor names to tell Emacs where to put a
frame?



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: List of monitor names
  2022-09-15  5:04 ` Po Lu
@ 2022-09-15 10:52   ` uzibalqa
  2022-09-15 17:06     ` Sam Steingold
  0 siblings, 1 reply; 7+ messages in thread
From: uzibalqa @ 2022-09-15 10:52 UTC (permalink / raw)
  To: Po Lu; +Cc: uzibalqa via Users list for the GNU Emacs text editor

------- Original Message -------
On Thursday, September 15th, 2022 at 5:04 AM, Po Lu <luangruo@yahoo.com> wrote:


> uzibalqa uzibalqa@proton.me writes:
> 
> > Can one get a list of monitor names that I can use to tell emacs where
> > to put the frame?
> 
> 
> How do you plan to use the monitor names to tell Emacs where to put a
> frame?

Perhaps the user can get the monitor names and see which monitor he wants to work in.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: List of monitor names
  2022-09-15 10:52   ` uzibalqa
@ 2022-09-15 17:06     ` Sam Steingold
  2022-09-16  1:30       ` Po Lu
  0 siblings, 1 reply; 7+ messages in thread
From: Sam Steingold @ 2022-09-15 17:06 UTC (permalink / raw)
  To: help-gnu-emacs, uzibalqa

> * uzibalqa <hmvonydn@cebgba.zr> [2022-09-15 10:52:34 +0000]:
>
>> uzibalqa uzibalqa@proton.me writes:
>> 
>> > Can one get a list of monitor names that I can use to tell emacs where
>> > to put the frame?
>> 
>> 
>> How do you plan to use the monitor names to tell Emacs where to put a
>> frame?
>
> Perhaps the user can get the monitor names and see which monitor he wants to work in.

For me the solution was based on https://askubuntu.com/q/702071/80483
and https://askubuntu.com/q/702002/80483; basically you run `xrandr` and
parse its output.

--8<---------------cut here---------------start------------->8---
# configure multiple displays and
# move the windows to their appropriate displays

import subprocess
import os
import wmctrl
import re

mydisplays = [("VGA1",0,"left"),
              ("eDP1",1080,"normal"),
              ("HDMI1",3000,"left")]

def set_displays ():
    subprocess.check_call(" && ".join([
        "xrandr --output %s --pos %dx0  --rotate %s" % d for d in mydisplays]),
                          shell=True)

mywindows = [("/emacs$","VGA1"),
             ("/chrome$","HDMI1"),
             ("gnome-terminal","eDP1")]
def max_windows ():
    didi = dict([(d,x) for d,x,_ in mydisplays])
    for w in wmctrl.Window.list():
        try:
            exe = os.readlink("/proc/%d/exe" % (w.pid))
            if exe.endswith(" (deleted)"):
                print("WARNING: restart %s" % exe)
            for (r,d) in mywindows:
                if re.search(r,exe):
                    x = didi[d]
                    print("%s(%s) --> %s (%d)" % (r,exe,d,x))
                    w.set_properties(("remove","maximized_vert","maximized_horz"))
                    w.resize_and_move(x,0,w.w,w.h)
                    w.set_properties(("add","maximized_vert","maximized_horz"))
                    break
        except OSError:
            continue

def cmdlines (cmd):
    return subprocess.check_output(cmd).splitlines()

def show_displays ():
    for l in cmdlines(["xrandr"]):
        if " connected " in l:
            print(l)

if __name__ == '__main__':
    show_displays()
    set_displays()
    show_displays()
    max_windows()
--8<---------------cut here---------------end--------------->8---



-- 
Sam Steingold (https://aphar.dreamwidth.org/) on darwin Ns 10.3.2113
https://lastingimpactpsychology.com https://steingoldpsychology.com
https://honestreporting.com https://thereligionofpeace.com https://ij.org/
Any supplier that makes enough to pay a full time lobbyist is overcharging.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: List of monitor names
  2022-09-15 17:06     ` Sam Steingold
@ 2022-09-16  1:30       ` Po Lu
  2022-09-16  1:48         ` uzibalqa
  0 siblings, 1 reply; 7+ messages in thread
From: Po Lu @ 2022-09-16  1:30 UTC (permalink / raw)
  To: help-gnu-emacs; +Cc: uzibalqa

Sam Steingold <sds@gnu.org> writes:

> For me the solution was based on https://askubuntu.com/q/702071/80483
> and https://askubuntu.com/q/702002/80483; basically you run `xrandr` and
> parse its output.

Well, look no further than display-monitor-attributes-list, which uses
RandR to obtain the same information, but without needing an external
program.

(Unless, of course, your X server only supports Xinerama, in which case
it falls back to that.)



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: List of monitor names
  2022-09-16  1:30       ` Po Lu
@ 2022-09-16  1:48         ` uzibalqa
  2022-09-16  2:08           ` uzibalqa
  0 siblings, 1 reply; 7+ messages in thread
From: uzibalqa @ 2022-09-16  1:48 UTC (permalink / raw)
  To: Po Lu; +Cc: help-gnu-emacs


------- Original Message -------
On Friday, September 16th, 2022 at 1:30 AM, Po Lu <luangruo@yahoo.com> wrote:


> Sam Steingold sds@gnu.org writes:
> 
> > For me the solution was based on https://askubuntu.com/q/702071/80483
> > and https://askubuntu.com/q/702002/80483; basically you run `xrandr` and
> > parse its output.
> 
> 
> Well, look no further than display-monitor-attributes-list, which uses
> RandR to obtain the same information, but without needing an external
> program.
> 
> (Unless, of course, your X server only supports Xinerama, in which case
> it falls back to that.)

With "display-monitor-attributes-list" I get

(((geometry 1080 1152 1366 768) (workarea 1080 1152 1311 768) (mm-size 344 194) 
(frames #<frame *scratch* 0x16f3510> #<frame Speedbar 0x2b84190>) 
(source . "Gdk")) ((geometry 0 0 1080 1920) (workarea 0 0 1080 1920) 
(mm-size 477 268) (frames) (source . "Gdk")))

But still nobody has told me what frame should I use for the initial frame (seems it
is usually *scratch*).  What input should frame be in the command "(frame-outer-width frame)".



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: List of monitor names
  2022-09-16  1:48         ` uzibalqa
@ 2022-09-16  2:08           ` uzibalqa
  0 siblings, 0 replies; 7+ messages in thread
From: uzibalqa @ 2022-09-16  2:08 UTC (permalink / raw)
  To: uzibalqa; +Cc: Po Lu, help-gnu-emacs






Sent with Proton Mail secure email.

------- Original Message -------
On Friday, September 16th, 2022 at 1:48 AM, uzibalqa <uzibalqa@proton.me> wrote:


> ------- Original Message -------
> On Friday, September 16th, 2022 at 1:30 AM, Po Lu luangruo@yahoo.com wrote:
> 
> 
> 
> > Sam Steingold sds@gnu.org writes:
> > 
> > > For me the solution was based on https://askubuntu.com/q/702071/80483
> > > and https://askubuntu.com/q/702002/80483; basically you run `xrandr` and
> > > parse its output.
> > 
> > Well, look no further than display-monitor-attributes-list, which uses
> > RandR to obtain the same information, but without needing an external
> > program.
> > 
> > (Unless, of course, your X server only supports Xinerama, in which case
> > it falls back to that.)
> 
> 
> With "display-monitor-attributes-list" I get
> 
> (((geometry 1080 1152 1366 768) (workarea 1080 1152 1311 768) (mm-size 344 194)
> (frames #<frame scratch 0x16f3510> #<frame Speedbar 0x2b84190>)
> 
> (source . "Gdk")) ((geometry 0 0 1080 1920) (workarea 0 0 1080 1920)
> (mm-size 477 268) (frames) (source . "Gdk")))
> 
> But still nobody has told me what frame should I use for the initial frame (seems it
> is usually scratch). What input should frame be in the command "(frame-outer-width frame)".

Doing (frame-outer-width "*scratch*") gives

Debugger entered--Lisp error: (error "*scratch* is not a live frame")

  signal(error ("*scratch* is not a live frame"))

  error("%s is not a live frame" "*scratch*")

  window-normalize-frame("*scratch*")

  frame-outer-width("*scratch*")





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-09-16  2:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-15  2:55 List of monitor names uzibalqa
2022-09-15  5:04 ` Po Lu
2022-09-15 10:52   ` uzibalqa
2022-09-15 17:06     ` Sam Steingold
2022-09-16  1:30       ` Po Lu
2022-09-16  1:48         ` uzibalqa
2022-09-16  2:08           ` uzibalqa

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.