Sie sind auf Seite 1von 23

Batera

#!/usr/bin/env bash
notify-send "Battery low" --icon=battery-caution
zenity --info --text \
"<span color=\"blue\"><b>bateria baja?</b></span>\n \
<span><i>Very</i> <u>well</u>, <s>and</s> <b>you</b>?</span>\n \
<span color=\"red\">battery low</span> <span color=\"green\">color</span> <span
color=\"blue\">test</span>\n \
<span font-family=\"serif\">battery</span> \
<span font-family=\"sans\">low</span> \
<span font-family=\"mono\">///////////////////////</span>" --width=600 --height=400 & sleep 10
zenity --info --text \
"<span color=\"red\" font-family=\"sans\" font-weight=\"900\" font-size=\"xx-large\">bateria
baja</span>" --width=800 --height=600 & sleep 10
zenity --info --text \
"<span color=\"blue\" font-family=\"sans\" font-weight=\"900\" font-size=\"xx-large\">bateria
baja</span>" --width=800 --height=600 & sleep 10
zenity --question --timeout 10 --text="Backup completed. Suspend the system? \nThis dialog will
timeout in 10 seconds, after which the system will suspend."
if [[ $? -eq 1 ]] ; then
# user clicked Cancel
exit $rc
else
dbus-send --print-reply --system
\
--dest=org.freedesktop.login1
\
/org/freedesktop/login1
\
org.freedesktop.login1.Manager.Suspend boolean:true
fi
Brillo pantalla
#!/bin/bash
#xrandr --verbose | grep -i brightness | cut -f2 -d ' ' | head -n1
A=$(xrandr --verbose | grep -i brightness | cut -f2 -d ' ' | head -n1)
A=$(echo $A - 0.1 | bc)
xrandr --output eDP --brightness $A
bat baja
#!/usr/bin/env bash
notify-send "Battery low" --icon=battery-caution
zenity --info --text="bateria baja."
zenity --info --text="bateria baja"
cifrae e wav

#!/usr/bin/env python
# -*- coding: UTF-8 -*import easygui,wave
import os, random, struct
from Crypto.Cipher import AES
from Tkinter import Tk
from tkFileDialog import askopenfilename
Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
#filename = askopenfilename() # show an "Open" dialog
def encrypt_file(key, in_filename, out_filename=None, chunksize=64*1024):
""" Encrypts a file using AES (CBC mode) with the
given key.
key:
The encryption key - a string that must be
either 16, 24 or 32 bytes long. Longer keys
are more secure.
in_filename:
Name of the input file
out_filename:
If None, '<in_filename>.enc' will be used.
chunksize:
Sets the size of the chunk which the function
uses to read and encrypt the file. Larger chunk
sizes can be faster for some files and machines.
chunksize must be divisible by 16.
"""
if not out_filename:
out_filename = in_filename + '.w'
iv = ''.join(chr(random.randint(0, 0xFF)) for i in range(16))
encryptor = AES.new(key, AES.MODE_CBC, iv)
filesize = os.path.getsize(in_filename)
with open(in_filename, 'rb') as infile:
with open(out_filename, 'wb') as outfile:
outfile.write(struct.pack('<Q', filesize))
outfile.write(iv)
while True:
chunk = infile.read(chunksize)
if len(chunk) == 0:
break
elif len(chunk) % 16 != 0:
chunk += ' ' * (16 - len(chunk) % 16)
outfile.write(encryptor.encrypt(chunk))

return out_filename
def decrypt_file(key, in_filename, out_filename=None, chunksize=24*1024):
""" Decrypts a file using AES (CBC mode) with the
given key. Parameters are similar to encrypt_file,
with one difference: out_filename, if not supplied
will be in_filename without its last extension
(i.e. if in_filename is 'aaa.zip.enc' then
out_filename will be 'aaa.zip')
"""
if not out_filename:
out_filename = os.path.splitext(pathFileWav)[0]
with open(in_filename, 'rb') as infile:
origsize = struct.unpack('<Q', infile.read(struct.calcsize('Q')))[0]
iv = infile.read(16)
decryptor = AES.new(key, AES.MODE_CBC, iv)
with open(out_filename, 'wb') as outfile:
while True:
chunk = infile.read(chunksize)
if len(chunk) == 0:
break
outfile.write(decryptor.decrypt(chunk))
outfile.truncate(origsize)
ke = easygui.passwordbox('contrasena para cifrar o descifrar') # clave de cifrado en caso de haberlo
activado
if len(ke) <32 :
while len(ke) < 32 :
ke = ke + "p"
elif len(ke) >32:
ke = ke[:32]
else :
ke = ke
# constantes cifrado
CIPHER_ON = 1 # cifrado activo
CIPHER_OFF = 0 # cifrado inactivo
# variables modificables a gusto
jumpsData = 10 #Espacio de muestras del framerate para la toma de datos vlidos
numFraSize = 4 # 32bits para determinar cuantos bytes ocupa el fichero oculto
header = ["S", "Y", "L", "M"] # 1 byte por cada caracter (contra menos caracteres, ms
posibilidades de error por accidente)
passphrase_cipher = ke
cipher = CIPHER_OFF
msg1 ="que hacemos?"
title1 = "eleccion"
choices = ["codificar", "descodificar"]

choice1= easygui.choicebox(msg1, title1, choices)


if choice1 == "descodificar":
# DATOS DEL USUARIO:
pathFileWav = askopenfilename(title = "selecciona archivo wav a decodificar")
sizeFileToHide = 0
sizeFileWav = 0
# Abrimos el archivo WAV que oculta algo
fileAudioBase = wave.open(pathFileWav,'rb')
bytesFileAudioBase = bytearray(fileAudioBase.readframes(fileAudioBase.getnframes()))
channels = fileAudioBase.getnchannels() # canales de audio
sampleWidth = fileAudioBase.getsampwidth() # nmero de bytes para las muestras del
samplerate
frameRate = fileAudioBase.getframerate()
numTotalFrames = fileAudioBase.getnframes()
startIn = 0
indexHeader = 0
indexSampleWav = startIn
saltos = (sampleWidth * jumpsData)
bytesFileOculto = []
indexFileOculto = 0
error = 0
# Leemos cabecera:
for i in range(len(header)):
#bytesFileOculto.append(bytesFileAudioBase[indexSampleWav])
#indexFileOculto += 1
print header[i], chr(bytesFileAudioBase[indexSampleWav])
if header[i] != chr(bytesFileAudioBase[indexSampleWav]):
error = 1
print "Cabecera no vlida"
exit(error)
indexSampleWav += saltos
print "Cabecera vlida (OK!)"
# Leemos el tipo de cifrado que utilizar el fichero resultante:
typeCipher = bytesFileAudioBase[indexSampleWav]
indexSampleWav += saltos
listTamanio = []
# Leemos los bytes que determinan el tamao en bytes del fichero:
for i in range(numFraSize):

listTamanio.append(bytesFileAudioBase[indexSampleWav])
indexSampleWav += saltos
print "Bytes tamao fichero oculto: ", listTamanio
listTamanio.reverse()
print "Bytes tamao reordenados: ", listTamanio
desplazamiento = 0
tamanio = ""
for i in range(numFraSize):
#tamanio += bin(listTamanio[i] & 0xFF)[2:]
listTamanio[i]>>desplazamiento
tamanio += bin(listTamanio[i] & 0xFF)[2:].zfill(8)
print "byte: ", bin(listTamanio[i])[2:].zfill(8)
desplazamiento += 8
sizeFileHidden = int(tamanio, 2)
print "Bytes ocultos: ", sizeFileHidden
bytesFileOculto = []
indexDataHidden = 0
while indexDataHidden < sizeFileHidden:
bytesFileOculto.append(bytesFileAudioBase[indexSampleWav])
indexSampleWav += saltos
indexDataHidden += 1
nameFileResult = "pepe"
ficheroRecuperado = open(nameFileResult, 'wb')
newFileByteArray = bytearray(bytesFileOculto)
ficheroRecuperado.write(newFileByteArray)
ficheroRecuperado.close()
decrypt_file(ke,"pepe")
#os.remove("recuperado.cip")
easygui.textbox("hecho , archivo decodificado nombre recuperado")
os.remove("pepe")
else :
in_file= askopenfilename(title = "selecciona archivo a ocultar") # show an "Open" dialog
pathFileToHide = encrypt_file(ke,in_file)
#cantidad = float(input("Dgame una cantidad en euros (hasta con 2 decimales): "))
# DATOS DE LOS FICHEROS NECESARIOS:
#pathFileToHideCipher = pathFileToHide + ".cipher"
pathFileWav = askopenfilename(title = "selecciona archivo wav para ocultacion")

pathFileWavResult = pathFileToHide + 'av' # nombre de fichero de salida (el que ocultar el


contenido)

#
# COMPOSICIN DE LA TRAMA DE DATOS OCULTOS:
#
# (CABECERA)->(CIFRADO)->(TAMAO ARCHIVO)->(BYTES ARCHIVO)
#
#TRATANDO CON LOS FICHEROS:
# FICHERO BASE WAV DONDE LO VAMOS A OCULTAR
fileWav = wave.open(pathFileWav,'rb')
bytesfileWav = bytearray(fileWav.readframes(fileWav.getnframes())) # guardamos los bytes (del
muestreo) en un array de bytes
channels = fileWav.getnchannels() # canales de audio (1 mono, 2 stereo)
sampleWidth = fileWav.getsampwidth() # nmero de bytes para las muestras del samplerate
frameRate = fileWav.getframerate() # obtenemos el nmero de muestras (frames) por segundo
que realiza
numTotalFrames = fileWav.getnframes() # obtenemos el nmero total de muestras disponibles
(frames)
# calculamos el nmero total de bytes que se puede almacenar:
bytesMaximos = ((numTotalFrames / sampleWidth) / jumpsData) - len(header) - 1 # el -1 es para
evitar Bytes hurfanos
# mostramos la informacin por pantalla:
print "Nmero de canales: ",channels
print "Ancho de muestra del sample (bytes): ",sampleWidth
print "Nmero de frames totales: ", numTotalFrames
print "Capacidad mxima de almacenado: ", bytesMaximos, "Bytes (",float(bytesMaximos /
1024), "KBytes )"

# FICHERO QUE QUEREMOS OCULTAR


try:
fileToHide = open(pathFileToHide,'rb')
except:
print "ERROR: problema con fichero"
exit(1)
bytesFileToHide = bytearray(fileToHide.read()) # guardamos todos los bytes del archivo en un
array
#fileToHide.close()
# comprobamos que el archivo de audio tenga capacidad para esconder el fichero:

if len(bytesFileToHide) < bytesMaximos:


easygui.textbox( "El archivo a ocultar cabe, ok")
else:
easygui.textbox( "El archivo a ocultar no cabe, elige uno menor o un wav mayor")
exit(1)
startIn = 0 # byte del sample de audio donde se empieza a contar
# A tener en cuenta:
#
# bytem = byte menos significativo
# byteM = byte ms significativo
#
# si se un sistema estereo el muestreo comienza as -> bytem_ch1 - byteM_ch1 - bytem_ch2 byteM_ch2 .....
# si se un sistema mono el muestreo comienza as -> bytem_ch1 - byteM_ch1 - bytem_ch1 byteM_ch1 .....
#
# ---------------indexHeader = 0
indexFileToHide = 0
indexSampleWav = startIn
jump = (sampleWidth * jumpsData) # salto para grabar en los bytes correctos
# grabamos la cabecera
while indexHeader < len(header):
bytesfileWav[indexSampleWav] = header[indexHeader]
indexHeader += 1
indexSampleWav += jump
# grabamos el valor de cifrado
bytesfileWav[indexSampleWav] = cipher
indexSampleWav += jump
# grabamos el tamao bytes que ocupa el fichero oculto en los bytes asignados para ello
# utilizamos desplazamiento de bits para guardarlo en bloques de un octeto (byte) y luego poder
recomponerlo
desplazamiento = 0
for i in range(numFraSize):
#print bytes(len(bytesFileToHide)>>24 & 0xFF) , bytes(len(bytesFileToHide)>>16 & 0xFF) ,
bytes(len(bytesFileToHide)>>8 & 0xFF) , bytes(len(bytesFileToHide)>>0 & 0xFF)
bytesfileWav[indexSampleWav] = len(bytesFileToHide)>>desplazamiento & 0xFF
desplazamiento += 8
indexSampleWav += jump
# grabamos los bytes del archivo oculto en el audio
while indexFileToHide < len(bytesFileToHide):
bytesfileWav[indexSampleWav] = bytesFileToHide[indexFileToHide]

indexSampleWav += jump
indexFileToHide += 1
print indexFileToHide
# GRABAMOS EL FICHERO DE AUDIO RESULTANTE:
outEstegoWAV = wave.open(pathFileWavResult, "wb")
outEstegoWAV.setnchannels(channels)
outEstegoWAV.setsampwidth(sampleWidth)
outEstegoWAV.setframerate(frameRate)
outEstegoWAV.writeframes(bytesfileWav)
outEstegoWAV.close()
easygui.textbox("hecho , archivo codificado junto al original")
fileToHide.close()
os.remove(pathFileToHide)
crear link
#!/usr/bin/env bash
file="$1"
#file=$(zenity --file-selection --title="confirme archivo a linkar")
directorio=$(zenity --file-selection --directory --title="enviar a...")
ln -sv $file $directorio
zenity --info --text="enlace creado."
diferenc 2 imagenes
#!/usr/bin/python
import cv2
#Cargamos las dos imagenes para hacer las diferencias
diff1 = cv2.imread('diff1.png')
diff2 = cv2.imread('diff2.png')
#Calculamos la diferencia absoluta de las dos imagenes
diff_total = cv2.absdiff(diff1, diff2)
#Buscamos los contornos
imagen_gris = cv2.cvtColor(diff_total, cv2.COLOR_BGR2GRAY)
contours,_ =
cv2.findContours(imagen_gris,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)

#Miramos cada uno de los contornos y, si no es ruido, dibujamos su Bounding Box sobre la imagen
original
for c in contours:
if cv2.contourArea(c) >= 20:
posicion_x,posicion_y,ancho,alto = cv2.boundingRect(c) #Guardamos las dimensiones de la
Bounding Box
cv2.rectangle(diff1,(posicion_x,posicion_y),(posicion_x+ancho,posicion_y+alto),(0,0,255),2)
#Dibujamos la bounding box sobre diff1
while(1):
#Mostramos las imagenes. ESC para salir.
cv2.imshow('Imagen1', diff1)
cv2.imshow('Imagen2', diff2)
cv2.imshow('Diferencias detectadas', diff_total)
tecla = cv2.waitKey(5) & 0xFF
if tecla == 27:
break
cv2.destroyAllWindows()
encriptar
#!/usr/bin/env python
# -*- coding: UTF-8 -*import easygui
import os, random, struct
from Crypto.Cipher import AES
from Tkinter import Tk
from tkFileDialog import askopenfilename
Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
def encrypt_file(key, in_filename, out_filename=None, chunksize=64*1024):
""" Encrypts a file using AES (CBC mode) with the
given key.
key:
The encryption key - a string that must be
either 16, 24 or 32 bytes long. Longer keys
are more secure.
in_filename:
Name of the input file
out_filename:
If None, '<in_filename>.enc' will be used.
chunksize:
Sets the size of the chunk which the function
uses to read and encrypt the file. Larger chunk
sizes can be faster for some files and machines.

chunksize must be divisible by 16.


"""
if not out_filename:
out_filename = in_filename + '.enc'
iv = ''.join(chr(random.randint(0, 0xFF)) for i in range(16))
encryptor = AES.new(key, AES.MODE_CBC, iv)
filesize = os.path.getsize(in_filename)
with open(in_filename, 'rb') as infile:
with open(out_filename, 'wb') as outfile:
outfile.write(struct.pack('<Q', filesize))
outfile.write(iv)
while True:
chunk = infile.read(chunksize)
if len(chunk) == 0:
break
elif len(chunk) % 16 != 0:
chunk += ' ' * (16 - len(chunk) % 16)
outfile.write(encryptor.encrypt(chunk))
def decrypt_file(key, in_filename, out_filename=None, chunksize=24*1024):
""" Decrypts a file using AES (CBC mode) with the
given key. Parameters are similar to encrypt_file,
with one difference: out_filename, if not supplied
will be in_filename without its last extension
(i.e. if in_filename is 'aaa.zip.enc' then
out_filename will be 'aaa.zip')
"""
if not out_filename:
out_filename = os.path.splitext(in_filename)[0]
with open(in_filename, 'rb') as infile:
origsize = struct.unpack('<Q', infile.read(struct.calcsize('Q')))[0]
iv = infile.read(16)
decryptor = AES.new(key, AES.MODE_CBC, iv)
with open(out_filename, 'wb') as outfile:
while True:
chunk = infile.read(chunksize)
if len(chunk) == 0:
break
outfile.write(decryptor.decrypt(chunk))
outfile.truncate(origsize)
ke = easygui.passwordbox('contrasena para cifrar o descifrar') # clave de cifrado en caso de haberlo
activado
if len(ke) <32 :

while len(ke) < 32 :


ke = ke + "p"
elif len(ke) >32:
ke = ke[:32]
else :
ke = ke
msg1 ="que hacemos?"
title1 = "eleccion"
choices = ["codificar", "descodificar"]
choice1= easygui.choicebox(msg1, title1, choices)
if choice1 == "descodificar":
ino = askopenfilename(title = "selecciona archivo a decodificar")
decrypt_file(ke,ino)
easygui.textbox("hecho , archivo decodificado junto al original")
else :
in_file= askopenfilename(title = "selecciona archivo a codificar")
encrypt_file(ke,in_file)
easygui.textbox("hecho , archivo codificado junto al original")
shred
#!/usr/bin/env bash
#-----------------------------------------------------------------------------#shred_file Version: 0.1
#Copyright (C) 2007 Josh Barrick (random125@gmail.com)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#***CAUTION***
#
Do NOT use on device files like /dev/hda.
#
If you need to shred these files, refer to the shred man pages.
#***CAUTION***
#
Use of this script on a file will make recovery impossible,
#
even with the more expensive file recovery solutions.
#

#This script will shred the input file, after confirmation.


#You will also be notified, when shredding is complete. (Should this be
#removed?)
#-----------------------------------------------------------------------------file="$1"
zenity --question --title="Shred" --text="Are you sure you wish to shred $file?"
if [ "$?" = 1 ] ; then
exit $?
else
shred -u -z "$file"
zenity --info --text="$file: shredding complete."
fi
srm
#!/usr/bin/env bash
file="$1"
zenity --question --title="borrar_carpeta_definitivamente" --text="quieres borrar del todo este
archivo $file?"
if [ "$?" = 1 ] ; then
exit $?
else
srm -r "$file"
zenity --info --text="$file: archivo borrado."
fi

ooo
#!/usr/bin/env bash
file="$1"
zenity --question --title="borrar_carpeta_definitivamente" --text="quieres borrar del todo este
archivo $file?"
if [ "$?" = 1 ] ; then
exit $?
else
srm "$file"
zenity --info --text="$file: archivo borrado."
fi
wine32
#!/usr/bin/env bash
file="$1"
#file=$(zenity --file-selection --title="confire archivo abrir wine32")
if env WINEPREFIX=~/.wine32 wine "$file" 2>/dev/null ; then

zenity --info --text="operacion copletada."


else
zenity --info --text="archivo no 32 u otro error"
fi
esconder en png
#!/usr/bin/python
# -*- coding: utf-8 -*import Image, stepic
import easygui
import tkFileDialog
from tkFileDialog import askopenfilename

msg1 ="que hacemos?"


title1 = "eleccion"
choices = ["codificar", "descodificar"]
choice1= easygui.choicebox(msg1, title1, choices)
if choice1 == "descodificar":
ino = askopenfilename(title = "selecciona archivo png portador")
im=Image.open(ino)
s=stepic.decode(im)
f=open('mensaje', 'w')
f.write(s)
f.close()
easygui.textbox("hecho , archivo llamado mensaje junto al original")
else :
ino = askopenfilename(title = "selecciona archivo png portador")
m=Image.open (ino)
ino2 = askopenfilename(title = "selecciona archivo a ocultar")
tx=open(ino2, "rb")
tx2=tx.read()
im2=stepic.encode(m, tx2)
im2.save(tkFileDialog.asksaveasfile(mode='w', defaultextension=".png") , "PNG")
easygui.textbox("hecho , archivo codificado junto al original")
bajarbrillo cualquierscreen
#!/bin/bash
#xrandr --verbose | grep -i brightness | cut -f2 -d ' ' | head -n1
A=$(xrandr --verbose | grep -i brightness | cut -f2 -d ' ' | head -n1)

A=$(echo $A - 0.1 | bc)


b=$(xrandr -q | grep ' connected' | head -n 1 | cut -d ' ' -f1)
xrandr --output $b --brightness $A
resoluc cualq pantalla
#!/bin/bash
# newrez
# Marc Brumlik, Tailored Software Inc, tsi-inc@comcast.net
# up to v 0.8
# use 'xrandr' to scale video output to the display
# v 0.9
# Wed Jan 2 05:23:54 CST 2013
# rewrite to handle mouse boundaries when scaled (mouse confined)
# by setting requested resolution to the unused VGA1 device
# then scaling that for display on the LVDS1 device
# v 1.1
# Fri Dec 20 08:28:08 CST 2013
# fixed issue where setting to "default" after some other resulution
# left mouse-area at prior resolution
umask 000
# resolution can optionally be specified on command line
newrez=$1
# we MUST be running xrandr 1.3 or higher
if xrandr -v | grep "RandR version 1.[012]"
then zenity --info --title="XRandR version is too old" --text="You must be running
Xrandr
version 1.3 or newer!
Time to upgrade your system :-)"
exit 0
fi
#tipo de pantalla
tipo=$(xrandr -q | grep ' connected' | head -n 1 | cut -d ' ' -f1)
default=`echo "$current" | grep -A 1 "^$tipo" | tail -1 | awk '{print $1}'`
print $default
H=`echo $default | cut -d'x' -f1`
V=`echo $default | cut -d'x' -f2`
HZ=`echo $default | awk '{print $2}' | tr -d '[*+]'`
# echo DEFAULT: $default $H $V

if [ -z "$newrez" ]
then while true
do
newrez=`zenity --entry --title="Set New Resolution" \
--text="Default Resolution: $default\n\nNew size (eg 1280x750 or
1450x1000)\n -or- \"default\""` || exit 0
case $newrez in
default|[0-9]*x[0-9]*)break ;;
esac
done
fi
case $newrez in
default)

xrandr --output $tipo --mode $default --scale 1x1


xrandr --addmode $tipo $default
xrandr --newmode $default $newmode
xrandr --output $tipo --mode $default --scale 1x1
exit 0 ;;

esac
newH=`echo $newrez | cut -d'x' -f1`
newV=`echo $newrez | cut -d'x' -f2`
modeline=`cvt $newH $newV $HZ | grep Modeline`
newmode=`echo "$modeline" | sed 's/^.*"//'`
cvtrez=`echo "$modeline" | sed -e 's/_.*//' -e 's/^.*"//'`
if [ "$newrez" != "$cvtrez" ]
then newrez=$cvtrez
newH=`echo $newrez | cut -d'x' -f1`
newV=`echo $newrez | cut -d'x' -f2`
fi
scaleH=`echo -e "scale=10\n$newH / $H\nquit" | bc`
scaleV=`echo -e "scale=10\n$newV / $V\nquit" | bc`
if echo "$current" | grep -A 100 "^$tipo" | grep $newrez >/dev/null
then : already there
else xrandr --newmode "$newrez" $newmode
xrandr --addmode $tipo $newrez
fi
if xrandr --output $tipo --mode $newrez --output $tipo --fb $newrez --scale $scaleH"x"$scaleV
2>&1 | tee -a /tmp/xrandr.err
then : success
else zenity --info --title="Xrandr produced this error" --text="`cat /tmp/xrandr.err`"
The problem could be that Your video driver
does not support xrandr version 1.3
rm -f /tmp/xrandr.err
fi

resol pantalla
#!/bin/bash
# newrez
# Marc Brumlik, Tailored Software Inc, tsi-inc@comcast.net
# up to v 0.8
# use 'xrandr' to scale video output to the display
# v 0.9
# Wed Jan 2 05:23:54 CST 2013
# rewrite to handle mouse boundaries when scaled (mouse confined)
# by setting requested resolution to the unused VGA1 device
# then scaling that for display on the LVDS1 device
# v 1.1
# Fri Dec 20 08:28:08 CST 2013
# fixed issue where setting to "default" after some other resulution
# left mouse-area at prior resolution
umask 000
# resolution can optionally be specified on command line
newrez=$1
# we MUST be running xrandr 1.3 or higher
if xrandr -v | grep "RandR version 1.[012]"
then zenity --info --title="XRandR version is too old" --text="You must be running
Xrandr
version 1.3 or newer!
Time to upgrade your system :-)"
exit 0
fi
# find the currently connected devices, make a list
devices=`xrandr -q | grep connected | grep -v disconnected | cut -d"(" -f1`
# there MUST be a "connected" LVDS1 and a "disconnected" VGA1
current=`xrandr -q`
if echo "$current" | grep "LVDS1 connected" >/dev/null
then : OK
else zenity --info --title="PROBLEM" --text="Current display must be LVDS1"; exit 0
fi
if echo "$current" | grep "VGA1 disconnected" >/dev/null
then : OK
else zenity --info --title="IMPORTANT" --text="The VGA1 display resolution may be
affected by this change"
fi

default=`echo "$current" | grep -A 1 "^LVDS1" | tail -1 | awk '{print $1}'`


H=`echo $default | cut -d'x' -f1`
V=`echo $default | cut -d'x' -f2`
HZ=`echo $default | awk '{print $2}' | tr -d '[*+]'`
# echo DEFAULT: $default $H $V
if [ -z "$newrez" ]
then while true
do
newrez=`zenity --entry --title="Set New Resolution" \
--text="Default Resolution: $default\n\nNew size (eg 1280x750 or
1450x1000)\n -or- \"default\""` || exit 0
case $newrez in
default|[0-9]*x[0-9]*)break ;;
esac
done
fi
case $newrez in
default)

xrandr --output LVDS1 --mode $default --scale 1x1


xrandr --addmode VGA1 $default
xrandr --newmode $default $newmode
xrandr --output VGA1 --mode $default --scale 1x1
exit 0 ;;

esac
newH=`echo $newrez | cut -d'x' -f1`
newV=`echo $newrez | cut -d'x' -f2`
modeline=`cvt $newH $newV $HZ | grep Modeline`
newmode=`echo "$modeline" | sed 's/^.*"//'`
cvtrez=`echo "$modeline" | sed -e 's/_.*//' -e 's/^.*"//'`
if [ "$newrez" != "$cvtrez" ]
then newrez=$cvtrez
newH=`echo $newrez | cut -d'x' -f1`
newV=`echo $newrez | cut -d'x' -f2`
fi
scaleH=`echo -e "scale=10\n$newH / $H\nquit" | bc`
scaleV=`echo -e "scale=10\n$newV / $V\nquit" | bc`
if echo "$current" | grep -A 100 "^VGA1" | grep $newrez >/dev/null
then : already there
else xrandr --newmode "$newrez" $newmode
xrandr --addmode VGA1 $newrez
fi
if xrandr --output VGA1 --mode $newrez --output LVDS1 --fb $newrez --scale $scaleH"x"$scaleV
2>&1 | tee -a /tmp/xrandr.err
then : success
else zenity --info --title="Xrandr produced this error" --text="`cat /tmp/xrandr.err`"

The problem could be that Your video driver


does not support xrandr version 1.3
rm -f /tmp/xrandr.err
fi
multisystem
#! /bin/bash
exec >& >(tee -a /tmp/debog-install-depot-multisystem.txt)
#

install-depot-multisystem.sh

crit par Franois Fabre

MultiSystem LiveUSB

#Mr Fabre Franois @frafa


#E-Mail: liveusb@gmail.com En Franais SVP !
#http://liveusb.info/
#License: GNU General Public License (GPL)
#Ce programme est un logiciel libre: vous pouvez le redistribuer
#et/ou le modifier selon les termes de la "GNU General Public
#License", tels que publis par la "Free Software Foundation"; soit
#la version 2 de cette licence ou ( votre choix) toute version
#ultrieure.
#
#Ce programme est distribu dans l'espoir qu'il sera utile, mais
#SANS AUCUNE GARANTIE, ni explicite ni implicite; sans mme les
#garanties de commercialisation ou d'adaptation dans un but spcifique.
#
#Se rfrer la "GNU General Public License" pour plus de dtails.
#
#Vous devriez avoir reu une copie de la "GNU General Public License"
#en mme temps que ce programme; sinon, crivez a la "Free Software
#Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA".
#http://www.gnu.org/licenses/gpl-howto.fr.html
#Sous Kde en boot livecd Activer dept universe et installer zenity
if [ "$(sudo -A cat grep '^%admin ALL=(ALL) NOPASSWD: ALL' /etc/sudoers 2>/dev/null)" ];
then
echo
if [ "$(which software-properties-kde)" ]; then
sudo software-properties-kde --enable-component universe
if [ ! "$(which zenity)" ]; then
xterm -title 'Install zenity' -e "sudo apt-get update && sudo apt-get install -q -y zenity"
fi

fi
fi
#quelques test...
errorlist=()
testlist="apt-get sudo lsb_release tee zenity nohup xterm dpkg"
for i in ${testlist}
do
if [ ! "$(which "$i")" ]; then
errorlist=(${errorlist[@]} $i)
fi
done
#Stop si
if [ "$(echo "${errorlist[@]}")" ]; then
echo -e "\033[1;47;31m Error: ${errorlist[@]} \033[0m"
miseenforme="${errorlist[@]}"
zenity --error --text "Error: ${miseenforme}" 2>/dev/null
exit 0
fi
#si pas sudo!
if [ ! "$SUDO_USER" ]; then
msg1="L'installation de multisystem necessite les droits d'administrateur."
msg2="Installing multisystem requires administrator rights."
if [ "$(echo $LANG | grep -i "fr_FR.utf")" ]; then
zenity --info --text "<b>${msg1}</b>"
else
zenity --info --text "<b>${msg2}</b>"
fi
xterm -e "sudo "$0""
exit 0
fi
#chmod 777 /media
if [ "$(stat -c %a /media)" != "777" ]; then
chmod 777 /media
fi
#Rajouter test si deja install sortie!
if [ "$(dpkg -l | grep 'ii multisystem')" ]; then
msg1="multisystem est dj install!"
msg2="multisystem is already installed!"
if [ "$(echo $LANG | grep -i "fr_FR.utf")" ]; then
zenity --info --text "<b>${msg1}</b>"
else
zenity --info --text "<b>${msg2}</b>"
fi
exit 0
fi
#verifier que user appartiens au group disk
if [ ! "$(grep ^disk /etc/group | grep "$SUDO_USER")" ]; then

usermod -a -G disk "$SUDO_USER"


fi
#verifier que user appartiens au group adm
if [ ! "$(grep ^adm /etc/group | grep "$SUDO_USER")" ]; then
usermod -a -G adm "$SUDO_USER"
fi
#Activer dept universe
if [ "$(which software-properties-gtk)" ]; then
#Sous Gnome
software-properties-gtk -e universe
elif [ "$(which software-properties-kde)" ]; then
#Sous Kde
software-properties-kde --enable-component universe
fi
#Pour Ubuntu hardy il faut activer en + le depot hardy-backport
if [ "$(lsb_release -cs)" == "hardy" ]; then
echo
#Sous Gnome
if [ "$(which software-properties-gtk)" ]; then
software-properties-gtk -e hardy-backport
#Sous Kde
elif [ "$(which software-properties-kde)" ]; then
software-properties-kde --enable-component hardy-backport
fi
fi
#Ajouter le dept
if [ ! "$(grep '^deb http://liveusb.info/multisystem' /etc/apt/sources.list 2>/dev/null)" ]; then
vardeb="## Dept MultiSystem\ndeb http://liveusb.info/multisystem/depot all main"
echo -e "$vardeb" | tee -a "/etc/apt/sources.list"
fi
#Ajouter cl publique pour apt
sudo -u "$SUDO_USER" wget -q http://liveusb.info/multisystem/depot/multisystem.asc -O- | aptkey add #Recharger les sources
apt-get update
#Installer le paquet multisystem
apt-get install -y --force-yes multisystem
apt-get -f install -y
#Verifier que est bien install
if [ ! "$(dpkg -l | grep 'ii multisystem')" ]; then
msg1="Une erreur est survenue"
msg2="An error occurred"
if [ "$(echo $LANG | grep -i "fr_FR.utf")" ]; then
zenity --error --text "<b>${msg1}</b>"

else
zenity --error --text "<b>${msg2}</b>"
fi
exit 0
fi
#Rendre executable fusermount pour bases Debian !
chmod +x "/usr/bin/fusermount" 2>/dev/null
chmod +x "/bin/fusermount" 2>/dev/null
#Modifs pour lmde!
if [ "$(stat -c "%a" $(which fusermount))" = "4754" ]; then
chmod 755 $(which fusermount)
fi
if [ "$(stat -c "%a" /media)" -lt "755" ]; then
chmod 755 /media
fi
if [ "$(stat -c "%G" "$HOME/.local")" = "root" ]; then
sudo chown $SUDO_USER:$SUDO_USER -R "$HOME"/.local
fi
#message
msg1="Dornavant pour lancer le script veuillez utiliser\nle Menu:
/Applications/Accessoires/MultiSystem."
msg2="Now to start the script please use\nthe menu: / Applications/Accessoires/MultiSystem."
if [ "$(echo $LANG | grep -i "fr_FR.utf")" ]; then
zenity --info --text "<b>${msg1}</b>"
else
zenity --info --text "<b>${msg2}</b>"
fi
#lancer gui
nohup sudo -u "$SUDO_USER" -i "/usr/local/share/multisystem/gui_multisystem.sh"&
sleep 1
exit 0
frecuencia palabras en texto
#!/usr/bin/python
# -*- coding: UTF-8 -*import easygui
from Tkinter import Tk
from tkFileDialog import askopenfilename
Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
#frecuencia palabras
words= askopenfilename(title = "selecciona archivo a tratar") # show an "Open" dialog
palabras = []
frecuencias = []

'''
for i in range(6):
nuevo.append (0)
print nuevo
'''
f = open(words)
for word in f.read().split():
if word in palabras:
ind=palabras.index(word)
frecuencias[ind]=frecuencias[ind]+1
else:
palabras.append(word)
frecuencias.append(1)
print palabras
print frecuencias
mixto=zip(frecuencias, palabras)
mixto.sort()
print mixto
genera aleatorios y su frecuencia
#!/usr/bin/python
#genera digitos aleatorios y cuenta cuantos hay de cada
import random
n=int(raw_input('introduce numero mayor->'))
t=int(raw_input('introduce numero tiradas->'))
A=[] #matriz dde digitos 0 a 9
for iu in range(n+1):
A.append(0)
for i in range(t): #numero tiradas
a=int( random.randrange(n+1))
for index, item in enumerate(A, start=0): #si coincide digito con indice matriz
if index==a:
A[index]+=1
else:
continue

for iuk in range (n+1):#impime matriz total tiradas

print iuk,"->",A[iuk], '%->', A[iuk]*100.0/t


au=0
for eac in A:
au=au+eac
print 'total->', au, 'media->', t*1.0/(n+1)

Das könnte Ihnen auch gefallen