From 219d855945eed65e46387882bf5f745f2b45c317 Mon Sep 17 00:00:00 2001 From: "A.Levin" Date: Fri, 12 Dec 2025 14:29:57 +0300 Subject: [PATCH] Add grayscale toggle script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Toggle grayscale mode on dual GPU (NVIDIA + Intel) Linux setup - Organized with folder structure: each script has its own directory with README 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- README.md | 9 ++++++++- grayscale/README.md | 29 +++++++++++++++++++++++++++++ grayscale/grayscale | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 grayscale/README.md create mode 100755 grayscale/grayscale diff --git a/README.md b/README.md index ff0287e..78995a0 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,9 @@ # scripts -my scripts with descritpion + +Personal shell scripts collection. + +## Scripts + +| Script | Description | +|--------|-------------| +| [grayscale](grayscale/README.md) | Toggle grayscale mode on dual GPU (NVIDIA + Intel) Linux | diff --git a/grayscale/README.md b/grayscale/README.md new file mode 100644 index 0000000..ab4e5c5 --- /dev/null +++ b/grayscale/README.md @@ -0,0 +1,29 @@ +# grayscale + +Toggle grayscale mode on Linux with NVIDIA + Intel hybrid graphics. + +## Usage + +```bash +grayscale # toggle +grayscale on # enable grayscale +grayscale off # disable grayscale +``` + +## How it works + +- **NVIDIA**: Uses `nvidia-settings -a DigitalVibrance=-1024` +- **Intel**: Uses xrandr CTM (Color Transformation Matrix) + +## Requirements + +- NVIDIA GPU with `nvidia-settings` +- Intel GPU with xrandr CTM support +- X11 + +## Installation + +```bash +cp grayscale ~/bin/ +chmod +x ~/bin/grayscale +``` diff --git a/grayscale/grayscale b/grayscale/grayscale new file mode 100755 index 0000000..4fa7d5a --- /dev/null +++ b/grayscale/grayscale @@ -0,0 +1,35 @@ +#!/bin/bash + +STATE_FILE="$HOME/.grayscale_state" + +set_grayscale() { + nvidia-settings -a DigitalVibrance=-1024 >/dev/null 2>&1 + xrandr --output eDP-1-1 --set CTM "0.299,0.587,0.114,0.299,0.587,0.114,0.299,0.587,0.114" 2>/dev/null + echo "on" > "$STATE_FILE" + echo "Grayscale: ON" +} + +set_normal() { + nvidia-settings -a DigitalVibrance=0 >/dev/null 2>&1 + xrandr --output eDP-1-1 --set CTM "1,0,0,0,1,0,0,0,1" 2>/dev/null + echo "off" > "$STATE_FILE" + echo "Grayscale: OFF" +} + +toggle() { + if [[ -f "$STATE_FILE" ]] && [[ "$(cat "$STATE_FILE")" == "on" ]]; then + set_normal + else + set_grayscale + fi +} + +case "${1:-toggle}" in + on) set_grayscale ;; + off) set_normal ;; + toggle) toggle ;; + *) + echo "Usage: grayscale [on|off|toggle]" + exit 1 + ;; +esac