From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Sam Steingold Newsgroups: gmane.emacs.help Subject: Re: List of monitor names Date: Thu, 15 Sep 2022 13:06:37 -0400 Message-ID: References: <2mSPREZqVQUWVJrXTsuN0rjIJ2gcUGe3oiFbU-Yra2JDRYlYmRjUlxF3aeaHDasAahwC8Nk56V4SCWsRIOW8wIru9mQUTxHKTVOZsJTuhf8=@proton.me> <871qsdz0qt.fsf@yahoo.com> Reply-To: sds@gnu.org Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22321"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (darwin) To: help-gnu-emacs@gnu.org, uzibalqa Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 15 19:07:21 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oYsKe-0005cN-O3 for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 15 Sep 2022 19:07:20 +0200 Original-Received: from localhost ([::1]:33358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oYsKd-0000g7-LS for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 15 Sep 2022 13:07:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59930) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oYsK2-0000eL-6o for help-gnu-emacs@gnu.org; Thu, 15 Sep 2022 13:06:42 -0400 Original-Received: from mail-qk1-x730.google.com ([2607:f8b0:4864:20::730]:42859) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oYsK0-0006Qi-E4; Thu, 15 Sep 2022 13:06:41 -0400 Original-Received: by mail-qk1-x730.google.com with SMTP id d15so13746500qka.9; Thu, 15 Sep 2022 10:06:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:message-id:date:mail-followup-to:reply-to :return-receipt-to:user-agent:references:in-reply-to:subject:to:from :sender:from:to:cc:subject:date; bh=WXVcz0ELVb8lAKhY7Nd1wdbd3FkeEOMbdyuXJ7kwSrA=; b=XyeygYjI/IKkpeiX3MGboSdqowUVyABjdw7ustP7i+EuOSbwiFguzTRI4OnrRNg+Mm fw+4Kh8YgnfrprIyDoPozJ4UDF6oDHvqL3/O0XeYoOCEyHB9fPDODOLT9qWLD+kHX6aF 1pERHYYQ9yrdAAdKyRIomndJizayf2Toxdw1HZb1qKASLR0KZt6wLCxD2ior2KTfxsxW sxriC3+BgYMNbYyzqun0L9UoDaqsVHtJUe7KNq5NXCKZou+Nw76RTpGiKYXbcYNcp96+ T1MdFc5VwPFlW1dyOH5wZxPQHpToWXJWlr5xjtU4zzlQ1VmCbJzwi/dpPEU6K5GtwxzD t9rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:mail-followup-to:reply-to :return-receipt-to:user-agent:references:in-reply-to:subject:to:from :sender:x-gm-message-state:from:to:cc:subject:date; bh=WXVcz0ELVb8lAKhY7Nd1wdbd3FkeEOMbdyuXJ7kwSrA=; b=PppcDaCJdmogVFgTetCyZnCrj2/cXqGtFFXoDB/XKad+y/d6wbwO3vQtpBBGL0DhZu pl7zIaR0cPyvp50EojJqCzISESMQa66VUCQA9feG7htvXPcicWYcaXZsu2qyrRpqOZcN iYPbktJSWvU2usFgzDihYCUXMH4SRHyM/WBRRIdmgWr5LWmoDkbKqfu2hdRsS6zzVfox YfM4gJFEzpkW70GZywekaM42/3y3LrOHkQeGVDk9aVtbGBL3gJ7saXpovfrmjPnWAvRv Zvr7VW9rOCznPehQc/oPwnr/ZMbzVAL7TI0BnZ8B8mMyFmRdYaFsHSD4QTSBtm4RnpeZ W2Nw== X-Gm-Message-State: ACrzQf0fLWwEaP6e0acPnDIQCa79yJstBzuyj5R4Qsa+d5OixIV1MO6d QWgxuFTjiMFjM7dZQv/pi/dN262npDxL X-Google-Smtp-Source: AMsMyM5G5sg7Z+mQRvENVA7Qh4LMWWSZGoClBSedC6RoI+UwVChHs9PtZpbqKwGmiJna5/PH0I1OeA== X-Received: by 2002:a05:620a:4407:b0:6cb:e111:32c2 with SMTP id v7-20020a05620a440700b006cbe11132c2mr868784qkp.415.1663261598688; Thu, 15 Sep 2022 10:06:38 -0700 (PDT) Original-Received: from 3c22fb11fdab.ant.amazon.com (pool-71-125-32-130.nycmny.fios.verizon.net. [71.125.32.130]) by smtp.gmail.com with ESMTPSA id u8-20020a05620a430800b006bb208bd889sm4311340qko.120.2022.09.15.10.06.37 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Sep 2022 10:06:38 -0700 (PDT) In-Reply-To: (uzibalqa@proton.me's message of "Thu, 15 Sep 2022 10:52:34 +0000") X-Attribution: Sam X-Disclaimer: You should not expect anyone to agree with me. Mail-Followup-To: help-gnu-emacs@gnu.org, uzibalqa Received-SPF: pass client-ip=2607:f8b0:4864:20::730; envelope-from=sam.steingold@gmail.com; helo=mail-qk1-x730.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:139492 Archived-At: > * uzibalqa [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.