可以用C改变屏幕亮度吗?
在Linux中使用C语言,可以改变观看屏幕的亮度吗?除了在我安装的 Ubuntu 和 Fedora 上运行之外,预计它不会是可移植的。我问的是如何与操作系统交互来改变亮度。
Using C in Linux, would it be possible to change the brightness of the viewing screen? This isn't expected to be portable other than running on my installs of Ubuntu and Fedora. I'm asking about how I would interface with the os to change the brightness.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我首先从下面的 ubuntu 软件包列表中进行选择,该工具允许您管理屏幕亮度(提示:这取决于品牌)
一旦您选择了它,
应该会让您走上正确的道路
I'd start with selecting from the following list of ubuntu pacakges, the tool that allows you to manage your screen's brightness (hint: it depends on the brand)
Once you have selected it,
should get you on the right track
戳
/sys/class/backlight/*/brightness
。是的,即使是在 C 语言中。Poke
/sys/class/backlight/*/brightness
. Yes, even in C.是的,但不可移植——你需要一个特定于平台的函数,C 标准库中没有任何东西。
Yes, but not portably -- you need a platform-specific function, there is nothing in the C standard library.
查看 xbacklight 源。例如,以下代码将屏幕亮度设置为 50%。
Check out the xbacklight source. For example, the following code sets the screen brightness to 50%.