Experiment with Screener

Moderator: Forum moderators

Post Reply
User avatar
Sofiya
Posts: 2290
Joined: Tue Dec 07, 2021 9:49 pm
Has thanked: 1481 times
Been thanked: 1543 times

Experiment with Screener

Post by Sofiya »

Fed up with a black screen.Wanted something exclusive.
Works great, surprisingly nice!!! :)

Installed:
screener-1.0.1_amd64 viewtopic.php?t=4270

From Pamac: xlockmore , xautolock

Attachments
Снимок экрана.png
Снимок экрана.png (254.56 KiB) Viewed 5129 times
Снимок экрана.png
Снимок экрана.png (255.41 KiB) Viewed 5130 times
Last edited by Sofiya on Fri Jun 23, 2023 5:22 pm, edited 2 times in total.

KL
PUPPY LINUX Simple fast free

User avatar
fredx181
Posts: 3103
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 378 times
Been thanked: 1324 times
Contact:

Re: Experiment with Screener

Post by fredx181 »

Ok, great! Needs some adjustments for yad GTK3 for the buttons, so you get e.g. Apply instead of gtk-apply : --button="Apply!gtk-apply:0" --button="Preview:1" --button="Close!gtk-close:2"

User avatar
Sofiya
Posts: 2290
Joined: Tue Dec 07, 2021 9:49 pm
Has thanked: 1481 times
Been thanked: 1543 times

Re: Experiment with Screener

Post by Sofiya »

fredx181 wrote: Fri Jun 23, 2023 3:54 pm

Ok, great! Needs some adjustments for yad GTK3 for the buttons, so you get e.g. Apply instead of gtk-apply : --button="Apply!gtk-apply:0" --button="Preview:1" --button="Close!gtk-close:2"

without attention. Thank you @fredx181

corrected line 19 , 32

Code: Select all

#!/bin/bash
#Screener-1.4
#screen saver by rg66 and Geoffrey Oct 25 2013

. ~/.config/screener.conf

SAVERS=$(echo `cat /usr/share/screener/savers` | sed -e 's/\s/!/g')
XAUTO=`pidof xautolock`

[ "$SCREENSAVER" = '' ] && SCREENSAVER="blank"

if [ -e /root/.xlockrc ] && [ ! -s /root/.xlockrc ] || [ ! -e /root/.xlockrc ]; then
PASSWORD="FALSE"
else
PASSWORD="TRUE"
fi

PREVIEW(){
cat /usr/share/screener/savers | yad --window-icon="preferences-desktop-screensaver" --title="Screener" --height="310" --list --column="Screen Savers" --button="Preview:2" --button="Close!gtk-close:2" | while read line; do

PREV=`echo $line | tr -d '|'`
   xlock -inwindow -mode $PREV
   PREVIEW 
done
}
export -f PREVIEW

CONFIG=$(yad --image-on-top --image="energy_star" --window-icon="preferences-desktop-screensaver" --text="<b><big> Screen Saver Settings</big></b>" \
--title="Screener" --borders="10" --fixed --form --field="Enable Screen Saver:CHK" "$ENABLESAVER" --field="Enable Mouse Motion:CHK" "$MOUSEMOTION" --field="Mins Until Screen Saver:NUM" "$SAVERTIME!1..120!1" \
--field="Screen Saver:CB" "$SCREENSAVER!$SAVERS" --field="Password Protect:CHK" "$PASSWORD" \
--field="Monitor Energy Saver:CHK" "$ENERGYSAVE" --field="Mins Until Monitor Standby:NUM" "$ENERGYTIME!0..120!1" \
--buttons-layout="center" --button="Apply!gtk-apply:0" --button="Preview:1" --button="Close!gtk-close:2")

case $? in
0) echo ENABLESAVER="'`echo $CONFIG | awk -F'|' '{print $1}'`'" > /root/.config/screener.conf
   echo MOUSEMOTION="'`echo $CONFIG | awk -F'|' '{print $2}'`'" >> /root/.config/screener.conf
   echo SAVERTIME="'`echo $CONFIG | awk -F'|' '{print $3}' | awk -F'.' '{print $1}'`'" >> /root/.config/screener.conf
   echo SCREENSAVER="'`echo $CONFIG | awk -F'|' '{print $4}'`'" >> /root/.config/screener.conf
   echo PASSWORD="'`echo $CONFIG | awk -F'|' '{print $5}'`'" >> /root/.config/screener.conf
   echo ENERGYSAVE="'`echo $CONFIG | awk -F'|' '{print $6}'`'" >> /root/.config/screener.conf
   echo ENERGYTIME="'`echo $CONFIG | awk -F'|' '{print $7}' | awk -F'.' '{print $1}'`'" >> /root/.config/screener.conf ;;
1) PREVIEW ;;
*) exit 0 ;;
esac 

. ~/.config/screener.conf

if [ "$MOUSEMOTION" = TRUE ]; then
MM="-mousemotion"
fi

if [ "$ENABLESAVER" = TRUE ]; then
xset s off
kill $XAUTO
xautolock -time "$SAVERTIME" -locker /usr/share/screener/sxlock &
else
kill $XAUTO
fi 

if [ "$PASSWORD" = FALSE ] && [ -f /root/.xlockrc ] || [ ! -s /root/.xlockrc ]; then
rm -f /root/.xlockrc
fi
if [ "$PASSWORD" = TRUE ] && [ ! -f /root/.xlockrc ]; then 
xterm -g 36x1 -title "Create key (password)" -e xlock $MM -mode $SCREENSAVER
fi

if [ "$ENERGYSAVE" = TRUE ]; then
ETIME=$(( $ENERGYTIME * 60 ))
xset dpms $ETIME $ETIME $ETIME
else
xset -dpms 
fi
Attachments
Скриншот.gif
Скриншот.gif (466.81 KiB) Viewed 5092 times
Снимок экрана.png
Снимок экрана.png (28.03 KiB) Viewed 5112 times
Last edited by Sofiya on Sat Jun 24, 2023 11:47 am, edited 1 time in total.

KL
PUPPY LINUX Simple fast free

User avatar
Sofiya
Posts: 2290
Joined: Tue Dec 07, 2021 9:49 pm
Has thanked: 1481 times
Been thanked: 1543 times

Re: Experiment with Screener

Post by Sofiya »

The only drawback is that it works even if the browser is open or the player is playing, the function is available only if the mouse is moving. need code fix :ugeek:
so that the splash screen does not turn on not only when the mouse moves, but also when playing the player or browser

KL
PUPPY LINUX Simple fast free

User avatar
fredx181
Posts: 3103
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 378 times
Been thanked: 1324 times
Contact:

Re: Experiment with Screener

Post by fredx181 »

Sofiya wrote: Fri Jun 23, 2023 6:51 pm

The only drawback is that it works even if the browser is open or the player is playing, the function is available only if the mouse is moving. need code fix :ugeek:
so that the splash screen does not turn on not only when the mouse moves, but also when playing the player or browser

I use this, found that (same as you) while playing video through browser, indeed the screensaver gets activated, but while playing video with a player like vlc, mpv or mplayer it's OK, screensaver not activated.
Same for you ?
I've been looking a little now for some way to detect "movement" on the Desktop (not specially mouse movement but also video movement), but couldn't find yet.

User avatar
Sofiya
Posts: 2290
Joined: Tue Dec 07, 2021 9:49 pm
Has thanked: 1481 times
Been thanked: 1543 times

Re: Experiment with Screener

Post by Sofiya »

fredx181 wrote: Sat Jun 24, 2023 3:18 pm
Sofiya wrote: Fri Jun 23, 2023 6:51 pm

The only drawback is that it works even if the browser is open or the player is playing, the function is available only if the mouse is moving. need code fix :ugeek:
so that the splash screen does not turn on not only when the mouse moves, but also when playing the player or browser

I use this, found that (same as you) while playing video through browser, indeed the screensaver gets activated, but while playing video with a player like vlc, mpv or mplayer it's OK, screensaver not activated.
Same for you ?
I've been looking a little now for some way to detect "movement" on the Desktop (not specially mouse movement but also video movement), but couldn't find yet.

yes indeed, when playing the player, Smplayer is not blocked

KL
PUPPY LINUX Simple fast free

User avatar
Sofiya
Posts: 2290
Joined: Tue Dec 07, 2021 9:49 pm
Has thanked: 1481 times
Been thanked: 1543 times

Re: Experiment with Screener

Post by Sofiya »

fredx181 wrote: Sat Jun 24, 2023 3:18 pm
Sofiya wrote: Fri Jun 23, 2023 6:51 pm

The only drawback is that it works even if the browser is open or the player is playing, the function is available only if the mouse is moving. need code fix :ugeek:
so that the splash screen does not turn on not only when the mouse moves, but also when playing the player or browser

I use this, found that (same as you) while playing video through browser, indeed the screensaver gets activated, but while playing video with a player like vlc, mpv or mplayer it's OK, screensaver not activated.
Same for you ?
I've been looking a little now for some way to detect "movement" on the Desktop (not specially mouse movement but also video movement), but couldn't find yet.

does not come out to prevent xautolock from locking by monitoring for audio.

Code: Select all

if [ $(grep -r "RUNNING" /proc/asound | wc -l) -eq 0 ]; then
	xlock -nolock
fi

the mouse in the upper right corner works. blocking does not occur.

Code: Select all

xautolock -time 1 -locker "/usr/share/screener/sxlock" -corners 0-00 &

KL
PUPPY LINUX Simple fast free

User avatar
Sofiya
Posts: 2290
Joined: Tue Dec 07, 2021 9:49 pm
Has thanked: 1481 times
Been thanked: 1543 times

Re: Experiment with Screener

Post by Sofiya »

added to the code ( -corners 0-00 )line 7, now if the mouse pointer is in the upper right corner, the screen is not blocked, and you can watch the video in the browser.

/root/Startup/xscreener

Code: Select all

#!/bin/bash

. ~/.config/screener.conf

if [ "$ENABLESAVER" = TRUE ]; then
xset s off
xautolock -time "$SAVERTIME" -locker /usr/share/screener/sxlock -corners 0-00 &
fi

if [ "$ENERGYSAVE" = TRUE ]; then
ETIME=$(( $ENERGYTIME * 60 ))
xset dpms $ETIME $ETIME $ETIME
else
xset -dpms
fi


KL
PUPPY LINUX Simple fast free

User avatar
fredx181
Posts: 3103
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 378 times
Been thanked: 1324 times
Contact:

Re: Experiment with Screener

Post by fredx181 »

@Sofiya Perhaps this is useful, it shows status "Playing" or "Paused", tested with Play/Pause Youtube video on Firefox (probably with other browsers works too) :

Code: Select all

bus=$(dbus-send --session           \
  --dest=org.freedesktop.DBus \
  --type=method_call          \
  --print-reply=literal       \
  /org/freedesktop/DBus       \
  org.freedesktop.DBus.ListNames |
  tr ' ' '\n' |
  grep 'org.mpris.MediaPlayer2' |
  head -n 1)

status=`dbus-send --print-reply --dest=$bus /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'PlaybackStatus'|egrep -A 1 "string"|cut -b 26-|cut -d '"' -f 1|egrep -v ^$`
echo $status
User avatar
Sofiya
Posts: 2290
Joined: Tue Dec 07, 2021 9:49 pm
Has thanked: 1481 times
Been thanked: 1543 times

Re: Experiment with Screener

Post by Sofiya »

fredx181 wrote: Sun Jun 25, 2023 3:59 pm

@Sofiya Perhaps this is useful, it shows status "Playing" or "Paused", tested with Play/Pause Youtube video on Firefox (probably with other browsers works too) :

Code: Select all

bus=$(dbus-send --session           \
  --dest=org.freedesktop.DBus \
  --type=method_call          \
  --print-reply=literal       \
  /org/freedesktop/DBus       \
  org.freedesktop.DBus.ListNames |
  tr ' ' '\n' |
  grep 'org.mpris.MediaPlayer2' |
  head -n 1)

status=`dbus-send --print-reply --dest=$bus /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'PlaybackStatus'|egrep -A 1 "string"|cut -b 26-|cut -d '"' -f 1|egrep -v ^$`
echo $status

will have to look later. Checked with Yandex-browser works.

xlock_xidlehook

I've been a bit shamanistic and compiled "xidlehook" - https://drive.google.com/file/d/1Yrclwx ... sp=sharing
xidlehook is a generic replacement for xautolock.
in the package the files are arranged where they should be.
I think the code is quite clear in order to increase the blocking time, etc.
Enabled - do not lock the screen when playing sound, when in full screen mode, when inactive, screen fades after 1 min, screen locks after 10 sec, then suspend ('systemctl suspend ) - after an hour. These are test settings. Verified with YRadio ,Yandex-browser ,Smplayer.
screensavers play randomly.

If you want not a random splash screen to play when you lock the screen, but the one you like, change the configuration file a little .

line 18 : 'xrandr --output "$PRIMARY_DISPLAY" --brightness 1; xlock -nolock' \ on this
'xrandr --output "$PRIMARY_DISPLAY" --brightness 1; xlock -nolock -mode clock' ### where " clock " is the name of your splash screen

my screensaver set

Code: Select all

atlantis
atunnels
clock
dclock
life1d
mandelbrot
matrix
spiral
sierpinski3d
qix
bat
blank

should also be xlockmore, xautolock installed

I have "xlock -nolock" written in my code so that I can unlock the screen without a password. If you remove "-nolock" then you will need a password to unlock the screen, which must be entered and remembered in advance. for this I have created a file "Change user password"
the default password is: root

place in /usr/share/applications/Change user password

Code: Select all

[Desktop Entry]
Encoding=UTF-8
Name=Change user password
Icon=lock
Comment=Change user password
Exec=xterm -e passwd root
Terminal=false
Type=Application
Categories=DesktopSettings
GenericName=Change user password

you can change the time of the timers to your taste "time in seconds" tobish based on 1 minute = 60 seconds " --timer 60 \ "

in /root/Startup/ - I have it called:
xlock_xidlehook

Code: Select all

#!/usr/bin/env bash

# Only exported variables can be used within the timer's command.

sleep 5
export PRIMARY_DISPLAY="$(xrandr | awk '/ primary/{print $1}')"

# Run xidlehook
xidlehook \
  `# Don't lock when there's a fullscreen application` \
  --not-when-fullscreen \
  `# Don't lock when there's audio playing` \
  --not-when-audio \
  `# Dim the screen after 60 seconds(1 minute), undim if user becomes active` \
  --timer 60 \
    'xrandr --output "$PRIMARY_DISPLAY" --brightness .1' \
    'xrandr --output "$PRIMARY_DISPLAY" --brightness 1' \
  `# Undim & lock after 10 more seconds` \
  --timer 10 \
    'xrandr --output "$PRIMARY_DISPLAY" --brightness 1; xlock -nolock' \
    '' \
  `# Finally, suspend an hour after it locks` \
  --timer 3600 \
    'systemctl suspend' \
    ''

KL
PUPPY LINUX Simple fast free

User avatar
fredx181
Posts: 3103
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 378 times
Been thanked: 1324 times
Contact:

Re: Experiment with Screener

Post by fredx181 »

fredx181 wrote: Sun Jun 25, 2023 3:59 pm

@Sofiya Perhaps this is useful, it shows status "Playing" or "Paused", tested with Play/Pause Youtube video on Firefox (probably with other browsers works too) :

Code: Select all

bus=$(dbus-send --session           \
  --dest=org.freedesktop.DBus \
  --type=method_call          \
  --print-reply=literal       \
  /org/freedesktop/DBus       \
  org.freedesktop.DBus.ListNames |
  tr ' ' '\n' |
  grep 'org.mpris.MediaPlayer2' |
  head -n 1)
status=`dbus-send --print-reply --dest=$bus /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'PlaybackStatus'|egrep -A 1 "string"|cut -b 26-|cut -d '"' -f 1|egrep -v ^$`
echo $status

Until now I didn't really tested it by implementing in screener, but now I did test and seems to work well, changed '/usr/share/screener/sxlock' to:

Code: Select all

#! /bin/bash

. ~/.config/screener.conf

if [ "$PASSWORD" = FALSE ]; then
LOCK="-nolock"
fi
if [ "$MOUSEMOTION" = TRUE ]; then
MM="-mousemotion"
fi

bus=$(dbus-send --session           \
  --dest=org.freedesktop.DBus \
  --type=method_call          \
  --print-reply=literal       \
  /org/freedesktop/DBus       \
  org.freedesktop.DBus.ListNames |
  tr ' ' '\n' |
  grep 'org.mpris.MediaPlayer2' |
  head -n 1)
 
# check status of browser playing or not
status=`dbus-send --print-reply --dest=$bus /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'PlaybackStatus' 2> /dev/null|egrep -A 1 "string"|cut -b 26-|cut -d '"' -f 1|egrep -v ^$`

# only activate xlock if status is NOT 'Playing'
[ "$status" != "Playing" ] && xlock $MM -mode $SCREENSAVER $LOCK

And for me it doesn't activate the screensaver while playing a video in a browser (when pausing it, will activate screensaver again after time set).
edit: probably won't work when logged in as root and the browser is running "as-spot"

Post Reply

Return to “KL-Dev_Work”