2022年11月23日水曜日

Thinkpad L570 の LCD調整とか

Thinkpad の輝度調整は、debian のパッケージにある、 `tpb/stable,now 0.6.4-11 amd64 (program to use the IBM ThinkPad(tm) special keys)` を入れて、xbacklight を割り付けて、問題なく使えていたのだが、 最近、機能しないことに気付いた。

どのタイミングからなのか記憶にないのは別の問題だが。intel のドライバーを削除したから??

現状、対応してないようなので、xrandar を使う方法にしてみた。

いつものように、先人のスクリプトを利用させていただいた。感謝しかない!! 今回は、いくつか見付けた中から、以下にお世話になった。

#!/bin/bash

# MON="DP-1-1"    # Discover monitor name with: xrandr | grep " connected"
MON=$(xrandr | grep " connected" | cut -f1 -d" ")
STEP=5          # Step Up/Down brightnes by: 5 = ".05", 10 = ".10", etc.

CurrBright=$( xrandr --verbose --current | grep ^"$MON" -A5 | tail -n1 )
CurrBright="${CurrBright##* }"  # Get brightness level with decimal place

Left=${CurrBright%%"."*}        # Extract left of decimal point
Right=${CurrBright#*"."}        # Extract right of decimal point

MathBright="0"
[[ "$Left" != 0 && "$STEP" -lt 10 ]] && STEP=10     # > 1.0, only .1 works
[[ "$Left" != 0 ]] && MathBright="$Left"00          # 1.0 becomes "100"
[[ "${#Right}" -eq 1 ]] && Right="$Right"0          # 0.5 becomes "50"
MathBright=$(( MathBright + Right ))

[[ "$1" == "Up" || "$1" == "+" ]] && MathBright=$(( MathBright + STEP ))
[[ "$1" == "Down" || "$1" == "-" ]] && MathBright=$(( MathBright - STEP ))
[[ "${MathBright:0:1}" == "-" ]] && MathBright=0    # Negative not allowed
[[ "$MathBright" -gt 999  ]] && MathBright=999      # Can't go over 9.99

if [[ "${#MathBright}" -eq 3 ]] ; then
    MathBright="$MathBright"000         # Pad with lots of zeros
    CurrBright="${MathBright:0:1}.${MathBright:1:2}"
else
    MathBright="$MathBright"000         # Pad with lots of zeros
    CurrBright=".${MathBright:0:2}"
fi

xrandr --output "$MON" --brightness "$CurrBright"   # Set new brightness

こんな、shell script がサクっと書けるようになれたらいいな。
こいつを `i3` の設定で volume key に割付て終了。

ついでに、gamma も調整してみると、0.8 ぐらいが夜中の作業にはよさそう。
ということで、調子こいてスクリプトをかいてみた。夜の作業でも、深夜と明け方では変更したかったから。
こんなのでも、調べながらなので、1時間弱かかってしまった。

#!/bin/bash

if [[ $* == "--help" || $* == "-h" || $# -lt 1 ]];
then
    echo "Usage: $0 ( colorshift [d0|d1|n0|n1] )"
    exit 0
fi

# bash  [[]]の内側は、
# 単語分割が無効
# パス名展開が無効
# 空文字列も1つの要素として扱われる

if [ "$1" = 'n0' ]; then
    command='xrandr --output eDP-1 --gamma 0.9:0.8:0.8 --brightness 0.9'
elif [ "$1" = 'n1' ]; then
    command='xrandr --output eDP-1 --gamma 0.8:0.7:0.7 --brightness 0.8'
elif [ "$1" = 'd0' ]; then
    command='xrandr --output eDP-1 --gamma 1.0:1.0:1.0 --brightness 1.0'
elif [ "$1" = 'd1' ]; then
    command='xrandr --output eDP-1 --gamma 1.0:1.0:1.1 --brightness 1.15'
else
    echo " >> colorshift [[d0|d1|n0|n1]: $1"
    exit 1
fi

eval "$command"

細かな数値は、実際に使いながら調整してゆけばよいのだろう。

まあ、とりあえず、よしとしよう。

Emacs の lsp の設定、なう(202310)

前回さらしてから、さらに1年。そう、3年めになる。 が、今回は一段と自信がない。 環境は、 Debian GNU/Linux 12 (bookworm) + emacs(29.1)。consult + company。 embark は未だに使ってない。 用途は、メモ と ...