Created
June 17, 2016 15:15
-
-
Save PhilHudson/377837908a2dbe43ee4c2b6d84898604 to your computer and use it in GitHub Desktop.
Dual-screen interactive slideshow screensaver for MATE
This file contains 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
#!/usr/bin/env bash | |
# Standard-repo requirements: | |
# w, awk, head, mktemp, split, grep, ck-list-sessions, sed, getent, cut | |
# TODO Check whether awk can't exit immediately after first match | |
ACTIVE_USER=`w --no-header -s | awk '/ :0 / {print $1}' | head -1` | |
[ -n "$ACTIVE_USER" ] && { | |
echo "$ACTIVE_USER" | |
exit 0 | |
} | |
sessions_dir=`mktemp --tmpdir --directory ConsoleKit-sessions.XXXXXX` | |
ck-list-sessions | split --lines 13 - "${sessions_dir}/" | |
matching_session=`grep --files-with-matches --line-regexp '^[[:space:]]\+active = TRUE$' ${sessions_dir}/a* 2> /dev/null | head -1` | |
if [ $? = 0 ]; then | |
user_id=`sed -n 's/^[[:space:]]\+unix-user = .\([[:digit:]]\+\).$/\1/p' $matching_session` | |
getent passwd "$user_id" | cut -f 1 -d ':' | |
unset user_id | |
else | |
echo 'root' | |
fi | |
rm -Rf "$sessions_dir" | |
unset matching_session sessions_dir |
This file contains 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
#!/usr/bin/env bash | |
# Custom script requirements: active_user | |
ACTIVE_USER=`"${HOME}/bin/linux/active_user"` | |
[ "${ACTIVE_USER:-root}" == "${USER:=$LOGNAME}" ] |
This file contains 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
#!/usr/bin/env bash | |
# Standard-repo requirements: xrandr, grep | |
xrandr | grep -c '\bconnected\b' |
This file contains 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
#!/usr/bin/env bash | |
# $1 (optional): timeout in seconds. Defaults to $IDLER_TIMEOUT, which in turn | |
# defaults to 300. | |
# If env var DEBUG_IDLER is set to 'true' on entry then debugging information will be output | |
# Standard-repo requirements: xprintidle, bc, pgrep/pkill, xdotool | |
# Custom script requirements: active_user_is_me, slideshow | |
debug () { | |
`"${DEBUG_IDLER:-false}"` && eval "echo $1: \$$1 1>&2" | |
} | |
"${HOME}/bin/active_user_is_me" || exit 0 | |
# xprintidle needs this | |
export DISPLAY=:0.0 | |
# Seconds of inactivity until sleep. 0 to disable sleep | |
time_out=$(( ${1:-${IDLER_TIMEOUT:-300}} * 1000 )) | |
debug time_out | |
shift | |
idle_time="`xprintidle`" | |
debug idle_time | |
# Use bc to avoid integer overflow | |
[ $( echo "${idle_time:-0} > $time_out" | bc ) -eq 0 ] && { | |
timed_out=false | |
debug timed_out | |
# Don't know why this is still in the process table | |
pkill mate-screensave | |
exit 0 | |
} | |
# Re-activate slideshow in case something has taken priority | |
pgrep 'feh' &> /dev/null && { | |
xdotool search feh windowactivate %1 windowactivate %2 &> /dev/null | |
feh_found=true | |
debug feh_found | |
exit 0 | |
} | |
# Programs worth staying up for :) | |
pgrep 'shutdown|mpg123|mplayer|mate-screensave' &> /dev/null && { | |
blocking_app_found=true | |
debug blocking_app_found | |
exit 0 | |
} | |
pgrep vlc &> /dev/null && { | |
vlc_is_running=true | |
debug vlc_is_running | |
"${HOME}/bin/vlc_is_playing_music_or_stopped" || { | |
vlc_is_not_playing_music_or_stopped=true | |
debug vlc_is_not_playing_music_or_stopped | |
exit 0 | |
} | |
} | |
"${HOME}/bin/slideshow" $@ |
This file contains 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
#!/usr/bin/env bash | |
# Standard-repo requirements: feh | |
# Default to right screen | |
GEOMETRY="${MY_FEH_GEOMETRY:=1280x768+1200+1120}" | |
feh --geometry "$GEOMETRY" --image-bg black --randomize --recursive \ | |
--slideshow-delay 3.25 --zoom max --action 'animate -loop 0 %F &' "$@" |
This file contains 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
#!/usr/bin/env bash | |
# $1 (optional): Window geometry to pass to first (rhs) my_feh process | |
# $2 (optional): Window geometry to pass to second (lhs) my_feh process | |
# Custom script requirements: count_hardware_displays, my_feh | |
################## EDIT ################## | |
PHOTOS="/path/to/your/photos/" | |
########################################## | |
DISPLAYS_COUNT="`${HOME}/bin/X11-utils/count_hardware_displays`" | |
[[ $DISPLAYS_COUNT == 0 ]] && exit 1 | |
SLIDESHOW="${HOME}/bin/my_feh" | |
# Right screen | |
if [ -n "$1" ]; then | |
export MY_FEH_GEOMETRY="$1" | |
fi | |
"$SLIDESHOW" "$PHOTOS" &>> "${HOME}/slideshow1.log" & | |
[[ $DISPLAYS_COUNT == 1 ]] && exit 0 | |
sleep 1 | |
# Left screen | |
if [ -n "$2" ]; then | |
export MY_FEH_GEOMETRY="$2" | |
else | |
export MY_FEH_GEOMETRY='1200x1868+0+52' | |
fi | |
"$SLIDESHOW" "$PHOTOS" &>> "${HOME}/slideshow2.log" & |
This file contains 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
#!/usr/bin/env bash | |
# VLC must be launched as vlc --extraintf oldrc:http --rc-unix ~/vlc.sock | |
# Standard-repo requirements: vlc, pgrep, netcat-openbsd, grep | |
[ -S "${HOME}/vlc.sock" ] || exit 2 | |
/usr/bin/pgrep vlc &> /dev/null || exit 3 | |
# Change this to a distinctive portion of the pathname of your music collection | |
##### EDIT ### | |
echo status | /bin/nc -U "${HOME}/vlc.sock" | /bin/grep --quiet 'Music.\+iTunes\|stop state: 5' | |
############## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment