手动实现黑白阅读模式-win10+ubuntu

手动实现黑白阅读模式-win10+ubuntu

概要

本文通过调节系统/显卡驱动的设定的方式来实现显示器黑白阅读的体验.

起由

最近深感一半时间都是与屏幕交互的,好的屏幕能提升学习娱乐效率,无奈囊中羞涩.决定买入门级的Philips的278E1显示器.满足基础的阅读/观影/办公的需求.从性价比来看在27吋/4K/IPS/1600RMB的段位来看,163 PPI/ 350 cd/m²/10Bit/sRGB 109%/Delta E<2, 这个spec可以算是很硬核了.当前公司给配的显示器就是Philips的,用户体验还不错.选显示器的话可以浏览一下这篇文章.
在线屏幕色彩检测网站:
https://www.eizo.nl/monitor-test/
https://screen.bmcx.com/#welcome

相应地Type-c/USB接口,旋转升降,Pilips普遍带的easyread等功能都被砍掉了.这些功能用的机率非常小砍掉省成本也罢.唯一遗憾的是easyread的一键黑白显示的功能.又不是调成墨水屏那样的渲染,只是把多通道改成单通道的灰度显示的原理?应该不难吧.遂决定手动实现easyread功能.

Win10

windows还是用户友好,居然都预设好了,只需要开启并且还给留了默认的快捷键,另外还有色盲模式,很够用了.
具体,搜索颜色滤镜,选择打开颜色滤镜以及允许使用快捷键,即可实现win+ctrl+c键切换彩色与黑白显示.下面还有色盲模式.
win10

Ubuntu

通过调节nvidia驱动的配置实现.DigitalVibrance参数是与色彩显示相关的.先通过命令查询当前状态. nvidia-setting参考链接.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
nvidia-settings --query DigitalVibrance #查询命令

Attribute 'DigitalVibrance' (cxHD:1[dpy:0]): 0. #显示器0的DigitalVibrance值,范围是-1024 - 1023,越小灰度越高越大色度越高
The valid values for 'DigitalVibrance' are in the range -1024 - 1023
(inclusive).
'DigitalVibrance' is display device specific.
'DigitalVibrance' can use the following target types: X Screen, GPU,
Display Device.
Attribute 'DigitalVibrance' (cxHD:1[dpy:2]): 0. #显示器2的DigitalVibrance值,范围是-1024 - 1023,越小灰度越高越大色度越高
The valid values for 'DigitalVibrance' are in the range -1024 - 1023
(inclusive).
'DigitalVibrance' is display device specific.
'DigitalVibrance' can use the following target types: X Screen, GPU,
Display Device.

然后设置DigitalVibrance值为-1024.

1
2
nvidia-settings --assign [dpy:0]/DigitalVibrance=-1024 #显示器0
nvidia-settings --assign [dpy:0]/DigitalVibrance=-1024 #显示器2

效果如下:
DigitalVibrance_-1024

需要注意的是,上面的操作只是实现显示器端的黑白化,系统内部仍旧是彩色的,因此通过截屏得到的图片还是彩色的.

笔者还尝试将值设为了+1023上限值,色彩的确丰富了很多,稍显刺眼,还是设回了默认值0,如果遇到对色彩有要求的场景也许设为+1023是个不错的选择.

当然所有操作的前提是装了nvidia的驱动程序.安装可以参考链接

也可以把命令绑定到自定义的快捷键上即可实现一键切换.如下展示:

一键实现color模式与grayscale模式的反转

先写一个实现反转的shell脚本然后绑定到快捷键上.每个人的设置可能不同,或许需要根据具体环境修改.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash

#This script is to reverse screens color mode or grayscale mode
nvidia-settings --query DigitalVibrance |
grep "Attribute 'DigitalVibrance'" |
awk -F[ '{print $NF}' |
sed 's/]): /:/g' |
sed 's/.$//g' |
awk -F: '{if(0==$NF) print "nvidia-settings -a ["$1":"$2"]/DigitalVibrance=-1024"; \
else print "nvidia-settings -a ["$1":"$2"]/DigitalVibrance=0";}' >temp_reverse_color_grayscale

while read -r line; do
eval $line
done < temp_reverse_color_grayscale

rm -f temp_reverse_color_grayscale

echo -e " Finished! Existing...."
sleep 2
#exec bash

# you need to add the following command to bind a shortcut.
# For example, ctrl+superkey+c just like win10 setting.
# gnome-terminal -x bash -c "~/Desktop/scipt/reverse_color_grayscale.sh"

绑定快捷键GUI操作(Ubuntu18): 右上角设置-Devices-Keyboard-最下方的+号.

手动实现黑白阅读模式-win10+ubuntu

https://www.chuxin911.com/set_sreen_grayscale_20210730/

作者

cx

发布于

2021-07-30

更新于

2022-07-16

许可协议