作業系統:Ubuntu - 18.04 LTS
我的目錄中有 2 個符號連結/sys/class/backlight/
。
acpi_video0 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/backlight/acpi_video0/
nv_backlight -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card0/card0-LVDS-1/nv_backlight/
亮度熱鍵可變更 的值acpi_video0/brightness
。但這其實並沒有改變顯示器的亮度。
但是,手動更改該值nv_backlight/brightness
實際上會改變顯示器的亮度。
因此,將熱鍵連結到nv_backlight
而不是acpi_video0
可以解決我的問題,但我不知道該怎麼做。
編輯:操作Fn鍵調整亮度(熱鍵)時,螢幕上會出現彈出滑桿進度條。
編輯:
輸入:
cat /sys/class/backlight/nv_backlight/max_brightness
輸出:
100
輸入:
cat /sys/class/backlight/nv_backlight/actual_brightness
輸出(這個值自動改為相同的值,我手動輸入
/sys/class/backlight/nv_backlight/brightness
):10
輸入:
cat /sys/class/backlight/acpi_video0/max_brightness
輸出:
15
答案1
bash腳本redirect-brightness
您的問題是增加/減少亮度的功能鍵正在更新/sys/class/backlight/acpi_video0/brightness
而不是/sys/class/backlight/nv_backlight/brightness
最初的請求是攔截功能鍵並用它們來控制nv_backlight
驅動程式。這樣做的問題是:
- 棘手的
udev
腳本 - 沒有彈出通知滑桿顯示亮度,無需複雜的 Python 腳本。
解決方案是使用來inotify
監視acpi_video0
.然後計算亮度百分比並將相同的百分比套用到nv_backlight
。
在下面的 bash 腳本中您需要設定:
WatchDriver="/sys/class/backlight/acpi_video0/brightness"
PatchDriver="/sys/class/backlight/nv_backlight/brightness"
將腳本放入/usr/local/bin
並使用以下命令使其可執行:
chmod a+x /usr/local/bin/redirect-brightness
首先使用命令列運行腳本
redirect-brightness -l
如果出現問題,請使用以下命令檢查日誌檔案:
cat /tmp/redirect-brightness.log
如果一切正常,請添加redirect-brightness
到您的啟動應用程式中。
redirect-brightness
bash腳本
#!/bin/bash
# NAME: redirect-brightness
# PATH: /usr/local/bin
# DESC: Redirect to correct driver when Ubuntu is adjusting the wrong
# /sys/class/DRIVER_NAME/brightness
# DATE: June 13, 2018. Modified June 14, 2018.
# NOTE: Written for Ubuntu question:
# https://askubuntu.com/q/1045624/307523
WatchDriver="/sys/class/backlight/intel_backlight"
PatchDriver="/sys/class/backlight/intel_backlight"
# Must be running as sudo
if [[ $(id -u) != 0 ]]; then
echo >&2 "Root access required. Use: 'sudo redirect-brightness'"
exit 1
fi
# inotifywait required
type inotifywait >/dev/null 2>&1 || \
{ echo >&2 "'inotifywait' required but it's not installed. Aborting."; \
echo >&2 "Use 'sudo apt install inotify-tools' to install it.'"; \
exit 1; }
# Was right watch driver directory name setup correctly?
if [[ ! -d $WatchDriver ]]; then
echo >&2 "Watch directory: '$WatchDriver'"; \
echo >&2 "does not exist. Did you spell it correctly? Aborting.'"; \
exit 1;
fi
# Was right patch driver directory name setup correctly?
if [[ ! -d $PatchDriver ]]; then
echo >&2 "Redirect to directory: '$PatchDriver'"; \
echo >&2 "does not exist. Did you spell it correctly? Aborting.'"; \
exit 1;
fi
# Get maximum brightness values
WatchMax=$(cat $WatchDriver/max_brightness)
PatchMax=$(cat $PatchDriver/max_brightness)
# PARM: 1="-l" or "--log-file" then write each step to log file.
fLogFile=false
if [[ $1 == "-l" ]] || [[ $1 == "--log-file" ]]; then
fLogFile=true
LogFile=/tmp/redirect-brightness.log
echo redirect-brightness LOG FILE > $LogFile
echo WatchMax: $WatchMax PatchMax: $PatchMax >> $LogFile
fi
SetBrightness () {
# Calculate watch current percentage
WatchAct=$(cat $WatchDriver/actual_brightness)
WatchPer=$(( WatchAct * 100 / WatchMax ))
[[ $fLogFile == true ]] && echo WatchAct: $WatchAct WatchPer: $WatchPer >> $LogFile
# Reverse engineer patch brightness to set
PatchAct=$(( PatchMax * WatchPer / 100 ))
echo $PatchAct | sudo tee $PatchDriver/brightness
[[ $fLogFile == true ]] && echo PatchAct: $PatchAct >> $LogFile
}
# When machine boots, set brightness to last saved value
SetBrightness
# Wait forever for user to press Fn keys adjusting brightness up/down.
while (true); do
inotifywait --event modify $WatchDriver/actual_brightness
[[ $fLogFile == true ]] && \
echo "Processing modify event in $WatchDriver/actual_brightness" >> $LogFile
SetBrightness
done
原答案 2018 年 6 月 11 日。
正在進行中的工作答案
有許多 nVidia 用戶在 Ubuntu 18.04 中遇到類似問題:
- Ubuntu 18.04 中配備 NVIDIA GTX 1060 Mobile 的筆記型電腦 MSI GT72VR 的亮度不起作用
- 電腦無法從暫停中喚醒並且無法更改亮度
- 使用 Nvidia 驅動程式時亮度控制遺失,但使用 X.Org 時又重新出現
- Xubuntu 18.04:讓 Fn 亮度鍵與 /sys/class/backlight/nv_backlight/ 一起使用
- 如何在lubuntu中更改背光驅動
- Ubuntu 18.04 中配備 NVIDIA GTX 1060 Mobile 的筆記型電腦 MSI GT72VR 的亮度不起作用
- 亮度控制和視訊播放方面的 NVIDIA 顯示問題
- 無法變更螢幕亮度
- 筆記型電腦螢幕的亮度無法透過按鈕或滑桿調整。編輯
在編寫腳本之前
我可以編寫一個腳本來模擬對 /acpi_video 的更改並填充 /nv_backlight 但在嘗試此操作之前:
- 編輯
/etc/default/grub
。 - 尋找
quiet splash
- 在飛濺後面添加:
acpi_backlight=vendor
- 儲存檔案
- 跑步
sudo update-grub
根據這個答案,它應該適合你:Xubuntu 18.04:讓 Fn 亮度鍵與 /sys/class/backlight/nv_backlight/ 一起使用
韋蘭
亮度在 Wayland 下不起作用。確保您沒有使用它。看:筆記型電腦螢幕的亮度無法透過按鈕或滑桿調整。編輯