~scripts
55 itemsDownload ./*

55 itemsDownload ./*

..
dzen2
tiling
vosh
4cdl
4trips
alarm
ambient
ana-wall.sh
battery-monitor
brightness.sh
checkit
cleverbot.py
clock
color-gen
colors-hex
colorscheme.sh
compton
dailywall
dmenu
ffthumb
grid
gridmacro
gridmacro.kde
help
importw
indexer
install-all.sh
install-twily.sh
installng
keep-on
mp3ogg
orage
pipes
pipes.x
pipewire_bt.sh
ports
rain
randwall
rotate.sh
scan.sh
screen-dim
screencast
screencast2
scrot
scrotw
search
skull
slocker
starwars
streamit
sumnum
tty-colorize
usrmount
ytp
ytplay


scriptsana-wall.sh
313•  1 year ago•  DownloadRawClose
1 year ago•  313

{}
#!/bin/bash
#
# Author: twily                 2023
# Website: twily.info
# Description: Set wallpaper in kde on interval--default get random selfie download from analiestar.com
# Usage: $ ./ana-wall.sh 0.5 # 30 sec
#

min=10
if [ ! -z "$1" ]; then
    min=$1
fi
sec=$(echo "$min*60" | bc -l)

# set youe home folder/picture store location
picdir="/home/amalie/Pictures/selfies"

# to change sddm set this folder (or which theme you use) to chmod 777
sddmpath="/usr/share/sddm/themes/breeze"

theme='[General]
background=ana-wall.jpg
type=image'
echo "$theme" > "$sddmpath"/theme.conf.user # chmod 777 this file also or pre-set text above

while :; do
    # fetch blob image -- change id/name to analiestar.com member page details
    curl "https://analiestar.com/randomselfie.php?name=username&id=XXXXX-XXXXX-XXXXX-XXXXX" -o ~/ana-wall-temp.jpg
    name=$( cat ~/ana-wall-temp.jpg | md5sum | cut -d' ' -f1 )
    
    echo "Downloading new image from analiestar.com--md5=$name(.jpg)"
    
    exists=0
    for f in "$picdir"; do
        if [ "$f" == "$name.jpg" ]; then
            echo "Exists..skipping save"
            exists=1
            break;
        fi
    done
    if [ $exists -eq 0 ]; then
        mv ~/ana-wall-temp.jpg "$picdir/$name.jpg"
    else
        rm ~/ana-wall-temp.jpg
    fi
   
    # kde set wallpaper 
    dbus-send --session --dest=org.kde.plasmashell --type=method_call /PlasmaShell org.kde.PlasmaShell.evaluateScript 'string:
    var Desktops=desktops();
    for(i=0;i<Desktops.length;i++) {
        d=Desktops[i];
        d.wallpaperPlugin="org.kde.image";
        d.currentConfigGroup=Array("Wallpaper",
            "org.kde.image",
            "General");
        d.writeConfig("Image","file://'$picdir'/'$name'.jpg");
    }'

    # kde set lockscreen 
    if [ -f ~/.config/kscreenlockerrc ]; then
        SAVEIFS=$IFS
        IFS=$'\n'
        readarray -t a < ~/.config/kscreenlockerrc
        IFS=$SAVEIFS
        ndat=""
        changed=0
        for((i=0;i<${#a[@]};i++)); do
            if [[ ${a[$i]} == Image=* ]]; then
                ndat="$ndat""Image=$picdir/$name.jpg\n"
                changed=1
            else
                ndat="$ndat""${a[$i]}\n"
            fi
        done
        if [ $changed -eq 1 ]; then
            if [ "$ndat" != "" ]; then
                echo -ne "$ndat" > ~/.config/kscreenlockerrc
            fi
        fi
    fi
    
    cp -f "$picdir/$name.jpg" "$sddmpath/ana-wall.jpg" # need access sddm
    
    echo ""
    echo "next in $sec seconds. (run as $ nohup ./ana-wall.sh 0.5 & to run in background)"

    sleep $sec
done

exit

Top
©twily.info 2013 - 2024
twily at twily dot info



2 033 334 visits
... ^ v