Jump to content

I've seen these around and figured it would be a fun and helpful topic for everyone to get involved in.

The idea is simple: Post your best script that you or someone else wrote which you think is really useful.

The only restriction must be that it should be in something that most users have access to (e.g. either bash (your terminal), python, perl etc)

Also kinda useful if you could explain what it does ;)

 

So here is mine:

 

#!/bin/bash
pkill feh

if [[ -z $DISPLAY ]];then export DISPLAY=:0; fi


getWall(){
	find ~/Pictures/Wallpapers/ ! -path . ! -path "*.old*" | shuf -n1
}

applyBorder(){
	convert $1 -gravity center -background white -extent $2 $3
}

#applyBorder $(getWall) 1920x1080 "/tmp/wall1.png"
#applyBorder $(getWall) 3840x2160 "/tmp/wall2.png"

FILE1=$(getWall)
FILE2=$(getWall)


feh --bg-scale $FILE1 --bg-scale $FILE2

 

This is a quick n dirty system I have for putting random wallpapers on my desktops. It uses feh for the actual displaying, and optionally imagemagick to apply a border, although I commented it out since in the end I didn't like the effect.

Link to comment
Share on other sites

Link to post
Share on other sites

This is my little script that runs in the background and changes wallpapers. It loops through images in directory specified in ~/whichdir.txt (needs to be created manually), the path to the directory written in the file needs to be full (e.g. not ~/wallpapers/* but /home/username/wallpapers/*) and needs a '/*' at the end.

It takes 3 optional arguments that are: number of the wallpaper you want to start with, time unit you want to use for wait between wallpapers (e.g. -m = minutes, -s = seconds...) and the amount of time units the wait should last.

#! /bin/bash

NUMBER=${1:-1}
WAITT=${2:--m}
WAITNUM=${3:-5}
DIR=$(cat ~/whichdir.txt)
ls -d $DIR > ~/wallpaperlist.txt
MAXNUM=$(ls -d $DIR | wc -l)

WAITT=$(echo $WAITT | sed 's/^.//')
WAITNUM=$WAITNUM$WAITT

if [ $NUMBER -gt $MAXNUM ]
	then
		NUMBER=1
elif [ $NUMBER -lt 1 ]
	then
		NUMBER=$MAXNUM
fi


WALLPAPER=$(head -$NUMBER ~/wallpaperlist.txt | tail -1)
feh --bg-fill $WALLPAPER &

while [ true ]
do
	NUMBER=$(($NUMBER+1))
	sleep $WAITNUM
	if [ $NUMBER -gt $MAXNUM ]
		then
			NUMBER=1
	fi
	WALLPAPER=$(head -$NUMBER ~/wallpaperlist.txt | tail -1)
	feh --bg-fill $WALLPAPER &
done
Link to comment
Share on other sites

Link to post
Share on other sites

I like those scripts both, but windows can do that from itself too, and i'm pretty sure ubuntu and other linux distros can also do that, what is the use of getting a script to do it?

Computer's don't make errors. What they do, they do on purpose.

Link to comment
Share on other sites

Link to post
Share on other sites

17 minutes ago, matjojo said:

I like those scripts both, but windows can do that from itself too, and i'm pretty sure ubuntu and other linux distros can also do that, what is the use of getting a script to do it?

For me, I run a very thin environment where it doesn't even include a wallpaper option so we use the program 'feh' to draw one in the background.

 

Some environments of Linux (gnome springs to mind) don't offer this, while I believe Ubuntu does. The other option of this is that you could also grab wallpapers from the web or anywhere you wanted, since it's flexible enough to get an image from any source.

Link to comment
Share on other sites

Link to post
Share on other sites

3 hours ago, Half-Shot said:

For me, I run a very thin environment where it doesn't even include a wallpaper option so we use the program 'feh' to draw one in the background.

 

Some environments of Linux (gnome springs to mind) don't offer this, while I believe Ubuntu does. The other option of this is that you could also grab wallpapers from the web or anywhere you wanted, since it's flexible enough to get an image from any source.

Also because it's fun to write scripts

Link to comment
Share on other sites

Link to post
Share on other sites

i can not post my scripts here! site says that i am blocked! why is that? i wrote to administrators about this.

i'll just attach my scripts to this post in text file. pls read, there are some interesting ones. especially last one :)

 

Fuck when i attach it says failed proccessing the file: -200 WTF is wrong with this forum?

 

Computer users fall into two groups:
those that do backups
those that have never had a hard drive fail.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×