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