Skip to content

Instantly share code, notes, and snippets.

@jjwatt
Created July 19, 2024 17:00
Show Gist options
  • Save jjwatt/197c8db66ecf802c9851cedfcf4df1b5 to your computer and use it in GitHub Desktop.
Save jjwatt/197c8db66ecf802c9851cedfcf4df1b5 to your computer and use it in GitHub Desktop.
#!/bin/bash
: ${IDLE:=swayidle}
: ${YDOTOOL_SOCKET:=/tmp/.ydotool_socket}
stayawake() {
# Get screen dimensions using wlr-randr (for wlroots-based compositors)
# NOTE(jjwatt): Does not work on Plasma 5 Wayland
# read screenwidth screenheight << EOF
# $(wlr-randr | awk '/current/ {print $1, $3}' | tr 'x' ' ')
# EOF
# : ${screenwidth:=1920}
# : ${screenheight=1080}
"${IDLE}" -w timeout 5 \
'ydotool mousemove 1920 1080'
}
# Make sure ydotool daemon is running
sudo pkill ydotoold
sudo ydotoold &
sudo chmod 777 "$YDOTOOL_SOCKET"
# Run the function
stayawake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment