Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1omvYq-0001du-Pv for mharc-grub-devel@gnu.org; Mon, 24 Oct 2022 07:24:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1omvYp-0001bd-BO for grub-devel@gnu.org; Mon, 24 Oct 2022 07:24:03 -0400 Received: from mo4-p01-ob.smtp.rzone.de ([81.169.146.165]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1omvYk-0001d2-Ou for grub-devel@gnu.org; Mon, 24 Oct 2022 07:24:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1666610620; s=strato-dkim-0002; d=novelsense.com; h=Message-ID:Date:Subject:In-Reply-To:References:Cc:To:From:Cc:Date: From:Subject:Sender; bh=BlnbckkLI1nmI+vH4YBwMzT4+o4o4phK6nq9E5Js/wY=; b=lvETgPIB8eWzW5nxjJtlAc7Th3dqoBgommaGk+sXXpHzNcWWpkfqhLPrgjGPgH4Kyd xP6df94p8CORwz1PE2/PLUhcTFmQyuNwVPkJhZQdZJfgn7scki6qAFGIyc1ekGl5hFug PWicMd4lrtT0JJ8WfRu2hX3AeGZNZ8ZqeCas6A8tC1fFBhZENwdFynQBDkO/DU0siMH+ Odt43eL6M044XJa6mPObDQ32uWdug4rhFrDYDPyc8tVZ6anpDYeJSGH6vNKUD+nBPGcL ZPwyrH95itcOLPLFbqDWcGP7wLKKISeFHzePRN8ybxwlX0SL5uIivqcJ2YH2L2i0ATcP wBMg== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":P28MekyyW/FuRqQOhYGtJMr0YcvcIev3suY5UMBvEvA20G1vQGGVl+SI6/0G9/d2MQO8ybbslUOpv/M8eN8rzC9w4FiO" X-RZG-CLASS-ID: mo00 Received: from DESKTOP0NC8IKQ by smtp.strato.de (RZmta 48.2.0 AUTH) with ESMTPSA id N73bc2y9OBNdpO6 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256 bits)) (Client did not present a certificate); Mon, 24 Oct 2022 13:23:39 +0200 (CEST) From: "Markus Scholz" To: Cc: , , , "'Daniel Kiper'" References: <032301d8de3f$990fe010$cb2fa030$@novelsense.com> <20221020173602.ls3hbhtnwhis4mrl@tomti.i.net-space.pl> In-Reply-To: <20221020173602.ls3hbhtnwhis4mrl@tomti.i.net-space.pl> Subject: AW: Adding --set to videoinfo to retrieve current video resolution Date: Mon, 24 Oct 2022 13:23:38 +0200 Message-ID: <00f501d8e79b$1073c7c0$315b5740$@novelsense.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQFLl7k4ZvZDucrDEG2kx8inGONqLAJc4q4AryUc8jA= Content-Language: de Received-SPF: none client-ip=81.169.146.165; envelope-from=scholz@novelsense.com; helo=mo4-p01-ob.smtp.rzone.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Oct 2022 11:24:03 -0000 Hi all, * I checked the links by Daniel (thanks for providing). * As I understand it Zhangs patches aim to add a high dpi scaling = feature for the fonts * In contrast, the patch I submitted (albeit having a similar use-case) = adds the possibility for grub "scripts" / config files to access & act upon the currently = used display resolution=20 * for me both things would have their merit and independent use-cases What is your opinion on having both features? Besides, I am willing to help progress both features - if someone can = guide me /give a hint how to proceed best? Thank you Markus -----Urspr=FCngliche Nachricht----- Von: Daniel Kiper =20 Gesendet: Donnerstag, 20. Oktober 2022 19:36 An: Markus Scholz Cc: grub-devel@gnu.org; phcoder@gmail.com; pmenzel@molgen.mpg.de; zhangboyang.id@gmail.com Betreff: Re: Adding --set to videoinfo to retrieve current video = resolution Adding Paul, Vladimir, and Zhang... On Wed, Oct 12, 2022 at 03:36:13PM +0200, Markus Scholz wrote: > Dear Grub Developers, > > recently we faced the problem the author in this old thread faced: > - https://lists.gnu.org/archive/html/grub-devel/2012-10/msg00009.html > > Ie. our theme wouldn't display properly due to different screen resolutions. > Hence, I wanted to change specifically the font size of our theme=20 > given the current resolution. > While the videoinfo module provides info about the current resolution=20 > I wasn't able to discover any way to get the info from the booted=20 > grub. > > Following the aforementioned thread, I therefore patched the videoinfo = > mod to add the ability of a -set switch just like commands like=20 > "smbinfo" or "search" have. > > Ie. the documentation of the videoinfo call could change as follows: > > Command: videoinfo [--set var | [WxH]xD] > > Retrieve available video modes. If --set is given, assign the=20 > currently active resolution to var. > If --set is not provided the available video modes are listed. > If resolution is given, show only matching modes. > > Attached is my patch proposal for the module; I probably made a lot=20 > mistakes wrt. > coding style and guidelines - please bear with me. > > I would be grateful regarding feedback what I could do / how I could=20 > improve the patch to make it part of grub? If it possible at all with = this approach? I think fix for similar problem has been proposed here [1] and I = commented it here [2]. Sadly it ended in limbo. Could you work with Zhang on this issue? Daniel [1] https://lists.gnu.org/archive/html/grub-devel/2022-06/msg00143.html [2] https://lists.gnu.org/archive/html/grub-devel/2022-07/msg00027.html > Thank you for your reply & best, > Markus > > --- > > --- grub-mod/grub-core/commands/videoinfo.c 2022-10-12 > 13:30:54.992451000 +0000 > +++ grub/grub-core/commands/videoinfo.c 2022-10-12 13:31:37.715512000 +0000 > @@ -30,7 +30,6 @@ GRUB_MOD_LICENSE ("GPLv3+"); struct hook_ctx { > unsigned height, width, depth; > - unsigned char set_variable; > struct grub_video_mode_info *current_mode; }; > > @@ -39,9 +38,6 @@ hook (const struct grub_video_mode_info { > struct hook_ctx *ctx =3D hook_arg; > > - if (ctx->set_variable) /* if variable should be set don't print all = > modes */ > - return 0; > - > if (ctx->height && ctx->width && (info->width !=3D ctx->width || > info->height !=3D ctx->height)) > return 0; > > @@ -136,40 +132,31 @@ grub_cmd_videoinfo (grub_command_t cmd _ > grub_video_adapter_t adapter; > grub_video_driver_id_t id; > struct hook_ctx ctx; > - > - ctx.height =3D ctx.width =3D ctx.depth =3D ctx.set_variable =3D 0; > - > + > + ctx.height =3D ctx.width =3D ctx.depth =3D 0; > if (argc) > { > - if (argc =3D=3D 2 && grub_memcmp(args[0], "--set", sizeof = ("--set") - 1) > =3D=3D 0 ) > - ctx.set_variable =3D 1; > - else > - { > const char *ptr; > ptr =3D args[0]; > ctx.width =3D grub_strtoul (ptr, &ptr, 0); > if (grub_errno) > - return grub_errno; > + return grub_errno; > if (*ptr !=3D 'x') > - return grub_error (GRUB_ERR_BAD_ARGUMENT, > - N_("invalid video mode specification `%s'"), > - args[0]); > + return grub_error (GRUB_ERR_BAD_ARGUMENT, > + N_("invalid video mode specification `%s'"), > + args[0]); > ptr++; > ctx.height =3D grub_strtoul (ptr, &ptr, 0); > if (grub_errno) > - return grub_errno; > + return grub_errno; > if (*ptr =3D=3D 'x') > - { > - ptr++; > - ctx.depth =3D grub_strtoul (ptr, &ptr, 0); > - if (grub_errno) > - return grub_errno; > - } > - } > - > + { > + ptr++; > + ctx.depth =3D grub_strtoul (ptr, &ptr, 0); > + if (grub_errno) > + return grub_errno; > + } > } > - > - > > #ifdef GRUB_MACHINE_PCBIOS > if (grub_strcmp (cmd->name, "vbeinfo") =3D=3D 0) @@ -177,23 +164,20 = @@=20 > grub_cmd_videoinfo (grub_command_t cmd _ #endif > > id =3D grub_video_get_driver_id (); > - if (!ctx.set_variable) > - { > -grub_puts_ (N_("List of supported video modes:")); -grub_puts_=20 > (N_("Legend: mask/position=3Dred/green/blue/reserved")); > - } > - > + > + grub_puts_ (N_("List of supported video modes:")); grub_puts_=20 > + (N_("Legend: mask/position=3Dred/green/blue/reserved")); > + > FOR_VIDEO_ADAPTERS (adapter) > { > struct grub_video_mode_info info; > struct grub_video_edid_info edid_info; > - if (!ctx.set_variable) > - grub_printf_ (N_("Adapter `%s':\n"), adapter->name); > + > + grub_printf_ (N_("Adapter `%s':\n"), adapter->name); > > if (!adapter->iterate) > { > - if (!ctx.set_variable) > - grub_puts_ (N_(" No info available")); > + grub_puts_ (N_(" No info available")); > continue; > } > > @@ -202,18 +186,7 @@ grub_puts_ (N_("Legend: mask/position=3Dre > if (adapter->id =3D=3D id) > { > if (grub_video_get_info (&info) =3D=3D GRUB_ERR_NONE) > - { > - ctx.current_mode =3D &info; > - if (ctx.set_variable) > - { > - /* set grub env var to current mode */ > - char screen_wxh[20]; > - unsigned int width =3D info.width; > - unsigned int height =3D info.height; > - grub_snprintf (screen_wxh, 20, "%ux%u", width, height); > - grub_env_set (args[1], screen_wxh); > - } > - } > + ctx.current_mode =3D &info; > else > /* Don't worry about errors. */ > grub_errno =3D GRUB_ERR_NONE; > @@ -263,26 +236,19 @@ GRUB_MOD_INIT(videoinfo) > /* TRANSLATORS: "x" has to be entered in, > like an identifier, so please don't > use better Unicode codepoints. */ > - N_("[--set var | [WxH]xD]"), > - N_("Retrieve available video modes. " > - "--set is given, assign the currently" > - "active resolution to var. If --set " > - "is not provided the available video " > - "modes are listed. If resolution is " > - "given, show only matching modes.")); > - > + N_("[WxH[xD]]"), > + N_("List available video modes. If " > + "resolution is given show only modes" > + " matching it.")); > #ifdef GRUB_MACHINE_PCBIOS > cmd_vbe =3D grub_register_command ("vbeinfo", grub_cmd_videoinfo, > /* TRANSLATORS: "x" has to be entered in, > like an identifier, so please don't > use better Unicode codepoints. */ > - N_("[--set var | [WxH]xD]"), > - N_("Retrieve available video modes. " > - "--set is given, assign the currently" > - "active resolution to var. If --set " > - "is not provided the available video " > - "modes are listed. If resolution is " > - "given, show only matching modes.")); > + N_("[WxH[xD]]"), > + N_("List available video modes. If " > + "resolution is given show only modes" > + " matching it.")); > #endif > }