You are not logged in.

#3201 2018-10-03 13:58:49

eschwartz
Trusted User/Bug Wrangler
Registered: 2014-08-08
Posts: 2,379

Re: Post your handy self made command line utilities

Trilby wrote:

Eschwartz, to be fair, they didn't sed pacman.conf themselves.  They read pacman.conf line by line in a clumsy and pointless loop and sed''ed part of each line for no reason only to check whether it matched 'IgnorePkg' and then only to oddly and conditionally append a space then a value to a simple variable when an array would be much easier needing no conditional or spaces.

And this is you being "fair"... tongue

Honest, yes, I will grant you that. But generally the phrase "to be fair" is used by people extending mercy, not additional objections. big_smile

If pacman-conf were not an option, that entire loop could just be:

IGNORE=$(sed -n 's/^IgnorePkg[^=]*=//p' /etc/pacman.conf)
# or better as an array
IGNORE=($(sed -n 's/^IgnorePkg[^=]*=//p' /etc/pacman.conf))

If it comes to that, matching on 'IgnorePkg222 = nope' and finding that the "nope" package should be ignored, is rather erroneous...

Don't match:

^IgnorePkg[^=]*=

Do match:

^IgnorePkg[[:space:]]*=

Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#3202 2018-10-03 14:01:01

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 20,142
Website

Re: Post your handy self made command line utilities

Good revision to my sed command.  To be fair, I'm an idiot. tongue


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3203 2018-10-03 15:31:43

Crouze
Member
Registered: 2017-10-04
Posts: 7

Re: Post your handy self made command line utilities

And to be fair, learned something new again today. Of course there was an easier way wink

Offline

#3204 2018-10-05 08:47:36

kokoko3k
Member
Registered: 2008-11-14
Posts: 1,756

Re: Post your handy self made command line utilities

I've found this nice site that is missing an rss but gives you updates about new free games, so i wrote a little script that checks it and send me a notification when there is a new free game; didn't tested it deeply... yet!
It uses the handy "sendemail" tool from aur.

#!/bin/bash
wdir=/koko/scripts/gamecheck
f1="$wdir/1.txt"
f2="$wdir/2.txt"
mkdir "$wdir" &>/dev/null
interval=7200 #secs

function notify() {
	 /usr/bin/sendEmail \
		-f source_email@gmail.com \
		-t dest_email@gmail.com \
		-s smtp.gmail.com:25 \
		-xu gmail_username \
		-xp gmail_password \
		-u "GameCheck" \
		-m "New updates on: https://givemekey.com/?s=" 
}

function check_out() {
	curl "https://givemekey.com/?s=" |\
		tr "<" "\n"|\
		grep free |\
		grep "title\=" |\
		cut -d \" -f 2
}

check_out > "$f1"

while true ; do
	sleep $interval
	check_out > "$f2"
	if [ $(<"$f1") != $(<"$f2") ] ; then
		notify "$f2"
	fi
	cp "$f2" "$f1"
done

...and a systemd service as well

[Unit]
Description=Check for free games

[Service]
Type=simple
ExecStart=/home/koko/scripts/gamecheck.sh

[Install]
WantedBy=default.target

Last edited by kokoko3k (2018-10-05 08:55:15)

Offline

Board footer

Powered by FluxBB