You are not logged in.
I do it like this:
find . -iname '*.rar' -execdir rar x {} $(pwd | perl -pe 's/^((?:\/[^\/]+){2}\/).*/$1/').temp/ \;
mplayer $(pwd | perl -pe 's/^((?:\/[^\/]+){2}\/).*/$1/').temp/* && rm $(pwd | perl -pe 's/^((?:\/[^\/]+){2}\/).*/$1/').temp/*
#echo $(basename $(pwd)) >> /mnt/Movies_1/.seen
Offline
here's an alarm script working through gxmessage and mpd (and mpc). it seems to be working fine, but ive only been using it a few days. create an "alarm" playlist, set time between snoozes, and set a cronjob like so:
00 5 * * 1-5 export DISPLAY=:0.0 && sh /home/vic/scripts/wakethehellup.sh
#!/bin/bash
# wakethehellup.sh
# amount of time between snoozes in minutes
ztime=60
# load playlist
mpc -q clear; mpc load alarm; mpc -q shuffle
# set volume to loud, play
vol=$1; mpc -q volume ${vol:-70}; mpc play
# gxmessage alarm
alarm_message() {
gxmessage -center \
-buttons "Stop":1,"Snooze":2 \
-geometry 400x80 \
-title "Alarm" \
'Get up for school ya lazy bum!'
action=$?
}
# snooze or stop?
export DISPLAY=:0.0
alarm_message
while [ $action -ne 1 ]
do
if [ $action -eq 2 ] ;then
mpc -q pause
sleep 3; xset dpms force standby
sleep "$ztime"m
xset dpms force on
sleep 3; mpc play
fi
alarm_message
done
mpc -q stop
Offline
Simple calculator. Could be used as interactive perl interpreter too, ofc.
#!/usr/bin/perl
while(<>){die if/:q/;print'='.eval,"\n"}
-4+5
=1
printf("%10s %15s\n", 'Arch', 'Linux');
Arch Linux
pwc. Simple weather fetcher. IRC format supported. List of towns to lookup supported.
#!/usr/bin/perl
#pwc
use strict;
use warnings;
use Getopt::Long;
use Weather::Google;
our $irc;
GetOptions(
'irc' => \$irc,
);
my @towns = @ARGV;
if(!@ARGV) {
print "Specify town(s).\n";
}
# In case we need more then one
my @gobjects;
my %data;
foreach my $town(@towns) {
push @{$data{$town}}, Weather::Google->new($town)->current(
'temp_c',
'condition',
'humidity',
'wind_condition',
);
}
my $town;
my @data;
foreach $town(sort keys %data) {
@data = @{$data{$town}};
foreach my $line (@data) {
if(!defined($line)) {
$line = "undef";
}
}
# I'm lazy
if(!$irc) {
print "\033[31;1m",ucfirst($town),"\033[0m\n";
print "Celsius: $data[0]°C\n";
print "Condition: $data[1]\n";
print "$data[2]\n";
print "$data[3]\n";
}
else {
# skummeslövsstrand
# The idea was to use %${lenght}s, but if that should work I'll have to
# figure out the longest string in @ARGV, which is simple, but I doubt
# that I'll get the formatting good anyway - therefore I leave it like
# this for now.
printf("%0s %0s %0s %0s %0s\n", '·',ucfirst($town).':', "$data[0]°C",
"[$data[1]]","| $data[3]");
}
}
» pwc washington
Washington
Celsius: 4°C
Condition: Cloudy
Humidity: 61%
Wind: NW at 13 mph
__________________
» pwc washington cairo stockholm oslo helsinki -i
· Cairo: 17°C [Haze] | Wind: SW at 8 mph
· Helsinki: 0°C [Light snow] | Wind: N at 2 mph
· Oslo: -8°C [Clear] | Wind: N at 2 mph
· Stockholm: -8°C [Mostly Cloudy] | Wind: W at 15 mph
· Washington: 4°C [Cloudy] | Wind: NW at 13 mph
#!/usr/bin/perl
$c='python';$_=`printf hack`;$_=~s;ck;;;;$c=~s%^(?!\x68)(.)(?2)(?1)(.)(?1)(?2)(?<!.{4}h)$%$2%;print j.substr($_,1),p,$c.",\n"
Offline
A few pacman scripts. I've showed these before but I've simplified them and cleaned them up a bit.
pacbac - creates backup list of installed packages. Creates separate lists for Official repositories and a Local repository (usually the AUR packages for me).
#!/bin/bash
# pacbac - Create Official and Local lists of installed packages
# Package list locations (official and local)
pkglsdir=/home/todd/.bin/root/backup
pkglsoff="$pkglsdir"/pkglist-off.txt
pkglsloc="$pkglsdir"/pkglist-loc.txt
# Use filename as program name
prog=${0##*/}
# Text color variables
if [ $(whoami) != "cron" ]; then
txtund=$(tput sgr 0 1) # Underline
txtcyn=$(tput setaf 6) # Cyan
txtbld=$(tput bold) # Bold
bldred=${txtbld}$(tput setaf 1) # red
bldblu=${txtbld}$(tput setaf 4) # blue
bldwht=${txtbld}$(tput setaf 7) # white
txtrst=$(tput sgr0) # Reset
info=${bldwht}*${txtrst} # Feedback
pass=${bldblu}*${txtrst}
warn=${bldred}!${txtrst}
fi
# Check that backup folder exists
if [ ! -d "$pkglsdir" ]; then
echo "$warn Package list directory doesn't exist: ("$pkglsdir")"
echo "$info Exiting"
exit
fi
# Continue?
echo -n "Create list of official, and list of local packages? (${txtbld}y${txtrst}/${txtbld}n${txtrst}): "
read listcreate
# Create lists
if [ $listcreate = "y" ]; then
# Create full list, remove local, base
echo "$info Creating list of official (core/extra/community packages) packages installed."
pacman -Qqe | grep -vx "$(pacman -Qqg base)" | grep -vx "$(pacman -Qqm)" > "$pkglsoff"
# Create list of local packages (includes the AUR)
echo "$info Creating list of local (includes AUR) packages installed."
pacman -Qqm > "$pkglsloc"
# Information
echo "$pass Official package list created: ${txtund}"$pkglsoff"${txtrst}"
echo "$pass Local package list created: ${txtund}"$pkglsloc"${txtrst}"
fi
pacrest - installs packages from package list created with pacbac (useful for reinstalling):
#!/bin/bash
# pacrest - Restore from list Official and Local packages
# Package list locations (official and local)
pkglsdir=/home/todd/.bin/root/backup
pkglsoff="$pkglsdir"/pkglist-off.txt
pkglsloc="$pkglsdir"/pkglist-loc.txt
# Use filename as program name
prog=${0##*/}
# Text color variables
if [ $(whoami) != "cron" ]; then
txtund=$(tput sgr 0 1) # Underline
txtcyn=$(tput setaf 6) # Cyan
txtbld=$(tput bold) # Bold
bldred=${txtbld}$(tput setaf 1) # red
bldblu=${txtbld}$(tput setaf 4) # blue
bldwht=${txtbld}$(tput setaf 7) # white
txtrst=$(tput sgr0) # Reset
info=${bldwht}*${txtrst} # Feedback
pass=${bldblu}*${txtrst}
warn=${bldred}*${txtrst}
fi
# Check that the package list folder exists
if [ ! -d "$pkglsdir" ]; then
echo "$warn Package list directory doesn't exist: ("$pkglsdir")"
echo "$info Exiting"
exit
fi
# Check that a package list exists
if [ ! -f "$pkglsoff" ] && [ ! -f "$pkglsloc" ]; then
echo "$warn No package lists exist:"
echo "$warn $pkglsoff and $pkglsoff"
echo "$info Exiting"
exit
fi
# Be sure yaourt is installed
if [[ ! -f /usr/bin/yaourt ]]; then
echo
echo "$warn $prog requires ${txtund}}Yaourt${txtrst} to be installed."
echo " ${txtcyn}http://wiki.archlinux.org/index.php/Yaourt${txtrst}"
echo
exit
fi
# Restore Official or Local?
echo -n "Do you want to restore Official or Local packages? (${txtbld}o${txtrst}/${txtbld}l${txtrst}): "
read restore
if [ $restore = "o" ]; then
sudo pacman -Sy
sudo pacman -S --needed $(cat "$pkglsoff")
fi
if [ $restore = "l" ]; then
yaourt -S $(cat "$pkglsloc" | grep -vx "$(pacman -Qqm)")
fi
pacrein - Re-installs all packages (installs explicit a explicit and dependencies as dependencies). Not often a use for this script but nice to have around:
#!/bin/bash
# pacrein - Re-install all Official and Local packages
# Local package cache
locpkgcache=/var/cache/pacman-local/pkg
# Use filename as program name
prog=${0##*/}
# Text color variables
if [ $(whoami) != "cron" ]; then
txtund=$(tput sgr 0 1) # Underline
txtcyn=$(tput setaf 6) # Cyan
txtbld=$(tput bold) # Bold
bldred=${txtbld}$(tput setaf 1) # red
bldblu=${txtbld}$(tput setaf 4) # blue
bldwht=${txtbld}$(tput setaf 7) # white
txtrst=$(tput sgr0) # Reset
info=${bldwht}*${txtrst} # Feedback
pass=${bldblu}*${txtrst}
warn=${bldred}!${txtrst}
fi
# If rebuilding, be sure yaourt is installed
if [[ "$1" == 'r' ]] && [[ -z $(pacman -Qs yaourt) ]]; then
echo
echo "$warn $prog requires ${txtund}}Yaourt${txtrst} to be installed."
echo " ${txtcyn}http://wiki.archlinux.org/index.php/Yaourt${txtrst}"
echo
exit
fi
# Sync db, download only
echo -n "Upgrade database, and download new packages? (${txtbld}y${txtrst}/${txtbld}n${txtrst}): "
read updbdown
if [ $updbdown = "y" ]; then
sudo pacman -Sy
sudo pacman --noconfirm -Swu
fi
# Reinstall Official dependencies?
echo -n "Re-install Official dependencies? (${txtbld}y${txtrst}/${txtbld}n${txtrst}): "
read offdep
if [ $offdep = "y" ]; then
sudo pacman -S --asdeps $(pacman -Qq | grep -vx "$(pacman -Qqe)" | grep -vx "$(pacman -Qqm)")
fi
# Re-install Official explictis?
echo -n "Re-install Official explicits? (${txtbld}y${txtrst}/${txtbld}n${txtrst}): "
read offexp
if [ $offexp = "y" ]; then
sudo pacman -S $(pacman -Qqe | grep -vx "$(pacman -Qqm)")
fi
# Re-install Local depedencies
echo -n "Re-install Local dependencies? (${txtbld}y${txtrst}/${txtbld}n${txtrst}): "
read locdep
if [ $locdep = "y" ]; then
# Re-install package if cached, build others
locdepls=$(pacman -Qqm | grep -vx "$(pacman -Qqme)")
for pkg in $locdepls; do
pkgver="$locpkgcache/$pkg-$(pacman -Qii $pkg | grep Version | awk '{ printf $3 }')-$(uname -m).pkg.tar.gz"
if [ -f $pkgver ]; then
sudo pacman -U --asdeps --noconfirm $pkgver
else
yaourt -S --asdeps --noconfirm $pkg
fi
done
fi
# Re-install Local explicits
echo -n "Re-install Local explicits? (${txtbld}y${txtrst}/${txtbld}n${txtrst}): "
read locexp
if [ $locexp = "y" ]; then
# Re-install package if cached, build others
locexpls=$(pacman -Qqme)
for pkg in $locexpls; do
pkgver="$locpkgcache/$pkg-$(pacman -Qii $pkg | grep Version | awk '{ printf $3 }')-$(uname -m).pkg.tar.gz"
if [ -f $pkgver ]; then
sudo pacman -U --asexplicit --noconfirm $pkgver
else
yaourt -S --noconfirm $pkg
fi
done
fi
Setting Up a Scripting Environment | Proud donor to wikipedia - link
Offline
recheck - regular expression validator, also supports groups like so:
» perl recheck.pl
S: foo bar baz zing
P: (\S+)\s(\S+)\s(.)(.)(.)\s(.+)
> foo bar baz zing <
[foo] [bar] [b] [a] [z] [zing]
#!/usr/bin/perl
#recheck
use strict;
use warnings;
#die "$0 STRING PATTERN" if !@ARGV;
#my $string = shift;
#my $pattern = shift;
while(1) {
print "S: "; my $string = <STDIN>; exit 0 if $string =~ /:q/;
print "P: "; my $pattern = <STDIN>; exit 0 if $string =~ /:q/;
chomp($string, $pattern);
eval{qr/$pattern/}; die if $@;
my $c = "\033[31;1m";
my $c0 = "\033[0m";
print ">$c $& $c0<\n" if $string =~ /$pattern/;
foreach my $i(1..$#-) {
print ' [', $c, substr($string, $-[$i], $+[$i] - $-[$i]), $c0, ']';
}
print "\n";
}
Offline
hello
I was looking for something like this for a long time but couldn`t find it. So after a while i thought, why not write it myself.
It is my first attempt at writing a script so improvements are welcome.
I use this script with awesomewm so that i get nice "nauthty" pupups. I haven`t tested it with other wm/de.
Also i would really like to add "clickable" notifications that show the email`s content when i click them. Then I don`t have to open mutt everytime i get an email. It would be great if someone could give me a hint in the right direction.
thanks
#!/usr/bin/perl -w
# MAILDIRCHECK, SCRIPT FOR CHECKING MAILDIRS ;)
# - scans folders for new messages
# - outputs a popup notification via "notify-send"
# - great for use witch console mail apps like "mutt"
# put in crontab for automated checking every 5 minutes
# - run: crontab -e
# - add entry: */5 * * * * /path/to/mailcheck.pl >/dev/null 2>&1
# or if you use "offlineimap":
# */10 * * * * /usr/bin/offlineimap -u Noninteractive.Quiet >/dev/null 2>&1 && /path/to/mailcheck.pl >/dev/null 2>&1
# - restart crond daemon
# TODO:
# - make notifications clickable, expand notification to show email
# - get rid of "cannot access" output
# by: eco
# for questions and/or improvements please mail me at "flevosap at gmail dot com"
#### edit here ####
$maildir=""; # set location of maildir. eg. "/home/<user>/mail"
# set wich maildirs to check. eg. "gmail/inbox gmail/arch_forum"
# etc. (do not use quotes or comma`s)
@checkdirs=qw();
$time=0; # time in ms for notifications to stay on the screen, 0 = forever
$urgency="normal"; # urgency level of popup (low,normal,critical)
$datafile_new="/home/nn/.maildircheck.new";
$datafile_old="/home/nn/.maildircheck.old";
$datafile_comm="/home/nn/.maildircheck_commfile";
#### stop editing here ####
if (-e $datafile_new) {
open (DEL, "rm $datafile_new |"); # remove $datafile_new if it exists
close DEL;
}
if (-e $datafile_comm) {
open (DEL, "rm $datafile_comm |"); # remove $datafile_comm if it exists
close DEL;
}
foreach $dir (@checkdirs) { # cycle through dirs in @checkdirs
$dir_open=$maildir."/".$dir."/new/*"; # $dir = complete path to "new" dir
open (WRITE_NEW, "ls -d $dir_open >> $datafile_new |") or die; # for each dir: add "ls" output to $datafile_new
close WRITE_NEW;
}
if (-e $datafile_old) { # IF $datafile_old exists =>
open (COMM, "comm -23 --nocheck-order $datafile_new $datafile_old >$datafile_comm |") or die; # compare two files and write to file
close COMM;
open (COMMFILE, "< $datafile_comm") or die; # open $atafile_com, put content in @newfiles
@newfiles=<COMMFILE>;
close COMMFILE;
open (MOVE_NEW_OLD, "cp $datafile_new $datafile_old |") or die; # move $datafile_new to $datafile_old
close MOVE_NEW_OLD;
}
else { # IF $datafile_old doesn`t exist =>
open (READ_NEW, "< $datafile_new") or die; # open $datafile_new, put content in @newfiles
@newfiles=<READ_NEW>;
close READ_NEW;
open (MOVE_NEW_OLD, "cp $datafile_new $datafile_old |") or die; # move $datafile_new to $datafile_old
close MOVE_NEW_OLD;
}
foreach $file (@newfiles) { # cycle through files in @newfiles
chomp ($file); # get rid of \n at end of lines
open (DATA_FROM, "cat $file | grep 'From: ' |") or die "Couldn't execute program: $!"; # extract "From:" line from $file
$from = <DATA_FROM>;
close DATA_FROM;
open (DATA_SUBJECT, "cat $file | grep 'Subject: ' |") or die "Couldn't execute program: $!"; # extract "Subject:" line from $file
$subject = <DATA_SUBJECT>;
close DATA_SUBJECT;
chomp ($from); # get rid of \n at end of line
chomp ($subject);
$from =~ s/"//g; # get rid of " in variable
$subject =~ s/"//g;
$from =~ s/</(/g; # get rid of < in variable
$subject =~ s/</(/g;
$from =~ s/>/)/g; # get rid of > in variable
$subject =~ s/>/)/g;
foreach $dir (@checkdirs){ # cycle through dirs till $file contains one of the dirs in @checkdirs
if ($file =~ $dir){
$newdir=$dir;
}
}
# send out notification
open (OUTPUT, "notify-send -u $urgency -t $time \"new message:\" \"in: $newdir\n$from\n$subject\" |") or die "Couldn't execute program: $!";
close OUTPUT;
}
Last edited by eco (2010-03-06 17:38:01)
"All programs can be optimized, and all programs have bugs; therefore all programs can be optimized to one line that doesn’t work."
Offline
@eco use strict
Offline
I recently made an extremely simple script, which basically uses Scrot to make you select a region, and take a screenshot. Hereafter, the screenshot is uploaded to my FTP server, and the URL is injected into my clipboard once the image was successfully uploaded - a message via libnotify is shown as well.
However, it's a very simple script, should anybody know of anything a bit better - while still maintaining the ease of use, and speed - please go ahead and link me!
Anyhow, I find it to a lot of use, hopefully you will too.
#!/bin/bash
FTPSERVER=
USERNAME=
PASSWORD=
dir=~/Photos/Screenshots
filename=shot$(date +%Y-%m-%d_%H%M%S)
url=http://example.com/screenshots
scrot -s -q 1 "$dir/$filename.png"
ncftpput -V -u $USERNAME -p $PASSWORD $FTPSERVER /var/www/html/pic $dir/$filename.png
echo "$url$filename.png" | xclip -selection c
notify-send "Image uploaded to $url$filename.png"
exit
Relies on quite a few libraries, you can see these throughout the simple code.
Offline
I'm doing the same thing like this:
scrot -e 'scp -P 19216 $f scp1@192.168.1.33:/srv/http/psy/scrots && rm $f && echo "http:/myhost/scrots/$f"|xclip'
Offline
Make sure to check that DISPLAY is set before running
[git] | [AURpkgs] | [arch-games]
Offline
Here is my killwine script, I use it a lot when windows games freeze up in wine:
#/bin/bash
#This script should kill any runaway wine programs
pid=$(ps -e | grep .e | cut -c 2-5)
kill $pid
"The beautiful thing about learning is nobody can take it away from you."
B.B. King
Offline
Here is my killwine script, I use it a lot when windows games freeze up in wine:
#/bin/bash #This script should kill any runaway wine programs pid=$(ps -e | grep .e | cut -c 2-5) kill $pid
wineserver -k
Offline
#!/bin/bash
export BOOKMARK_DB=${HOME}/.bm.db
bm(){
arg=$1;
if [[ "$arg" = "init" ]]; then
rm "${BOOKMARK_DB}"
echo "CREATE TABLE bookmarks(bookmark text primary key, path text);" |
sqlite3 "${BOOKMARK_DB}"
elif [[ "${arg:0:1}" = '+' ]]; then
arg="${arg:1}"
if [ -z "$2" ]; then
path="$(pwd)"
else
path="$2"
fi
echo "INSERT INTO bookmarks VALUES('${arg}','${path}');" |
sqlite3 "${BOOKMARK_DB}"
elif [[ "${arg:0:1}" = '-' ]]; then
arg="${arg:1}"
echo "DELETE FROM bookmarks WHERE bookmarks.bookmark='${arg}';" |
sqlite3 "${BOOKMARK_DB}"
else
path="$(
echo "SELECT path FROM bookmarks WHERE bookmarks.bookmark='${arg}';" |
sqlite3 "${BOOKMARK_DB}"
)"
if [ -z "$path" ]; then
echo "bookmark not recognised."
elif ! cd "$path" >/dev/null; then
echo "Unable to CD to bookmark '$arg'"
echo "Loaded path $path"
fi
fi
}
A bash bookmark for quick hopping around. Source it or include it in your .bashrc file.
Usage($ indicates lines written, everything else is output):
$ bm init ## create database
$ bm +h ~ ## create one for home
$ bm +d ~/Desktop ## one for my Desktop
$ bm +m ~/music ## for my music
$ pwd
/home/scragar/Desktop/Sorted/iso
$ bm +iso ## for the current directory
$ bm h
$ pwd
/home/scragar
$ bm m
$ pwd
/home/scragar/music
$ bm iso
$ pwd
/home/scragar/Desktop/Sorted/iso
$ ## Now for the really fun stuff
$ bm +t ~/test
$ bm t
Unable to CD to bookmark 't'
Loaded path ~/test
$ bm -t
$ bm t
bookmark not recognised.
Still needs some work so you don't need to delete and recreate a bookmark to change it, but so far I like it
Last edited by scragar (2010-03-09 21:52:56)
Offline
I'm doing the same thing like this:
scrot -e 'scp -P 19216 $f scp1@192.168.1.33:/srv/http/psy/scrots && rm $f && echo "http:/myhost/scrots/$f"|xclip'
Oh man that's great! I was looking for something like this the other day, thanks a lot. Added -s -q 1 as per Sirupsen's script to select region. Egg-sealant
Offline
That is good. Sqlite, man that's hardcore. Might just use that and save space in my bashrc.
Setting Up a Scripting Environment | Proud donor to wikipedia - link
Offline
Very simple script to pick a WM when starting X:
#!/bin/bash
# Selects a window manager to use.
die()
{
[ -n "$1" ] && echo "$1"
exit 1
}
WM="$1" && shift
[ -z "$WM" ] && die "no window manager selected"
case "$WM" in
openbox)
WM_COMMAND="openbox-session"
;;
awesome)
WM_COMMAND="awesome"
;;
*)
die "invalid window manager"
;;
esac
export WM_COMMAND
startx "$@"
unset WM_COMMAND
Offline
@ scragar: I really think you should work on that one, it has potential!
Offline
@scragar: sqlite? Seems a bit overkill to me. There's also: cdbm.
Offline
In response to the large number of comments I should explain that my goal was not to produce some awesome piece of software, but two fold, get a good understanding of sqlite from bash, and to avoid my current directory problems(Desktop/Sorted/iso/games/windows/RPG... Way too long).
If people do enjoy it and want me to continue it I will do so(probably best not to flood this thread though), but it really served it's purpose before I first posted it, I thought someone else might enjoy the code, draw inspiration from it, or whatever.
Offline
I know this is silly (and probably wrong) but I find myself using it all the time now. It's amazing how often the results are either the arch wiki or the forums
#google lucky search
lucky() {
local term="$*"
[ -z "$term" ] && term="$(xclip -o)"
local URL="http://www.google.com/search?btnI=I%27m+Feeling+Lucky&q=${term// /+}"
vimprobable "$URL" &>/dev/null &
}
Hand over the spoon Milt...
Offline
I was playing around with redirection to /dev/pts and came up with this retarded, but entertaining script:
#!/bin/bash
[ ! "$1" ] && {
echo "Usage: matrix <pts-number>"
echo "Grabs control of a terminal and sends the Matrix message."
echo
echo "Choose a pts number:"
echo -e "Number\tUser\tName"
ps aux | awk '/pts\// && /bash/ {print $7":\t("$1")\t"$11}'
exit
}
{
tput civis
echo -e "\r"
clear
echo "Wake up, ${USER^}..."
sleep 4
clear
s="The Matrix has you..."
for ((i=0;i<${#s};i++)); do
echo -n "${s:$i:1}"
case $i in
[0-2]) sleep 0.5;;
[3-6]) sleep 0.2;;
[7-8]) sleep 0.5;;
[9-11]) sleep 0.2;;
[12-13]) sleep 0.5;;
*) sleep 0.2;;
esac
done
sleep 3
clear
s="Follow the white rabbit."
for ((i=0;i<${#s};i++)); do
echo -n "${s:$i:1}"
sleep 0.05
done
sleep 3.5
clear
echo "Knock. Knock. ${USER^}."
sleep 2.5
tput reset
clear
} > /dev/pts/$1
Offline
^cool script.
Last edited by vik_k (2010-03-14 08:55:34)
"First learn computer science and all the theory. Next develop a programming style. Then forget all that and just hack." ~ George Carrette
Offline
My spin on the screenshot script. My script also creates a thumbnail for me and posts it to my server. Also in my clipboard I have the exact piece of forum code needed to post my screenshot.
Thanks to Sirupsen and dmz with the initial script, this will save me so much time.
#!/bin/bash
SHOT="`date +%y%m`.png"
SHOTTHUMB="`date +%y%m`t.png"
SERVER=192.168.1.10
SERVERDIR="/srv/httpd/htdocs/linux/shots"
SERVERURL="http://www.foxjames.co.uk/linux/shots"
SHOTDIR="/tmp"
scrot $SHOTDIR/$SHOT
cp $SHOTDIR/$SHOT $SHOTDIR/$SHOTTHUMB
mogrify -resize 25% $SHOTDIR/$SHOTTHUMB
scp $SHOTDIR/$SHOT $USER@$SERVER:$SERVERDIR
scp $SHOTDIR/$SHOTTHUMB $USER@$SERVER:$SERVERDIR
echo "[url=$SERVERURL/$SHOT][img]$SERVERURL/$SHOTTHUMB[/img][/url]" | xclip
Last edited by gazj (2010-03-14 10:00:53)
Offline