Created
February 7, 2026 04:17
-
-
Save teklynk/e295ead7d1d8e6e5fd1f187fc6344060 to your computer and use it in GitHub Desktop.
Toggle Webcam on off
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # enable / disable all UVC devices/cameras | |
| # No arguments - auto‑toggle based on whether the uvcvideo module is loaded | |
| # on = force load the driver | |
| # off = force unload the driver | |
| if [[ -z "$DISPLAY" ]]; then | |
| export DISPLAY=:0 | |
| fi | |
| ACTION="$1" | |
| if [[ -z "$ACTION" ]]; then | |
| # Toggle: if the module is exists then unload it, else load it | |
| if lsmod | grep -q '^uvcvideo'; then | |
| ACTION="off" | |
| else | |
| ACTION="on" | |
| fi | |
| fi | |
| case "$ACTION" in | |
| off) | |
| sudo modprobe -r uvcvideo && \ | |
| echo "All UVC cameras disabled" && \ | |
| play /usr/share/mint-artwork/sounds/unplug.oga 2>/dev/null & \ | |
| notify-send "Turning UVC Cameras Off..." | |
| ;; | |
| on|*) | |
| sudo modprobe uvcvideo && \ | |
| echo "All UVC cameras enabled" && \ | |
| play /usr/share/mint-artwork/sounds/plug.oga 2>/dev/null & \ | |
| notify-send "Turning UVC Cameras On..." | |
| ;; | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment