Last active
February 20, 2025 00:13
-
-
Save mrevjd/b034c3afaba3f2627fb1c47291885f3b to your computer and use it in GitHub Desktop.
Cursor Setup for WSL
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
| source /etc/os-release | |
| OS=$NAME | |
| if [[ "$OS" =~ Ubuntu ]]; then | |
| echo "Ubuntu found" | |
| DISTRO=UB | |
| elif [[ "$OS" =~ Debian ]]; then | |
| echo "Debian found" | |
| DISTRO=DEB | |
| elif [[ "$OS" =~ AlmaLinux ]]; then | |
| echo "AlmaLinux found" | |
| DISTRO=ALMA | |
| else | |
| echo "FATAL: Unknown OS found: $OS" | |
| exit 1; | |
| fi | |
| if apt --version >/dev/null 2>&1; then | |
| sudo apt -y install dmz-cursor-theme breeze-cursor-theme | |
| fi | |
| if dnf --version >/dev/null 2>&1; then | |
| sudo dnf -y install adwaita-cursor-theme breeze-cursor-theme | |
| fi | |
| wget -O ~/set-cursor.sh https://gist.github.com/mrevjd/b034c3afaba3f2627fb1c47291885f3b/raw/set-cursor.sh | |
| chmod +x ~/set-cursor.sh |
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
| #!/bin/bash | |
| # Originally from https://gist.github.com/egrath/85cadf516d90eddb0cbc25762357fb80 | |
| # Modified to handle arguments more robustly | |
| THEME="breeze" # Default theme | |
| SIZE="24" # Default size | |
| usage() { | |
| echo "Usage: $(basename $0) [--theme THEME] [--size SIZE]" | |
| echo " --theme THEME : cursor theme name (default: breeze)" | |
| echo " --size SIZE : cursor size (default: 24)" | |
| echo " -h, --help : show this help message" | |
| exit 1 | |
| } | |
| # Parse named arguments in any order | |
| while [[ $# -gt 0 ]]; do | |
| case $1 in | |
| --theme) | |
| if [ -z "$2" ] || [[ "$2" == -* ]]; then | |
| echo "Error: --theme requires a value" | |
| usage | |
| fi | |
| THEME="$2" | |
| shift 2 | |
| ;; | |
| --size) | |
| if [ -z "$2" ] || [[ "$2" == -* ]]; then | |
| echo "Error: --size requires a value" | |
| usage | |
| fi | |
| if ! [[ "$2" =~ ^[0-9]+$ ]]; then | |
| echo "Error: size must be a number" | |
| usage | |
| fi | |
| SIZE="$2" | |
| shift 2 | |
| ;; | |
| -h|--help) | |
| usage | |
| ;; | |
| *) | |
| echo "Unknown parameter: $1" | |
| usage | |
| ;; | |
| esac | |
| done | |
| echo "Setting cursor theme to '${THEME}' with size ${SIZE}" | |
| echo "Setting for GNOME ..." | |
| gsettings set org.gnome.desktop.interface cursor-theme "${THEME}" | |
| gsettings set org.gnome.desktop.interface cursor-size ${SIZE} | |
| ## Only for Deepin Linux | |
| if [ -f /etc/lsb-release ]; then | |
| if grep -qi "Deepin" /etc/lsb-release; then | |
| gsettings set com.deepin.wrap.gnome.desktop.interface cursor-size ${SIZE} | |
| gsettings set com.deepin.xsettings gtk-cursor-theme-size ${SIZE} | |
| gsettings set com.deepin.wrap.gnome.desktop.interface cursor-theme "${THEME}" | |
| gsettings set com.deepin.xsettings gtk-cursor-theme-name "${THEME}" | |
| gsettings set com.deepin.dde.appearance cursor-theme "${THEME}" | |
| fi | |
| fi | |
| echo "Setting for icons ..." | |
| if [ -f ~/.icons/default/index.theme ]; then | |
| rm ~/.icons/default/index.theme | |
| fi | |
| mkdir -p ~/.icons/default | |
| echo "[icon theme]" > ~/.icons/default/index.theme | |
| echo "Inherits=${THEME}" >> ~/.icons/default/index.theme | |
| echo "Setting for GTK-3.0 ..." | |
| if [ -f ~/.config/gtk-3.0/settings.ini ]; then | |
| rm ~/.config/gtk-3.0/settings.ini | |
| fi | |
| mkdir -p ~/.config/gtk-3.0 | |
| echo "[Settings]" > ~/.config/gtk-3.0/settings.ini | |
| echo "gtk-cursor-theme-name=${THEME}" >> ~/.config/gtk-3.0/settings.ini | |
| echo "Setting for Legacy X ..." | |
| if [ -f ~/.xinitrc ]; then | |
| sed -i '/.*XCURSOR_THEME.*/Id' ~/.xinitrc | |
| sed -i '/.*XCURSOR_SIZE.*/Id' ~/.xinitrc | |
| fi | |
| echo "export XCURSOR_SIZE=${SIZE}" >> ~/.xinitrc | |
| echo "export XCURSOR_THEME=${THEME}" >> ~/.xinitrc | |
| if [ -f ~/.Xresources ]; then | |
| sed -i '/.*xcursor.size.*/Id' ~/.Xresources | |
| sed -i '/.*xcursor.theme.*/Id' ~/.Xresources | |
| fi | |
| echo "Xcursor.size: ${SIZE}" >> ~/.Xresources | |
| echo "Xcursor.theme: ${THEME}" >> ~/.Xresources | |
| echo "Cursor theme setup complete!" | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment