Skip to content

Instantly share code, notes, and snippets.

@anroots
Last active August 29, 2015 14:02
Show Gist options
  • Save anroots/259cdb7c6e28b36ca711 to your computer and use it in GitHub Desktop.
Save anroots/259cdb7c6e28b36ca711 to your computer and use it in GitHub Desktop.
razercfg udev rule to automatically set DPI when the mouse is connected
# UDEV rules for razer devices
# Change script path!
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="1532", ATTR{idProduct}=="0015", RUN+="/home/david/bin/razer-connect.sh"
ACTION=="remove", SUBSYSTEM=="usb", RUN+="/usr/local/bin/razercfg -B -S1 -s"
#!/bin/bash
# This script is run by udev when Razer Naga mouse is connected.
# Sets the DPI and displays a message on notify-send
export DISPLAY=:0
# Scan resolution (*1000)
RES=30
# Show a message via notify-send, including icon
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
notify-send 'Razer Naga Connected' "Resolution set to $RES DPI" -i "$DIR/razer-connect.ico"
# Set scan resolution
razercfg -r "1:$RES"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment