1
0
mirror of https://github.com/balkian/dotfiles.git synced 2025-08-23 08:02:19 +00:00

New config

This commit is contained in:
J. Fernando Sánchez
2015-09-18 02:14:17 +02:00
parent 8e833119db
commit fc8c11d360
117 changed files with 1533 additions and 1083 deletions

2
scripts/.bin/README Normal file
View File

@@ -0,0 +1,2 @@
Here I will be posting my personal scripts (either written by me or found on the internet).
Feel free to use them and email me if you have any comment or question.

View File

@@ -0,0 +1,20 @@
#!/bin/bash
# @balkian
# Changes the behaviour of the window cycling in xfce4
#
# Extracted from: http://askubuntu.com/questions/136052/cycle-windows-over-all-workspaces-in-xfce-while-being-able-to-cycle-over-one-wo
#
OLD_VALUE=$(xfconf-query -c xfwm4 -p /general/cycle_workspaces)
if [ $OLD_VALUE == "true" ]; then
echo 'will now disable workspace cycling'
NEW_VALUE="false"
fi
if [ $OLD_VALUE == "false" ]; then
echo 'will now turn on workspace cycling'
NEW_VALUE="true"
fi
xfconf-query -c xfwm4 -p /general/cycle_workspaces -s $NEW_VALUE

12
scripts/.bin/changedisplay.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/bash
# Author: Andrew Martin
# Credit: http://ubuntuforums.org/showthread.php?t=1309247
echo "Enter the primary display from the following:" # prompt for the display
xrandr --prop | grep "[^dis]connected" | cut --delimiter=" " -f1 # query connected monitors
read choice # read the users's choice of monitor
xrandr --output $choice --primary # set the primary monitor

13
scripts/.bin/cpcuevana.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/bash
# Script to copy Cuevana files to your home directory.
# Tested only with one cuevana instance at a time.
# @author: balkian
destfile="$HOME/VideoCuevana$$"
info=($(lsof -c /npview/i | grep -i /tmp/flash | awk '{print $2; print $9}'))
dir="/proc/${info[0]}/fd"
file=${info[1]}
#echo "pid" $pid
#echo "file" $file
fdn=$(ls -l $dir | grep $file | awk '{print $8}')
cp $dir/$fdn $destfile && echo "Video copied successfully to $destfile." && echo "Enjoy"

27
scripts/.bin/dmenu.sh Executable file
View File

@@ -0,0 +1,27 @@
#!/bin/sh
#http://unix.stackexchange.com/questions/50539/inconsistent-behaviour-of-wmctrl-i-a-win
# source dmenu config file if it exists
if [ -f $HOME/.dmenurc ]; then
. $HOME/.dmenurc
else
DMENU='dmenu -i'
fi
# get list of all windows, and their count
wmctrl_output=$(wmctrl -lx)
win_count=$(echo "$wmctrl_output" | wc -l)
# get rid of the hostname and the number in the 2nd column
hostname=$(uname -n)
win_list=$(echo "$wmctrl_output" | \
sed -r -e 's/[^@]'$hostname'//' | \
sed -r -e 's/ [0-9][0-9]? / /')
# select a window ($target) and extract its id ($target_id)
target=$(echo "$win_list" | $DMENU -l $win_count -p "Switch to: ")
target_id=$(echo "$target" | cut -d' ' -f1)
# switch to target window
cmd="wmctrl -i -a \"$target_id\""
eval "$cmd"

View File

@@ -0,0 +1 @@
xrandr --auto --output eDP1 --primary --right-of DP1

5
scripts/.bin/elecciones.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/bash
cd /tmp
wget http://www3.upm.es/elecciones/resultados/#1 -O resultados

41
scripts/.bin/flasher.sh Executable file
View File

@@ -0,0 +1,41 @@
#!/bin/bash
# Script to copy/link Cuevana files to your home directory or play them with your default video player.
# Tested only with one cuevana instance at a time.
# The video can be played, but it's deleted when the flash player is closed (unless you copied it).
# @author: balkian
if [ -z "$1" ]; then
PLAYER=parole;
else
PLAYER=$1;
fi
destfile="$HOME/VideoCuevana$$"
# PID1=$(pgrep -f flash)
# info=($(lsof -p $PID1 | grep -i /tmp/flash | awk '{print $2; print $9}'))
# dir="/proc/${info[0]}/fd"
# file=${info[1]}
# #echo "pid" $pid
# #echo "file" $file
# fdn=$(ls -l $dir | grep $file | awk '{print $9}')
files=$(sudo lsof 2>/dev/null | grep "Pepper Data" | awk '{gsub(/[a-z]/,"",$4);print "/proc/"$2"/fd/"$4}' | uniq -u)
echo "Files:" $files
for file in $files; do
sel=$(zenity --list --radiolist --text "Select action for: $file" --column "pick" --column "Option" TRUE "play" FALSE "copy" FALSE "link")
case $sel in
play)
sudo $PLAYER $file
;;
link)
sudo ln -s $file $destfile && echo "Video linked successfully to $destfile." && echo "Enjoy"
sudo chown $USER:$USER $destfile
;;
copy)
sudo cp $file $destfile && echo "Video copied successfully to $destfile." && echo "Enjoy"
sudo chown $USER:$USER $destfile
;;
esac
done;

2
scripts/.bin/gnome-terminal Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
one-window 'gnome-terminal' 'xdotool windowfocus $WID & xdotool key ctrl+shift+t'

70
scripts/.bin/goear.sh Executable file
View File

@@ -0,0 +1,70 @@
#bin/bash
resultado=/tmp/resultado
canciones=/tmp/canciones
enlaces=/tmp/enlaces
titulos=/tmp/titulos
#Pedimos al usuario el titulo de la canción.
echo "Introduce el título de la canción o del artista:"
read TITULO
if [ ! -d "goear" ]
then
mkdir goear
fi
#Descargamos el PHP correspondiente al título.
wget http://goear.com/search.php?q="$TITULO" -O $resultado
#La línea 130 contiene todos los enlaces a goear... de risa pero bueno.
head -130 $resultado | tail -1 > $canciones
#Mediante ER, obtenemos una lista de canciones y una lista de enlaces.
egrep -o 'listen/......./[^"]*' $canciones > $enlaces
egrep -o '"Escuchar[^"]*' $canciones > $titulos
#Mostramos al usuario los que ha encontrado en la primera página.
Linea=1
cat $titulos | while read line;
do {
echo $Linea: ${line:9}
let 'Linea += 1'
}
done
#Si no encuentra nada, sale.
CONDICION=`wc -l $titulos | awk '{print $1}'`
if [ $CONDICION == 0 ]; then
echo "No hay resultados. Prueba buscando otra cosa."
rm $resultado $canciones $enlaces $titulos
exit
fi
#Leemos qué canción quiere el usuario bajarse.
echo "¿Cuál te quieres bajar? Indica el número:"
read NUMERO
#Concatenamos http://www.goear.com con el contenido de aBajar.txt.
#PD: Alguien sabe hacerlo de manera más sencilla?
GOEAR=http://www.goear.com/
aBajar=`head -$NUMERO $enlaces | tail -1`
for LISTEN in $aBajar
do
ENLACE=${GOEAR}${LISTEN}
done
echo $ENLACE
#A partir de aquí el script no es mío, pero es muy sencillo de leer.
fileid=`echo $ENLACE | cut -d '/' -f 5`
xmlurl="http://www.goear.com/tracker758.php?f="$fileid
infoline=`wget -qO- $xmlurl | grep ".mp3"`
mp3url=`echo $infoline | cut -d '"' -f6`
artist=`echo $infoline | cut -d '"' -f10`
title=`echo $infoline | cut -d '"' -f12`
filename=goear/"$artist-$title.mp3"
wget $mp3url -O "$filename"
rm $resultado $canciones $enlaces $titulos
echo "¿Quieres reproducirla?[Y/n]"
read RES
if [ -z "$RES" -o "$RES" = "Y" -o "$RES" = "y" ];then
mplayer "$filename";
fi;

34
scripts/.bin/i3-exit.sh Executable file
View File

@@ -0,0 +1,34 @@
#!/bin/bash
case "$1" in
lock)
xautolock -locknow
;;
logout)
while [ "$select" != "NO" -a "$select" != "YES" ]; do
select=$(echo -e 'NO\nYES' | dmenu -fn "-*-cure-medium-*-*-*-11-*-*-*-*-*-*-*" -nb "#101010" -nf "#5f5f5f" -sb "#191919" -sf "#c72f62" -i -p "Do you really want to exit?");
[ -z "$select" ] && exit 0
done
[ "$select" = "NO" ] && exit 0
i3-msg exit
;;
suspend)
xautolock -locknow
dbus-send --system --print-reply --dest="org.freedesktop.login1" /org/freedesktop/login1 org.freedesktop.login1.Manager.Suspend boolean:true # XFCE4-power settings
;;
hibernate)
xautolock -locknow
dbus-send --system --print-reply --dest="org.freedesktop.login1" /org/freedesktop/login1 org.freedesktop.login1.Manager.Hibernate boolean:true # XFCE4-power settings
;;
reboot)
dbus-send --system --print-reply --dest="org.freedesktop.login1" /org/freedesktop/login1 org.freedesktop.login1.Manager.Reboot boolean:true # XFCE4-power settings
;;
shutdown)
dbus-send --system --print-reply --dest="org.freedesktop.login1" /org/freedesktop/login1 org.freedesktop.login1.Manager.PowerOff boolean:true # XFCE4-power settings
;;
*)
echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}"
exit 2
esac
exit 0

5
scripts/.bin/i3-one-instance Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/sh
python2 $HOME/.bin/i3-wm-scripts/nextmatch.py $*
if [ $? -gt 0 ]; then
$* & sleep 0.1 && python2 $HOME/.bin/i3-wm-scripts/nextmatch.py $*
fi

11
scripts/.bin/i3-one-tmux Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/zsh
python2 $HOME/.bin/i3-wm-scripts/nextmatch.py tmux
if [ $? -gt 0 ]; then
urxvt -e tmux attach & sleep 0.1 && python2 $HOME/.bin/i3-wm-scripts/nextmatch.py tmux
fi
if [ "$#" -gt 0 ]; then
eval "tmux neww"
sleep 0.2
xdotool type "$*"
xdotool key Return
fi

View File

@@ -0,0 +1,10 @@
#!/bin/sh
i3-msg 'workspace "1: Term" output eDP1'
i3-msg 'workspace "2: Web" output eDP1'
i3-msg 'workspace "3: Edit" output eDP1'
i3-msg 'workspace "4: Viewer" output DP1'
i3-msg 'workspace "5: Files" output DP1'
i3-msg 'workspace "6: Music" output DP1'
i3-msg 'workspace "7: Chat" output DP1'
i3-msg 'workspace "8: Misc Big" output eDP1'
i3-msg 'workspace "9: Misc Small" output DP1'

61
scripts/.bin/i3-winmenu.py Executable file
View File

@@ -0,0 +1,61 @@
#!/usr/bin/env python
# dmenu script to jump to windows in i3.
#
# using ziberna's i3-py library: https://github.com/ziberna/i3-py
# depends: dmenu (vertical patch), i3.
# released by joepd under WTFPLv2-license:
# http://sam.zoy.org/wtfpl/COPYING
#
# edited by Jure Ziberna for i3-py's examples section
import i3
import subprocess
def i3clients():
"""
Returns a dictionary of key-value pairs of a window text and window id.
Each window text is of format "[workspace] window title (instance number)"
"""
clients = {}
for ws_num in range(1, 11):
workspace = i3.filter(num=ws_num)
if not workspace:
continue
workspace = workspace[0]
windows = i3.filter(workspace, nodes=[])
instances = {}
# Adds windows and their ids to the clients dictionary
for window in windows:
win_str = '[%s] %s' % (workspace['name'], window['name'])
# Appends an instance number if other instances are present
if win_str in instances:
instances[win_str] += 1
win_str = '%s (%d)' % (win_str, instances[win_str])
else:
instances[win_str] = 1
clients[win_str] = window['id']
return clients
def win_menu(clients, l=10):
"""
Displays a window menu using dmenu. Returns window id.
"""
dmenu = subprocess.Popen(['/usr/bin/dmenu', '-i', '-l', str(l),
'-fn', '"-*-cure-medium-*-*-*-11-*-*-*-*-*-*-*"',
'-nb', '#101010', '-nf', '#5f5f5f', '-sb', '#191919',
'-sf', '#b72f62'],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
menu_str = '\n'.join(sorted(clients.keys()))
# Popen.communicate returns a tuple stdout, stderr
win_str = dmenu.communicate(menu_str.encode('utf-8'))[0].decode('utf-8')\
.rstrip()
return clients.get(win_str, None)
if __name__ == '__main__':
clients = i3clients()
win_id = win_menu(clients)
if win_id:
i3.focus(con_id=win_id)

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

23
scripts/.bin/monitors Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/sh
case $1 in
"single")
#xrandr --auto --output eDP1 --primary --output DP1 --off
~/.screenlayout/gsi-single.sh
xrandr --output HDMI1 --off --output DVI-1 --off --output DP1 --off --output eDP1 --mode 1920x1080 --pos 0x0 --rotate normal --output VGA1 --off
;;
"dual")
case $2 in
"home")
xrandr --output DP1 --off --output VIRTUAL1 --off --output eDP1 --mode 1920x1080 --pos 0x1080 --rotate normal --output HDMI1 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output VGA1 --off
;;
*)
#xrandr --auto --output eDP1 --primary --right-of DP1
xrandr --output VIRTUAL1 --off --output DP1 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output HDMI1 --off --output eDP1 --mode 1920x1080 --pos 1920x0 --rotate normal --output VGA1 --off
xrandr --output "DVI-1-0" --off
;;
esac
;;
esac
if [ `command -v nitrogen` ]; then
nitrogen --restore
fi

2
scripts/.bin/myemacs Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/sh
emacsclient --alternate-editor="" -s "$HOME/.emacs.d/HIGHLANDER" $@

27
scripts/.bin/one-instance Executable file
View File

@@ -0,0 +1,27 @@
#!/bin/bash
if [ "x$1" != "x" ]
then
pgrep -l -u "$USER" -f "$1" | egrep -v "/bin/bash|/bin/sh" | grep -vq "$$"
if [ $? == "0" ]
then
WID=`xdotool search --class $1 | head -1`
CWID=`xdotool getactivewindow`
if [ "x$WID" != "x$CWID" ];
then
xdotool windowactivate $WID
#wmctrl -i -R $WID
else
xdotool windowminimize $WID
fi
else
if [ "x$3" == "x" ]
then
/usr/bin/$1
else
eval "$3"
fi
fi
else
echo "Usage: one-instance program-name [extra action]"
fi

View File

@@ -0,0 +1,27 @@
#!/bin/bash
if [ "x$1" != "x" ]
then
pgrep -fx $1 1> /dev/null
if [ $? == "0" ]
then
echo "running"
ps aux | grep terminator > /home/balkian/LOG
WID=`xdotool search --class $1 | head -1`
wmctrl -i -a $WID
if [ "x$2" != "x" ]
then
eval "$2"
fi
else
if [ "x$3" == "x" ]
then
echo "not running"
/usr/bin/$1
else
eval "$3"
fi
fi
else
echo "Usage: one-instance program-name [extra action]"
fi

10
scripts/.bin/one-terminator.sh Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/bash
pgrep -u "$USER" gnome-terminal | grep -qv "$$"
if [ "$?" == "0" ]; then
WID=`xdotool search --class "terminator" | head -1`
xdotool windowfocus $WID
xdotool key ctrl+shift+t
#wmctrl -i -a $WID
else
/usr/bin/gnome-terminal
fi

27
scripts/.bin/one-tmux Executable file
View File

@@ -0,0 +1,27 @@
#!/bin/bash
TERMINAL_EMULATOR='urxvt'
tab=1
pgrep -l -u "$USER" -f "$TERMINAL_EMULATOR" | egrep -v "/bin/zsh|/bin/bash|/bin/sh" | grep -vq "$$"
if [ $? != "0" ]
then
/usr/bin/$TERMINAL_EMULATOR &
sleep 1
tab=0
fi
WID=`xdotool search --class $TERMINAL_EMULATOR | tail -1`
wmctrl -i -a $WID
if [ "x$1" != "x" ]
then
if [ "x$1" == "xhelp" ]
then
echo "Usage: $0 [command-in-new-window]"
else
if [ $tab == 1 ]
then
eval "tmux neww"
sleep 0.2
fi
xdotool type "$*"
xdotool key Return
fi
fi

11
scripts/.bin/passmenu Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
shopt -s nullglob globstar
password_files=( ~/.password-store/**/*.gpg )
password_files=( "${password_files[@]##*/.password-store/}" )
password_files=( "${password_files[@]%.gpg}" )
password=$(printf '%s\n' "${password_files[@]}" | dmenu "$@")
pass show -c "$password"

2
scripts/.bin/play-europa.sh Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
rtmpdump --live --quiet --buffer 3000 -r rtmp://antena3fms35geobloqueolivefs.fplive.net/antena3fms35geobloqueolive-live/ --playpath stream-europafm | mplayer -vo null -idle -

2
scripts/.bin/play-hitfm.sh Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
mplayer -vo null -idle http://ice.5.c3.audiovideoweb.com:8000/4c3ice5500

2
scripts/.bin/play-kiss.sh Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
rtmpdump --live --quiet --buffer 3000 -r rtmp://kissfm.es.flash3.glb.ipercast.net/kissfm.es-live --playpath aac.stream | mplayer -vo null -idle -

2
scripts/.bin/play-m80.sh Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
curl -s http://4633.live.streamtheworld.com/M80RADIOAAC | mplayer -vo null -idle -

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<playlist xmlns="http://xspf.org/ns/0/" xmlns:vlc="http://www.videolan.org/vlc/playlist/ns/0/" version="1">
<title>Playlist</title>
<trackList>
<track>
<location>rtmp://antena3fms35geobloqueolivefs.fplive.net/antena3fms35geobloqueolive-live/stream-europafm</location>
<title>EuropaFM</title>
<extension application="http://www.videolan.org/vlc/playlist/0">
<vlc:id>0</vlc:id>
<vlc:option>network-caching=1000</vlc:option>
</extension>
</track>
<track>
<location>http://4633.live.streamtheworld.com:80/M80RADIO_SC</location>
<title>M80 Radio</title>
<duration>125287770</duration>
<extension application="http://www.videolan.org/vlc/playlist/0">
<vlc:id>1</vlc:id>
<vlc:option>network-caching=1000</vlc:option>
</extension>
</track>
<track>
<location>rtmp://kissfm.es.flash3.glb.ipercast.net/kissfm.es-live/aac.stream</location>
<title>KISSFM</title>
<extension application="http://www.videolan.org/vlc/playlist/0">
<vlc:id>2</vlc:id>
<vlc:option>network-caching=1000</vlc:option>
</extension>
</track>
</trackList>
<extension application="http://www.videolan.org/vlc/playlist/0">
<vlc:item tid="0"/>
<vlc:item tid="1"/>
<vlc:item tid="2"/>
</extension>
</playlist>

View File

@@ -0,0 +1,10 @@
#!/bin/sh
# Note: input should end with a newline
LINES=''
while read LINE; do
echo $LINE | sed 's/á/a/g' | sed 's/Á/A/g' | sed 's/é/e/g' | sed 's/É/E/g' | sed 's/í/i/g' | sed 's/Í/I/g' | sed 's/ó/o/g' | sed 's/Ó/O/g' | sed 's/ú/u/g' | sed 's/Ú/U/g' | sed 's/ñ/n/g' | sed 's/Ñ/N/g' | sed 's/ü/u/g' | sed 's/Ü/U/g'
done
exit 0

View File

@@ -0,0 +1 @@
xrandr --auto --output eDP1 --primary --output DP1 --off

View File

@@ -0,0 +1,417 @@
#!/usr/bin/python
# Spotify-notify
#
# v0.6d (28th aug 11)
# by JonW (jon.neverwinter@gmail.com)
# patched 20110907 by Jansen Price (sumpygump@gmail.com)
# patched 20120729 by Jansen Price (sumpygump@gmail.com) and brandl.matthaeus
#
# Original by SveinT (sveint@gmail.com)
# up to v0.5.2 (27th jan 11)
import dbus
import gobject, gtk, os, tempfile, sys, time, re, indicate, urllib2
from optparse import OptionParser
from subprocess import *
# The url to use when fetching spotify track information.
SPOTIFY_OPEN_URL = "http://open.spotify.com/track/"
# The path to this application's directory.
APPLICATION_DIR = sys.path[0] + "/"
# The file path to spotify. If empty, it will try to auto detect.
SPOTIFY_PROCESS_NAME = 'spotify'
# How often to check if spotify has been closed (in milliseconds).
SPOTIFY_CLOSED_CHECK = 20000
class SpotifyNotify():
spotifyPath = ''
tryToReconnect = False
tmpfile = False
def __init__(self, debugger):
self.debug = debugger
self.spotifyservice = False
self.prev = 0
self.new = False
self.prevMeta = {}
self.notifyid = 0
self.connect()
def __del__(self):
if SpotifyNotify and SpotifyNotify.tmpfile:
SpotifyNotify.tmpfile.close()
def connect(self):
self.debug.out("Connecting to spotify.")
self.bus = dbus.Bus(dbus.Bus.TYPE_SESSION)
try:
self.spotifyservice = self.bus.get_object(
'com.spotify.qt',
'/org/mpris/MediaPlayer2'
)
SpotifyNotify.tryToReconnect = False
except Exception, e:
self.spotifyservice = False
self.debug.out("Failed to connect.")
self.debug.out(e)
def executeCommand(self, key):
if not key:
return
self.connect()
self.debug.out("Running command: {0}".format(key))
self.cmd = self.spotifyservice.get_dbus_method(key, 'org.mpris.MediaPlayer2.Player')
self.cmd()
def pollChange(self):
try:
self.spotifyservice = self.bus.get_object('com.spotify.qt', '/')
self.cmd = self.spotifyservice.get_dbus_method(
'GetMetadata',
'org.freedesktop.MediaPlayer2'
)
self.new = self.cmd()
except Exception, e:
self.debug.out('Spotify service not connected.')
SpotifyNotify.tryToReconnect = True
if (self.prev != self.new):
self.trackChange(self.new)
self.prev = self.new
return 1
def trackChange(self, *trackChange):
if not trackChange[0]:
return
self.prev = trackChange[0]
trackInfo = {}
trackMap = {
'artist' : 'xesam:artist',
'album' : 'xesam:album',
'title' : 'xesam:title',
'year' : 'xesam:contentCreated',
'trackhash' : 'mpris:trackid',
'arturl' : 'mpris:artUrl'
}
# Fetch the track information for the notification window.
for key in trackMap:
if not trackMap[key] in trackChange[0]:
continue
piece = trackChange[0][trackMap[key]]
if key == 'year':
piece = str(piece[:4])
elif isinstance(piece, list):
piece = ", ".join(piece)
if not isinstance(piece, str):
piece = str(piece)
trackInfo[key] = piece.encode('utf-8')
if not self.prevMeta\
or not SpotifyNotify.tmpfile\
or 'iconfilename' not in self.prevMeta\
or self.prevMeta['artist'] != trackInfo['artist']\
or self.prevMeta['album'] != trackInfo['album']:
trackInfo['iconfilename'] = self.retrieveCoverImage(trackInfo)
cover_image = ''
if 'iconfilename' in trackInfo:
cover_image = trackInfo['iconfilename']
elif 'iconfilename' in self.prevMeta:
cover_image = self.prevMeta['iconfilename']
trackInfo['iconfilename'] = cover_image
if cover_image == '':
cover_image = APPLICATION_DIR + 'icon_spotify.png'
self.prevMeta = trackInfo
# Connect to notification interface on DBUS.
self.notifyservice = self.bus.get_object(
'org.freedesktop.Notifications',
'/org/freedesktop/Notifications'
)
self.notifyservice = dbus.Interface(
self.notifyservice,
"org.freedesktop.Notifications"
)
notifyText = "{0}\n{1}".format(
trackInfo['title'],
trackInfo['album']
)
if len(trackInfo['year']) > 0:
notifyText += " ({0})".format(trackInfo['year'])
# Send track change information to stdout
print "Changing track : {0} | {1} | {2} ({3})".format(
trackInfo['artist'],
trackInfo['title'],
trackInfo['album'],
trackInfo['year']
)
# The second param is the replace id, so get the notify id back,
# store it, and send it as the replacement on the next call.
self.notifyid = self.notifyservice.Notify(
"Spotify-notify",
self.notifyid,
cover_image,
trackInfo['artist'],
notifyText,
[],
{},
2000
)
def retrieveCoverImage(self, trackInfo):
if 'arturl' in trackInfo:
self.debug.out("Simply retrieving image from {0}".format(trackInfo['arturl']))
iconfilename = self.fetchCoverImage(trackInfo['arturl'])
else:
#if (trackInfo['trackhash'][0:14] == 'spotify:local:'):
# self.debug.out("Track is a local file. No art available.")
# return ''
self.debug.out("Attempting to fetch image from spotify")
iconfilename = self.fetchCoverImageSpotify(
trackInfo['artist'],
trackInfo['album'],
trackInfo['trackhash']
)
return iconfilename
def fetchCoverImageSpotify(self, artist, album, trackhash):
try:
trackid = trackhash.split(":")[2]
url = SPOTIFY_OPEN_URL + trackid
tracksite = urllib2.urlopen(url).read()
# Attempt to get the image url from the open graph image meta tag.
imageurl = False
metaMatch = re.search(
'<meta\s[^\>]*property\s*=\s*["\']og:image["\'][^\>]*/?>',
tracksite
)
if metaMatch:
contentMatch = re.search(
'content\s*=\s*["\']([^\"\']*)["\']',
metaMatch.group(0)
)
if contentMatch:
imageurl = contentMatch.group(1)
if not imageurl:
self.debug.out("No cover available.")
raise()
return self.fetchCoverImage(imageurl)
except Exception, e:
self.debug.out("Couldn't fetch cover image.")
self.debug.out(e)
return ''
def fetchCoverImage(self, url):
# Close the temporary image file, we are going to make a new one.
if SpotifyNotify.tmpfile:
SpotifyNotify.tmpfile.close()
SpotifyNotify.tmpfile = False
try:
SpotifyNotify.tmpfile = tempfile.NamedTemporaryFile()
tmpfilename = SpotifyNotify.tmpfile.name
self.debug.out("Album art tmp filepath: {0}".format(tmpfilename))
coverfile = urllib2.urlopen(url)
SpotifyNotify.tmpfile.write(coverfile.read())
SpotifyNotify.tmpfile.flush()
return tmpfilename
except Exception, e:
self.debug.out("Couldn't fetch cover image.")
self.debug.out(e)
return ''
@staticmethod
def startSpotify(Debug):
if not SpotifyNotify.spotifyPath:
Debug.out("No spotify process identifier found.")
return
ident = SpotifyNotify.spotifyPath
Debug.out("Looking for spotify as: {0}".format(ident))
procs = SpotifyNotify.checkForProcess(
'ps x | grep "{0}" | grep -v grep'.format(ident),
Debug
)
if len(procs):
Debug.out("Spotify process found as: {0}".format(" ".join(procs[0])))
return
Debug.out("Starting new Spotify now.")
FNULL = open('/dev/null', 'w')
spid = Popen([ident], stdout=FNULL, stderr=FNULL).pid
if spid:
Debug.out("Spotify started, pid: {0}.".format(spid))
else:
Debug.out("Spotify could not be started.")
@staticmethod
def checkForClosedSpotify(SN, Debug):
if not SpotifyNotify.spotifyPath:
Debug.out("No spotify process identifier found.")
return False
ident = SpotifyNotify.spotifyPath
Debug.out("Looking for spotify as: {0}".format(ident))
procs = SpotifyNotify.checkForProcess(
'ps x | grep "{0}" | grep -v grep'.format(ident),
Debug
)
if len(procs):
Debug.out("Spotify process found as: {0}".format(" ".join(procs[0])))
if (SpotifyNotify.tryToReconnect):
SN.connect()
return True
if SpotifyNotify.tmpfile:
SpotifyNotify.tmpfile.close()
Debug.out("Spotify has been closed, therefore I die.")
exit(0)
@staticmethod
def preventDuplicate(Debug):
mypid = os.getpid()
Debug.out("My pid: {0}".format(mypid))
proc = SpotifyNotify.checkForProcess('ps -p {0}'.format(mypid), Debug)
if not proc[0][3]:
return
process = proc[0][3]
search = 'ps -C {0}'.format(process)
Debug.out("Looking for other processes named: {0}".format(process).strip())
if process == 'python':
if not sys.argv[0]:
Debug.out("Process started using python, cannot determine script name.")
return
search = 'ps ax | grep "python {0}" | grep -v grep'.format(sys.argv[0])
for line in SpotifyNotify.checkForProcess(search, Debug):
if int(line[0]) != mypid:
print("This program was already running.")
Debug.out("I am a duplicate. I shall end myself. ({0})".format(" ".join(line)))
exit(0)
@staticmethod
def checkForProcess(proc, Debug):
output = []
for line in Popen(proc, shell=True, stdout=PIPE).stdout:
fields = line.split()
if not fields[0].isdigit():
continue
output.append(fields)
return output
class DebugMe():
def __init__(self, toggle):
if toggle:
self.output = True
else:
self.output = False
def out(self, msg):
if not self.output:
return
print(">> {0}".format(msg))
if __name__ == "__main__":
parser = OptionParser()
parser.add_option(
'-a',
'--action',
dest = 'action',
default = None,
type = 'choice',
choices = ['playPause', 'play', 'pause', 'next', 'previous'],
help = 'Music player actions (playPause/play/pause/next/previous).'
)
parser.add_option(
'-n',
'--skip_notify',
dest = 'skipNotify',
action = 'store_true',
default = False,
help = 'Song change notifications will be turned off.'
)
parser.add_option(
'-d',
'--debug',
dest = 'debug',
action = 'store_true',
default = False,
help = 'Debug messages will be displayed.'
)
(options, args) = parser.parse_args()
Debug = DebugMe(options.debug)
print("Spotify-notify v0.6")
if SPOTIFY_PROCESS_NAME:
SpotifyNotify.spotifyPath = SPOTIFY_PROCESS_NAME
else:
print "Spotify is not running"
sys.exit(0)
SN = SpotifyNotify(Debug)
if options.action:
action = options.action
action = action[0:1].upper() + action[1:]
SN.executeCommand(action)
SpotifyNotify.preventDuplicate(Debug)
try:
indicateserver = indicate.indicate_server_ref_default()
indicateserver.set_type("music.spotify")
indicateserver.set_desktop_file("/usr/share/applications/spotify.desktop")
indicateserver.show()
except:
pass
SN.pollChange()
print "Done"

421
scripts/.bin/spotify-remote.py Executable file
View File

@@ -0,0 +1,421 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
'''
Spoify-remote
Modified version of Spotify-notify that runs once when invoked instead of looping.
v0.6d (28th aug 11)
by JonW (jon.neverwinter@gmail.com)
patched 20110907 by Jansen Price (sumpygump@gmail.com)
patched 20120729 by Jansen Price (sumpygump@gmail.com) and brandl.matthaeus
modified 20130405 by Fernando Sánchez (balkian@gmail.com)
Original by SveinT (sveint@gmail.com)
up to v0.5.2 (27th jan 11)
'''
import dbus
import gobject, gtk, os, tempfile, sys, time, re, urllib2
from optparse import OptionParser
from subprocess import *
# The url to use when fetching spotify track information.
SPOTIFY_OPEN_URL = "http://open.spotify.com/track/"
# The path to this application's directory.
APPLICATION_DIR = sys.path[0] + "/"
# The file path to spotify. If empty, it will try to auto detect.
SPOTIFY_PROCESS_NAME = 'spotify'
# How often to check if spotify has been closed (in milliseconds).
SPOTIFY_CLOSED_CHECK = 20000
class SpotifyNotify():
spotifyPath = ''
tryToReconnect = False
tmpfile = False
def __init__(self, debugger):
self.debug = debugger
self.spotifyservice = False
self.prev = 0
self.new = False
self.prevMeta = {}
self.notifyid = 0
self.connect()
def __del__(self):
if SpotifyNotify and SpotifyNotify.tmpfile:
SpotifyNotify.tmpfile.close()
def connect(self):
self.debug.out("Connecting to spotify.")
self.bus = dbus.Bus(dbus.Bus.TYPE_SESSION)
try:
self.spotifyservice = self.bus.get_object(
'com.spotify.qt',
'/org/mpris/MediaPlayer2'
)
SpotifyNotify.tryToReconnect = False
except Exception, e:
self.spotifyservice = False
self.debug.out("Failed to connect.")
self.debug.out(e)
def executeCommand(self, key):
if not key:
return
self.connect()
self.debug.out("Running command: {0}".format(key))
self.cmd = self.spotifyservice.get_dbus_method(key, 'org.mpris.MediaPlayer2.Player')
self.cmd()
def pollChange(self):
try:
self.spotifyservice = self.bus.get_object('com.spotify.qt', '/')
self.cmd = self.spotifyservice.get_dbus_method(
'GetMetadata',
'org.freedesktop.MediaPlayer2'
)
self.new = self.cmd()
except Exception, e:
self.debug.out('Spotify service not connected.')
SpotifyNotify.tryToReconnect = True
if (self.prev != self.new):
self.trackChange(self.new)
self.prev = self.new
return 1
def trackChange(self, *trackChange):
if not trackChange[0]:
return
self.prev = trackChange[0]
trackInfo = {}
trackMap = {
'artist' : 'xesam:artist',
'album' : 'xesam:album',
'title' : 'xesam:title',
'year' : 'xesam:contentCreated',
'trackhash' : 'mpris:trackid',
'arturl' : 'mpris:artUrl'
}
# Fetch the track information for the notification window.
for key in trackMap:
if not trackMap[key] in trackChange[0]:
continue
piece = trackChange[0][trackMap[key]]
if key == 'year':
piece = str(piece[:4])
elif isinstance(piece, list):
piece = ", ".join(piece)
if not isinstance(piece, str):
piece = str(piece)
trackInfo[key] = piece.encode('utf-8')
if not self.prevMeta\
or not SpotifyNotify.tmpfile\
or 'iconfilename' not in self.prevMeta\
or self.prevMeta['artist'] != trackInfo['artist']\
or self.prevMeta['album'] != trackInfo['album']:
trackInfo['iconfilename'] = self.retrieveCoverImage(trackInfo)
cover_image = ''
if 'iconfilename' in trackInfo:
cover_image = trackInfo['iconfilename']
elif 'iconfilename' in self.prevMeta:
cover_image = self.prevMeta['iconfilename']
trackInfo['iconfilename'] = cover_image
if cover_image == '':
cover_image = APPLICATION_DIR + 'icon_spotify.png'
self.prevMeta = trackInfo
# Connect to notification interface on DBUS.
self.notifyservice = self.bus.get_object(
'org.freedesktop.Notifications',
'/org/freedesktop/Notifications'
)
self.notifyservice = dbus.Interface(
self.notifyservice,
"org.freedesktop.Notifications"
)
notifyText = "{0}\n{1}".format(
trackInfo['title'],
trackInfo['album']
)
if len(trackInfo['year']) > 0:
notifyText += " ({0})".format(trackInfo['year'])
# Send track change information to stdout
print "Changing track : {0} | {1} | {2} ({3})".format(
trackInfo['artist'],
trackInfo['title'],
trackInfo['album'],
trackInfo['year']
)
# The second param is the replace id, so get the notify id back,
# store it, and send it as the replacement on the next call.
#self.notifyid = self.notifyservice.Notify(
#"Spotify-notify",
#self.notifyid,
#cover_image,
#trackInfo['artist'],
#notifyText,
#[],
#{},
#2000
#)
def retrieveCoverImage(self, trackInfo):
if 'arturl' in trackInfo:
self.debug.out("Simply retrieving image from {0}".format(trackInfo['arturl']))
iconfilename = self.fetchCoverImage(trackInfo['arturl'])
else:
#if (trackInfo['trackhash'][0:14] == 'spotify:local:'):
# self.debug.out("Track is a local file. No art available.")
# return ''
self.debug.out("Attempting to fetch image from spotify")
iconfilename = self.fetchCoverImageSpotify(
trackInfo['artist'],
trackInfo['album'],
trackInfo['trackhash']
)
return iconfilename
def fetchCoverImageSpotify(self, artist, album, trackhash):
try:
trackid = trackhash.split(":")[2]
url = SPOTIFY_OPEN_URL + trackid
tracksite = urllib2.urlopen(url).read()
# Attempt to get the image url from the open graph image meta tag.
imageurl = False
metaMatch = re.search(
'<meta\s[^\>]*property\s*=\s*["\']og:image["\'][^\>]*/?>',
tracksite
)
if metaMatch:
contentMatch = re.search(
'content\s*=\s*["\']([^\"\']*)["\']',
metaMatch.group(0)
)
if contentMatch:
imageurl = contentMatch.group(1)
if not imageurl:
self.debug.out("No cover available.")
raise()
return self.fetchCoverImage(imageurl)
except Exception, e:
self.debug.out("Couldn't fetch cover image.")
self.debug.out(e)
return ''
def fetchCoverImage(self, url):
# Close the temporary image file, we are going to make a new one.
if SpotifyNotify.tmpfile:
SpotifyNotify.tmpfile.close()
SpotifyNotify.tmpfile = False
try:
SpotifyNotify.tmpfile = tempfile.NamedTemporaryFile()
tmpfilename = SpotifyNotify.tmpfile.name
self.debug.out("Album art tmp filepath: {0}".format(tmpfilename))
coverfile = urllib2.urlopen(url)
SpotifyNotify.tmpfile.write(coverfile.read())
SpotifyNotify.tmpfile.flush()
return tmpfilename
except Exception, e:
self.debug.out("Couldn't fetch cover image.")
self.debug.out(e)
return ''
@staticmethod
def startSpotify(Debug):
if not SpotifyNotify.spotifyPath:
Debug.out("No spotify process identifier found.")
return
ident = SpotifyNotify.spotifyPath
Debug.out("Looking for spotify as: {0}".format(ident))
procs = SpotifyNotify.checkForProcess(
'ps x | grep "{0}" | grep -v grep'.format(ident),
Debug
)
if len(procs):
Debug.out("Spotify process found as: {0}".format(" ".join(procs[0])))
return
Debug.out("Starting new Spotify now.")
FNULL = open('/dev/null', 'w')
spid = Popen([ident], stdout=FNULL, stderr=FNULL).pid
if spid:
Debug.out("Spotify started, pid: {0}.".format(spid))
else:
Debug.out("Spotify could not be started.")
@staticmethod
def checkForClosedSpotify(SN, Debug):
if not SpotifyNotify.spotifyPath:
Debug.out("No spotify process identifier found.")
return False
ident = SpotifyNotify.spotifyPath
Debug.out("Looking for spotify as: {0}".format(ident))
procs = SpotifyNotify.checkForProcess(
'ps x | grep "{0}" | grep -v grep'.format(ident),
Debug
)
if len(procs):
Debug.out("Spotify process found as: {0}".format(" ".join(procs[0])))
if (SpotifyNotify.tryToReconnect):
SN.connect()
return True
if SpotifyNotify.tmpfile:
SpotifyNotify.tmpfile.close()
Debug.out("Spotify has been closed, therefore I die.")
exit(0)
@staticmethod
def preventDuplicate(Debug):
mypid = os.getpid()
Debug.out("My pid: {0}".format(mypid))
proc = SpotifyNotify.checkForProcess('ps -p {0}'.format(mypid), Debug)
if not proc[0][3]:
return
process = proc[0][3]
search = 'ps -C {0}'.format(process)
Debug.out("Looking for other processes named: {0}".format(process).strip())
if process == 'python':
if not sys.argv[0]:
Debug.out("Process started using python, cannot determine script name.")
return
search = 'ps ax | grep "python {0}" | grep -v grep'.format(sys.argv[0])
for line in SpotifyNotify.checkForProcess(search, Debug):
if int(line[0]) != mypid:
print("This program was already running.")
Debug.out("I am a duplicate. I shall end myself. ({0})".format(" ".join(line)))
exit(0)
@staticmethod
def checkForProcess(proc, Debug):
output = []
for line in Popen(proc, shell=True, stdout=PIPE).stdout:
fields = line.split()
if not fields[0].isdigit():
continue
output.append(fields)
return output
class DebugMe():
def __init__(self, toggle):
if toggle:
self.output = True
else:
self.output = False
def out(self, msg):
if not self.output:
return
print(">> {0}".format(msg))
if __name__ == "__main__":
parser = OptionParser()
parser.add_option(
'-a',
'--action',
dest = 'action',
default = None,
type = 'choice',
choices = ['playPause', 'play', 'pause', 'next', 'previous'],
help = 'Music player actions (playPause/play/pause/next/previous).'
)
parser.add_option(
'-n',
'--skip_notify',
dest = 'skipNotify',
action = 'store_true',
default = False,
help = 'Song change notifications will be turned off.'
)
parser.add_option(
'-d',
'--debug',
dest = 'debug',
action = 'store_true',
default = False,
help = 'Debug messages will be displayed.'
)
(options, args) = parser.parse_args()
Debug = DebugMe(options.debug)
print("Spotify-notify v0.6")
if SPOTIFY_PROCESS_NAME:
SpotifyNotify.spotifyPath = SPOTIFY_PROCESS_NAME
else:
print "Spotify is not running"
sys.exit(0)
SN = SpotifyNotify(Debug)
if options.action:
action = options.action
action = action[0:1].upper() + action[1:]
SN.executeCommand(action)
SpotifyNotify.preventDuplicate(Debug)
try:
import indicate
indicateserver = indicate.indicate_server_ref_default()
indicateserver.set_type("music.spotify")
indicateserver.set_desktop_file("/usr/share/applications/spotify.desktop")
indicateserver.show()
except:
pass
SN.pollChange()
print "Done"

114
scripts/.bin/spotify-remote.sh Executable file
View File

@@ -0,0 +1,114 @@
#!/bin/bash
# Extracted from: http://ubuntuforums.org/showthread.php?t=1797848
# User: azzid
# Modified by Balkian
# Collect DBUS_SESSION_BUS_ADDRESS from running process
function set_dbus_adress
{
USER=$1
PROCESS=$2
PID=`pgrep -o -u $USER $PROCESS`
ENVIRON=/proc/$PID/environ
if [ -e $ENVIRON ]
then
export `grep -z DBUS_SESSION_BUS_ADDRESS $ENVIRON`
else
echo "Unable to set DBUS_SESSION_BUS_ADDRESS."
exit 1
fi
}
function spotify_cmd
{
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.$1 1> /dev/null
}
function spotify_query
{
qdbus org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player PlaybackStatus
}
function spotify_metadata
{
qdbus com.spotify.qt / org.freedesktop.MediaPlayer2.GetMetadata
}
function spotify_notify
{
metadata=`spotify_metadata`
echo "Metadata: $metadata"
title=`echo "$metadata" | grep title | cut -d' ' -f2-`
artist=`echo "$metadata" | grep artist | cut -d' ' -f2-`
image=`echo "$metadata" | grep artUrl | cut -d' ' -f3`
wget $image -O /tmp/image
echo "notifying $title"
notify-send "$artist" "$title" --icon=/tmp/image
}
function quit_message
{
echo "Usage: `basename $0` {play|pause|playpause|next|previous|stop|playstatus|<spotify URI>}"
exit 1
}
# Count arguments, must be 1
if [ "$#" -ne "1" ]
then
echo -e "You must supply exactly one argument!\n"
quit_message
fi
# Check if DBUS_SESSION is set
if [ -z $DBUS_SESSION_BUS_ADDRESS ]
then
#echo "DBUS_SESSION_BUS_ADDRESS not set. Guessing."
set_dbus_adress `whoami` spotify
fi
case "$1" in
play)
spotify_cmd Play
spotify_notify
;;
pause)
spotify_cmd Pause
spotify_notify
;;
playpause)
spotify_cmd PlayPause
spotify_notify
;;
next)
spotify_cmd Next
spotify_notify
;;
previous)
spotify_cmd Previous
spotify_notify
;;
stop)
spotify_cmd Stop
spotify_notify
;;
spotify:user:*)
spotify_cmd "OpenUri string:$1"
spotify_cmd Play
spotify_notify
;;
spotify:*:*)
spotify_cmd "OpenUri string:$1"
;;
playstatus)
spotify_query
;;
metadata)
spotify_metadata;
;;
*)
echo -e "Bad argument.\n"
quit_message
;;
esac
exit 0

View File

@@ -0,0 +1,17 @@
#!/bin/bash
cd $(dirname $(dirname $0))
eclipse/eclipse -vm jre1.6.0_20/bin/ || failed=1
if [ $failed -eq 1 ]; then
zenity --warning --title "Error executing eclipse's launcher" --text "Eclipse couldn't be found in $(pwd), please, modify $0 script to point to the right location" || exit
file=$(zenity --file-selection --title "Select the right executable");
vm=$(zenity --file-selection --title "Select virtual machine");
echo $file;
if [ -n "$file" ]; then
if [ -n "$vm" ]; then
virt=" -vm $vm";
fi
$file $virt
fi
fi

2
scripts/.bin/terminator Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
one-window "terminator" "xdotool windowfocus \$WID & xdotool key ctrl+shift+t;" "/usr/bin/terminator $*"

65
scripts/.bin/tmux-zoom.sh Executable file
View File

@@ -0,0 +1,65 @@
#!/bin/bash
# Copyright (c) 2012 Juan Ignacio Pumarino, jipumarino@gmail.com
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Instructions
# ------------
#
# 1. Install this script and give it execute permission somewhere in your PATH.
# For example:
#
# $ mkdir -p ~/bin
# $ wget https://raw.github.com/jipumarino/tmux-zoom/master/tmux-zoom.sh -O ~/bin/tmux-zoom.sh
# $ chmod +x ~/bin/tmux-zoom.sh
#
# 2. Add a shortcut in your ~/.tmux.conf file:
#
# bind C-k run "tmux-zoom.sh"
#
# 3. When using this shortcut, the current tmux pane will open in a new window by itself.
# Running it again in the zoomed window will return it to its original pane. You can have
# as many zoomed windows as you want.
current=$(tmux display-message -p '#W-#I-#P')
list=$(tmux list-window)
[[ "$current" =~ ^(.*)-([0-9]+)-([0-9]+) ]]
current_window=${BASH_REMATCH[1]}
current_pane=${BASH_REMATCH[2]}-${BASH_REMATCH[3]}
new_zoom_window=ZOOM-$current_pane
if [[ $current_window =~ ZOOM-([0-9]+)-([0-9+]) ]]; then
if [ "$(tmux list-panes | wc -l)" -gt 1 ]; then
tmux display-message "other panes exist"
exit 0
fi
old_zoom_window=ZOOM-${BASH_REMATCH[1]}-${BASH_REMATCH[2]}
tmux select-window -t ${BASH_REMATCH[1]} \; select-pane -t ${BASH_REMATCH[2]} \; swap-pane -s $old_zoom_window.0 \; kill-window -t $old_zoom_window
elif [[ $list =~ $new_zoom_window ]]; then
tmux select-window -t $new_zoom_window
else
if [ "$(tmux list-panes | wc -l)" -eq 1 ]; then
tmux display-message "already zoomed"
exit 0
fi
tmux new-window -d -n $new_zoom_window \; swap-pane -s $new_zoom_window.0 \; select-window -t $new_zoom_window
fi

View File

@@ -0,0 +1,63 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import telnetlib, time
# Poner esto a 0 para deshabilitar las opciones del menú
# o a 1 para habilitarlas
HABILITAR = 1;
tn = telnetlib.Telnet ( "192.168.1.1" );
tn.read_until("login: ");
tn.write("LBV2techno\n");
tn.read_until("Password: ");
tn.write("1901b95ae4295d613abf9eabae0b9d40\n");
for i in `range(1,3)`:
tn.write("\n");
tn.write("rg_conf_set wbm/settings/pages/backuprestore %i\n" % HABILITAR);
tn.read_until("Returned 0");
tn.write("rg_conf_set wbm/settings/pages/vpn %i\n" % HABILITAR);
tn.read_until("Returned 0");
tn.write("rg_conf_set wbm/settings/pages/fax %i\n" % HABILITAR);
tn.read_until("Returned 0");
tn.write("rg_conf_set wbm/settings/pages/log %i\n" % HABILITAR);
tn.read_until("Returned 0");
tn.write("rg_conf_set wbm/settings/pages/licence %i\n" % HABILITAR);
tn.read_until("Returned 0");
tn.write("rg_conf_set wbm/settings/pages/community %i\n" % HABILITAR);
tn.read_until("Returned 0");
tn.write("rg_conf_set wbm/settings/pages/visio %i\n" % HABILITAR);
tn.read_until("Returned 0");
tn.write("rg_conf_set wbm/settings/pages/livezoom %i\n" % HABILITAR);
tn.read_until("Returned 0");
tn.write("rg_conf_set wbm/settings/pages/hsiab %i\n" % HABILITAR);
tn.read_until("Returned 0");
tn.write("rg_conf_set wbm/settings/network/dhcp %i\n" % HABILITAR);
tn.read_until("Returned 0");
tn.write("rg_conf_set wbm/settings/network/ftlock %i\n" % HABILITAR);
tn.read_until("Returned 0");
tn.write("rg_conf_set wbm/settings/network/ftlock %i\n" % HABILITAR);
tn.read_until("Returned 0");
tn.write("rg_conf_set wbm/settings/network/tvrouted %i\n" % HABILITAR);
tn.read_until("Returned 0");
tn.write("rg_conf_set wbm/settings/services/professionnal %i\n" % HABILITAR);
tn.read_until("Returned 0");
tn.write("rg_conf_set wbm/settings/services/rtcphone %i\n" % HABILITAR);
tn.read_until("Returned 0");
tn.write("rg_conf_set wbm/settings/services/universal_phone %i\n" % HABILITAR);
tn.read_until("Returned 0");
tn.write("rg_conf_set wbm/settings/services/wifipushbutton %i\n" % HABILITAR);
tn.read_until("Returned 0");
tn.write("rg_conf_set wbm/settings/services/msgwaiting %i\n" % HABILITAR);
tn.read_until("Returned 0");
tn.write("rg_conf_set wbm/settings/test/sipdev %i\n" % HABILITAR);
tn.read_until("Returned 0");
tn.write("rg_conf_set wbm/settings/test/fmdev %i\n" % HABILITAR);
tn.read_until("Returned 0");
tn.write("rg_conf_set wbm/settings/network/h323 %i\n" % HABILITAR);
tn.read_until("Returned 0");
tn.write("rg_conf_set wbm/settings/services/wpspushbutton %i\n" % HABILITAR);
tn.read_until("Returned 0");
tn.write("save\n");
time.sleep(2);
tn.write("reboot\n");

2
scripts/.bin/volume-down.sh Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/sh
pacmd dump|awk --non-decimal-data '$1~/set-sink-volume/{system ("pacmd "$1" "$2" "$3-1000)}'

View File

@@ -0,0 +1,2 @@
#!/bin/sh
pacmd dump|awk --non-decimal-data '$1~/set-sink-mute/{system ("pacmd "$1" "$2" "($3=="yes"?"no":"yes"))}'

2
scripts/.bin/volume-up.sh Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/sh
pacmd dump|awk --non-decimal-data '$1~/set-sink-volume/{system ("pacmd "$1" "$2" "$3+1000)}'

194
scripts/.bin/winfuncs.sh Executable file
View File

@@ -0,0 +1,194 @@
#!/bin/bash
# Extracted from:http://forum.xfce.org/viewtopic.php?id=6841 ¡
#todo:
# cancel for tile functions
# determine what windows are maximized and re-max after the "window select" function
# determine what windows are non-resizable by the user so that the script doesn't resize them
# cascade also shaded windows
# which workspace we're on
function get_workspace {
if [[ "$DTOP" == "" ]] ; then
DTOP=`xdotool get_desktop`
fi
}
function is_desktop {
xwininfo -id "$*" | grep '"Desktop"'
return "$?"
}
function get_visible_window_ids {
if (( ${#WDOWS[@]} == 0 )) ; then
WDOWS=(`xdotool search --desktop $DTOP --onlyvisible "" 2>/dev/null`)
fi
}
function get_desktop_dim {
#desktop dimensions
if (( ${#DIM[@]} == 0 )) ; then
DIM=(`wmctrl -d | egrep "^0" | sed 's/.*DG: \([0-9]*x[0-9]*\).*/\1/g' | sed 's/x/ /g'`)
fi
}
function win_showdesktop {
get_workspace
get_visible_window_ids
command="search --desktop $DTOP \"\""
if (( ${#WDOWS[@]} > 0 )) ; then
command="$command windowminimize %@"
else
command="$command windowraise %@"
fi
echo "$command" | xdotool -
}
function win_tile_two {
get_desktop_dim
wid1=`xdotool selectwindow 2>/dev/null`
is_desktop "$wid1" && return
wid2=`xdotool selectwindow 2>/dev/null`
is_desktop "$wid2" && return
half_w=`expr ${DIM[0]} / 2`
commands="windowsize $wid1 $half_w ${DIM[1]}"
commands="$commands windowsize $wid2 $half_w ${DIM[1]}"
commands="$commands windowmove $wid1 0 0"
commands="$commands windowmove $wid2 $half_w 0"
commands="$commands windowraise $wid1"
commands="$commands windowraise $wid2"
wmctrl -i -r $wid1 -b remove,maximized_vert,maximized_horz
wmctrl -i -r $wid2 -b remove,maximized_vert,maximized_horz
echo "$commands" | xdotool -
}
function win_tile {
get_workspace
get_visible_window_ids
(( ${#WDOWS[@]} < 1 )) && return;
get_desktop_dim
# determine how many rows and columns we need
cols=`echo "sqrt(${#WDOWS[@]})" | bc`
rows=$cols
wins=`expr $rows \* $cols`
if (( "$wins" < "${#WDOWS[@]}" )) ; then
cols=`expr $cols + 1`
wins=`expr $rows \* $cols`
if (( "$wins" < "${#WDOWS[@]}" )) ; then
rows=`expr $rows + 1`
wins=`expr $rows \* $cols`
fi
fi
(( $cols < 1 )) && cols=1;
(( $rows < 1 )) && rows=1;
win_w=`expr ${DIM[0]} / $cols`
win_h=`expr ${DIM[1]} / $rows`
# do tiling
x=0; y=0; commands=""
for window in ${WDOWS[@]} ; do
wmctrl -i -r $window -b remove,maximized_vert,maximized_horz
commands="$commands windowsize $window $win_w $win_h"
commands="$commands windowmove $window `expr $x \* $win_w` `expr $y \* $win_h`"
x=`expr $x + 1`
if (( $x > `expr $cols - 1` )) ; then
x=0
y=`expr $y + 1`
fi
done
echo "$commands" | xdotool -
}
function win_cascade {
get_workspace
get_visible_window_ids
(( ${#WDOWS[@]} < 1 )) && return;
x=0; y=0; commands=""
for window in ${WDOWS[@]} ; do
wmctrl -i -r $window -b remove,maximized_vert,maximized_horz
commands="$commands windowsize $window 640 480"
commands="$commands windowmove $window $x $y"
x=`expr $x + 22`
y=`expr $y + 22`
done
echo "$commands" | xdotool -
}
function win_select {
get_workspace
get_visible_window_ids
(( ${#WDOWS[@]} < 1 )) && return;
# store window positions and widths
i=0
for window in ${WDOWS[@]} ; do
GEO=`xdotool getwindowgeometry $window | grep Geometry | sed 's/.* \([0-9].*\)/\1/g'`;
height[$i]=`echo $GEO | sed 's/\(.*\)x.*/\1/g'`
width[$i]=`echo $GEO | sed 's/.*x\(.*\)/\1/g'`
# ( xwininfo gives position not ignoring titlebars and borders, unlike xdotool )
POS=(`xwininfo -stats -id $window | grep 'geometry ' | sed 's/.*[-+]\([0-9]*[-+][0-9*]\)/\1/g' | sed 's/[+-]/ /g'`)
posx[$i]=${POS[0]}
posy[$i]=${POS[1]}
i=`expr $i + 1`
done
# tile windows
win_tile
# select a window
wid=`xdotool selectwindow 2>/dev/null`
is_desktop "$wid" && return
# restore window positions and widths
i=0; commands=""
for (( i=0; $i<${#WDOWS[@]}; i++ )) ; do
commands="$commands windowsize ${WDOWS[i]} ${height[$i]} ${width[$i]}"
commands="$commands windowmove ${WDOWS[i]} ${posx[$i]} ${posy[$i]}"
done
commands="$commands windowraise $wid"
echo "$commands" | xdotool -
}
for command in ${@} ; do
if [[ "$command" == "tile" ]] ; then
win_tile
elif [[ "$command" == "select" ]] ; then
win_select
elif [[ "$command" == "tiletwo" ]] ; then
win_tile_two
elif [[ "$command" == "cascade" ]] ; then
win_cascade
elif [[ "$command" == "showdesktop" ]] ; then
win_showdesktop
fi
done

2
scripts/.bin/zotero Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/sh
~/Programs/Zotero_linux-x86_64/run-zotero.sh