[英]Create a GNOME shell extension that enables and disables the webcam
I would like to create a shell extension for Ubuntu 20.04 that enables and disables the webcam but I don't know absolutely anything about JavaScript.我想为 Ubuntu 20.04 创建一个 shell 扩展,以启用和禁用网络摄像头,但我对 Z686155AF75A60A0F6E9D80C1F7EDD3 一无所知Although, the extension is pretty simple: I would like to make a simple camera icon in the top bar that虽然,扩展非常简单:我想在顶部栏中制作一个简单的相机图标
sudo modprobe -r uvcvideo
, to disable the webcam.单击时会被划掉并执行sudo modprobe -r uvcvideo
,以禁用网络摄像头。sudo modprobe uvcvideo
and the icon returns to the one before, enabling the webcam.然后重新单击时,只需运行sudo modprobe uvcvideo
并且图标返回到之前的图标,启用网络摄像头。How can I do it?我该怎么做?
EDIT: I made it by myself in GO, if you're searching for it here it is https://github.com/0xfederama/simple-tasks编辑:我自己在 GO 中制作的,如果你在这里搜索它是https://github.com/0xfederama/simple-tasks
You should probably start by looking through the tutorial on the GNOME Wiki:您可能应该从查看 GNOME Wiki 上的教程开始:
https://wiki.gnome.org/Projects/GnomeShell/Extensions/Writing https://wiki.gnome.org/Projects/GnomeShell/Extensions/Writing
When spawning your command, you're probably going to want to use pkexec
instead of sudo
.在生成命令时,您可能会想要使用pkexec
而不是sudo
。 I wouldn't recommend doing anything requiring superuser access in an extension, but pkexec
will at least work properly in a GUI environment.我不建议在扩展中做任何需要超级用户访问的事情,但pkexec
至少可以在 GUI 环境中正常工作。
To spawn your command, you can probably get away withGLib.spawn_command_line_async()
, although I always prefer GSubprocess
myself.要生成您的命令,您可能可以使用GLib.spawn_command_line_async()
,尽管我自己总是更喜欢GSubprocess
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.