Outils pour utilisateurs

Outils du site


Panneau latéral

vieux_vieux_wiki:scripts

Scripts







Conky (exemple pour quad-core, réseau ethernet)

background no
update_interval 1.0
double_buffer yes
no_buffers yes
cpu_avg_samples 2
net_avg_samples 2
text_buffer_size 2048
imlib_cache_size 0
override_utf8_locale yes
 
# ~~~~~ Window ~~~~~
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
 
#border_inner_margin 0
#border_outer_margin 0
 
# ~~~~~ Alignement ~~~~~
alignment top_right
gap_x 10
gap_y 36
#minimum_size 1050 120
#minimum_width 320
maximum_width 320
 
# ~~~~~ Styles ~~~~~
draw_shades yes
draw_outline no
draw_borders no
draw_graph_borders yes
 
# ~~~~~ Font ~~~~~
use_xft yes
xftfont DejaVu Sans:size=10
xftalpha 0.1
uppercase no
#color1 519F17
#color2 51C541
#color1 ADAEAD
#color2 E3E5E2
 
TEXT
# ~~~~~ Graphes DD ~~~~~
${color1}/foobar :${color1}${alignc}${fs_free /foobar} / ${fs_size /foobar}${color1}${alignr}${fs_used_perc /foobar}%
${color1}${fs_bar /foobar}
${color1}foo :${color1}${alignc}${fs_free /media/foo} / ${fs_size /media/foo}${color1}${alignr}${fs_used_perc /media/foo}%
${color1}${fs_bar /media/foo}
${color1}bar :${color1}${alignc}${fs_free /media/bar} / ${fs_size /media/bar}${color1}${alignr}${fs_used_perc /media/bar}%
${color1}${fs_bar /media/bar}
 
# ~~~~~ Graphes cores ~~~~~
${color1}Moyenne${alignc}Usage: ${freq} MHz${alignr}${cpu cpu0}% 
${cpugraph cpu0 42AE4A eeeeee}
${color1}${cpubar cpu0 5, 320 42AE4A eeeeee}
${color1}Core 1${alignc}Usage: ${freq_g 1} GHz${alignr}${cpu cpu1}%
${color1}${cpugraph cpu1 42AE4A eeeeee}
${color1}${cpubar cpu1 5, 320 42AE4A eeeeee}
${color1}Core 2${alignc}Usage: ${freq_g 2} GHz${alignr}${cpu cpu2}%
${color1}${cpugraph cpu2 42AE4A eeeeee}
${color1}${cpubar cpu2 5, 320 42AE4A eeeeee}
${color1}Core 3${alignc}Usage: ${freq_g 3} GHz${alignr}${cpu cpu3}%
${color1}${cpugraph cpu3 42AE4A eeeeee}
${color1}${cpubar cpu3 5, 320 42AE4A eeeeee}
${color1}Core 4${alignc}Usage: ${freq_g 4} GHz${alignr}${cpu cpu4}%
${color1}${cpugraph cpu4 42AE4A eeeeee}
${color1}${cpubar cpu4 5, 320 42AE4A eeeeee}
 
# ~~~~~ Graphes RAM ~~~~~
${color1}RAM${alignc}$mem / $memmax${color1}${alignr}$memperc%
${memgraph 42AE4A eeeeee}
${color1}CPU${alignr 100}RAM
${top name 1}${alignr 35}${top cpu 1}${alignr 15}${top_mem name 1}${alignr 5}${top mem 1}
${top name 2}${alignr 35}${top cpu 2}${alignr 15}${top_mem name 2}${alignr 5}${top mem 2}
${top name 3}${alignr 35}${top cpu 3}${alignr 15}${top_mem name 3}${alignr 5}${top mem 3}
${top name 4}${alignr 35}${top cpu 4}${alignr 15}${top_mem name 4}${alignr 5}${top mem 4}
${top name 5}${alignr 35}${top cpu 5}${alignr 15}${top_mem name 5}${alignr 5}${top mem 5}
${color1}${membar}
 
# ~~~~~ Reseau ~~~~~ 
${color1}Download: ${color1}${downspeed eth0}${alignr}Total Down: ${totaldown}
${downspeedgraph eth0 42AE4A eeeeee}
 
${color1}Upload: ${color1}${upspeed eth0}${alignr}Total Up: ${totalup}
${upspeedgraph eth0 42AE4A eeeeee}
# ~~~~~ Graphes ~~~~~
 
# ~~~~~ IPs ~~~~~
${if_existing /proc/net/route eth0}Lan, IP Publique :${alignr}${color1}${execi 3500 wget http://automation.whatismyip.com/n09230945.asp -O - -q}${else}Wifi, IP Publique :${alignr}${color1}${execi 3500 wget http://automation.whatismyip.com/n09230945.asp -O - -q}${endif}
${color1}IP Locale  : ${if_existing /proc/net/route eth0}${alignr}${color1}${addr eth0}${else}${alignr}${color1}${addr wlan0}${endif}
${color1}Passerelle : ${alignr}${color1}${gw_ip}
${color1}Serveur    : ${alignr}${color1}$nameserver
 
# ~~~~~ ToDo ~~~~~
${color1}${alignc}To do list :
${exec cat ~/todolist }
$uptime


Récupération de pièces jointes d'un compte email (gmail ici)

import email, getpass, imaplib, os
 
user = raw_input("Enter your GMail username:")
pwd = getpass.getpass("Enter your password: ")
lab = raw_input("Enter your GMail label:")
detach_dir = lab
 
# connecting to the gmail imap server
m = imaplib.IMAP4_SSL("imap.gmail.com")
m.login(user,pwd)
m.select(lab)
 
# use m.list() to get all the mailboxes
resp, items = m.search(None, "ALL") # you could filter using the IMAP rules here (check http://www.example-code.com/csharp/imap-search-critera.asp)
items = items[0].split() # getting the mails id
 
# create label's dir
try:
    os.mkdir(detach_dir)
except OSError:
    pass
 
for emailid in items:
    resp, data = m.fetch(emailid, "(RFC822)") # fetching the mail, "`(RFC822)`" means "get the whole stuff", but you can ask for headers only, etc
    email_body = data[0][1] # getting the mail content
    mail = email.message_from_string(email_body) # parsing the mail content to get a mail object
 
    #Check if any attachments at all
    if mail.get_content_maintype() != 'multipart':
        continue
 
    print "["+mail["From"]+"] :" + mail["Subject"]
 
    # we use walk to create a generator so we can iterate on the parts and forget about the recursive headach
    for part in mail.walk():
        # multipart are just containers, so we skip them
        if part.get_content_maintype() == 'multipart':
            continue
 
        # is this part an attachment ?
        if part.get('Content-Disposition') is None:
            continue
 
        filename = part.get_filename()
        counter = 1
 
        # if there is no filename, we create one with a counter to avoid duplicates
        if not filename:
            filename = 'part-%03d%s' % (counter, 'bin')
            counter += 1
 
        att_path = os.path.join(detach_dir, filename)
 
        #Check if its already there
        if not os.path.isfile(att_path) :
            # finally write the stuff
            fp = open(att_path, 'wb')
            fp.write(part.get_payload(decode=True))
            fp.close()


firefox-clean

#!/bin/bash
firefox
PROFIL="mon.profil"
#cache
rm -rf $HOME/.mozilla/firefox/"$PROFIL"/Cache/*
rm -rf $HOME/.cache/mozilla/firefox/"$PROFIL"/Cache/*
#cookies
rm -rf $HOME/.mozilla/firefox/"$PROFIL"/cookies.sqlite
#cache flash
#rm -rf $HOME/.adobe/#Flash_Player/AssetCache/
#cookies flash
#rm -rf $HOME/.macromedia/#Flash_Player/#SharedObjects/
#rm -rf $HOME/.macromedia/Flash_Player/macromedia.com/support/flashplayer/sys/
exit 0

Attention, peut bloquer les mise à jour, si c'est le cas, lancer Firefox normalement.

Aspirateurs

Scans Naruto

#!/bin/bash
#~ usage: ./naruto chapDebut
#~ usage: ./naruto chapDebut chapFin
#~ Attention ne pas mettre script dans le même répertoire que la sortie !
adresse="http://www.scan-mx.com/lecture-en-ligne/mangas/naruto"
temp="./tmp/"
out="./out/"
deb=$1
 
if [ "${#}" -eq 0 ] ; then
	echo "Préciser chapitre"
	exit 1
else
	if [ "$2" != "" ] ; then
		fin=$2
	else
		fin=$1
	fi
fi
 
de=1
wget -qP $temp "http://www.naruto-mx.com/lecture-en-ligne/naruto/""$deb"
 
fi="$(grep ' sur ' "$temp""$deb" | sed 's/^.* sur //' | sed -n '4p' | cut -c -2)"
 
if [ "${#fi}" -eq 0 ] ; then
	fi=$(grep ' sur ' "$temp""$deb" | sed 's/^.* sur //' | sed -n '3p' | cut -c -2)
fi
 
adresse=$(grep '<meta property' "$temp""$deb" | sed 's/^.*content="//' | sed 's/".*//' | sed "s/...........$//")
rm -rf "$temp"/"$deb"
 
#boucle chapitres
for chap in $(seq "$deb" "$fin"); do
#boucle pages
	for page in $(seq "$de" "$fi");
	do
#extension par defaut
		ext=".jpg"
#bourrage 0
		if [ "${#page}" -eq 1 ] ; then
			page="0""$page"
		fi
# wget de la page
		wget -qP "$temp" "$adresse"/"$chap"/"$page""$ext"
#si erreur changement extension
		if [ $? != 0 ] ; then
			ext=".JPG"
			wget -qP "$temp" "$adresse"/"$chap"/"$page""$ext"
#si erreur changement extension
		elif [ $? != 0 ] ; then
			ext=".png"
			wget -qP "$temp" "$adresse"/"$chap"/"$page""$ext"
		fi
		echo "$page"
	done
#archivage en cbz
	zip -rj "$temp""$chap"".cbz" "$temp"
#suprression ressources
	mv "$temp""$chap"".cbz" "$out"
	rm -rf "$temp"*
done
 
exit 0
vieux_vieux_wiki/scripts.txt · Dernière modification: 2013/10/25 07:54 (modification externe)