From nobody Sun Jul 07 19:27:54 2024 X-Original-To: freebsd-stable@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WHHN1426yz5QM7F for ; Sun, 07 Jul 2024 19:28:01 +0000 (UTC) (envelope-from freebsd-stable@m.gmane-mx.org) Received: from ciao.gmane.io (ciao.gmane.io [116.202.254.214]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4WHHN05vqLz46wf for ; Sun, 7 Jul 2024 19:28:00 +0000 (UTC) (envelope-from freebsd-stable@m.gmane-mx.org) Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); spf=pass (mx1.freebsd.org: domain of freebsd-stable@m.gmane-mx.org designates 116.202.254.214 as permitted sender) smtp.mailfrom=freebsd-stable@m.gmane-mx.org Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1sQXYF-000A1X-EI for freebsd-stable@freebsd.org; Sun, 07 Jul 2024 21:27:59 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: freebsd-stable@freebsd.org From: Anton Shepelev Subject: Re: Need help controlling laptom display brightness via sysctl Date: Sun, 7 Jul 2024 22:27:54 +0300 Message-ID: <20240707222754.2a531eb3344cb4644c571c66@gmail.com> References: <20240704010029.75608a4e49205eb38a6034be@gmail.com> <20240705005834.4c7983ea29da3af8f8e36718@gmail.com> List-Id: Production branch of FreeBSD source code List-Archive: https://lists.freebsd.org/archives/freebsd-stable List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: freebsd-stable@freebsd.org Sender: owner-freebsd-stable@FreeBSD.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) X-Spamd-Bar: + X-Spamd-Result: default: False [1.76 / 15.00]; NEURAL_SPAM_LONG(1.00)[1.000]; NEURAL_SPAM_MEDIUM(1.00)[0.999]; NEURAL_HAM_SHORT(-0.94)[-0.943]; MV_CASE(0.50)[]; FORGED_SENDER(0.30)[antontxt@gmail.com,freebsd-stable@m.gmane-mx.org]; R_SPF_ALLOW(-0.20)[+mx]; DMARC_POLICY_SOFTFAIL(0.10)[gmail.com : SPF not aligned (relaxed), No valid DKIM,none]; MIME_GOOD(-0.10)[text/plain]; ONCE_RECEIVED(0.10)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; RCPT_COUNT_ONE(0.00)[1]; TAGGED_FROM(0.00)[]; MISSING_XM_UA(0.00)[]; TO_DN_NONE(0.00)[]; R_DKIM_NA(0.00)[]; MLMMJ_DEST(0.00)[freebsd-stable@freebsd.org]; FROM_NEQ_ENVFROM(0.00)[antontxt@gmail.com,freebsd-stable@m.gmane-mx.org]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_COUNT_ONE(0.00)[1]; ASN(0.00)[asn:24940, ipnet:116.202.0.0/16, country:DE]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[] X-Rspamd-Queue-Id: 4WHHN05vqLz46wf I wrote to Kevin Oberman: > I fear you missed my point that HP seems to have a > different approach to these ACPI events. In ThinkPad, the > up- and down-brighness events have fixed notify codes: > 0x10 and 0x11. In HP, on the other hand, the notify codes > represent the target brightness level on a 0..100 scale, > so that consequtive presses of Fn+F3 yield an arithmetical > progression of notify codes, e.g. 51,52,53 &c, which is > why the simplest solution is to subsitute the notify value > into the invocation of `backlight'. > > Translating those codes into exponential changes would > require first of all to recall the previous value in order > to determine whether the current event is an increase or a > decrease. Indeed, and here is my final devd action stript: REF=50 # an (arbitrary) reference value NEW=$1 # the new brightness value as recevied from ACPI # Ignore the ref. value to avoid an infinite loop: if [ $NEW -eq $REF ]; then exit 0; fi # Determine whether to increase or decrease the brightness: if [ $NEW -lt $REF ]; then OP=decr else OP=incr; fi # Change brightness: backlight $OP # Restore the reference value: sysctl hw.acpi.video.lcd0.brightness=$REF # (in this system it has no effect on the actual brightness)