Vous n'êtes pas identifié(e).
Enorme ! wlourf, tu as le plus gros (...) que j'ai jamais vu
sinon merci pour le partage
...
Ouais bon j'ai peut-être l'esprit mal placé. 
Mais j'avais envi de faire cette remarque.
sur ce je =====> []
HuHu ou (H de Hawai)²
Il sert à rien ! Mais c'est la classe quand même ..... ou pas.
Eeepc 1005Pe : Crunchbang / MadBox
Hors ligne
Ça va, on peut dire que tu as bien cerné l'esprit de ce forum 
Hors ligne
Pipe-menu pour contrôler "Music on Console" (MoC quoi
) :
#!/bin/sh
# moc-ob-pipe - control moc in your openbox menu
# chmod +x mmoc-ob-pipe.sh, and place:
# "<menu id="pipe-moc-menu" label="MMusicOnConsole Pipe" execute="/path/to/script/moc-ob-pipe.sh" />"
# somewhere in your menu.
#set variables
playing=`mocp --info | egrep "^Artist\:|^SongTitle\:|^Album\:" | sed -n 'p'`
nowstatus=`mocp --info | sed -n '1p' | cut -c 8-15`
# convert reserved XML characters '&', '<', '>', '"' for songs containing characters
if [[ $playing =~ '&' ]]
then
export playing=${playing//\&/\&\;}
fi
if [[ $playing =~ '<' ]]
then
export playing=${playing//\</\<\;}
fi
if [[ $playing =~ '>' ]]
then
export playing=${playing//\>/\>\;}
fi
if [[ $playing =~ '"' ]]
then
export playing=${playing//\"/\"\;}
fi
# echo menu
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
echo "<openbox_pipe_menu>"
echo " <menu id=\"MoC-playing\" label=\"$nowstatus\">"
echo " <item label=\"$playing\">"
echo " <action name=\"Execute\"><execute>mocp --toggle-pause</execute></action>"
echo " </item>"
echo " </menu>"
echo " <separator />"
echo " <item label=\"play/pause\">"
echo " <action name=\"Execute\"><execute>mocp --toggle-pause</execute></action>"
echo " </item>"
echo " <item label=\"prev\">"
echo " <action name=\"Execute\"><execute>mocp --previous</execute></action>"
echo " </item>"
echo " <item label=\"next\">"
echo " <action name=\"Execute\"><execute>mocp --next</execute></action>"
echo " </item>"
echo " <item label=\"stop\">"
echo " <action name=\"Execute\"><execute>mocp --stop</execute></action>"
echo " </item>"
echo "</openbox_pipe_menu>"
Edit :
Nouvelle version du "Pipe-Menu", j'aimais pas l'aspect de l'autre en fait 
# moc-ob-pipe - control moc in your openbox menu
# chmod +x mmoc-ob-pipe.sh, and place:
# "<menu id="pipe-moc-menu" label="MMusicOnConsole Pipe" execute="/path/to/script/moc-ob-pipe.sh" />"
# somewhere in your menu.
# set variables
#playing=`mocp --info | egrep "^Artist\:|^SongTitle\:|^Album\:" | sed -n 'p'`
ARTIST="`mocp -i | grep 'Artist:' | sed -e 's/^.*: //'`"
SONGTITLE="`mocp -i | grep 'SongTitle:' | sed -e 's/^.*: //'`"
ALBUM="`mocp -i | grep 'Album:' | sed -e 's/^.*: //'`"
playing1=`echo "Titre : $SONGTITLE"`
playing2=`echo "Album : $ALBUM"`
playing3=`echo "Artiste : $ARTIST"`
nowstatus=`mocp -Q %state`
# echo menu
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
echo "<openbox_pipe_menu>"
echo " <menu id=\"MoC-playing\" label=\"$nowstatus\">"
echo " <item label=\"$playing1\">"
echo " <action name=\"Execute\"><execute>mocp --toggle-pause</execute></action>"
echo " </item>"
echo " <item label=\"$playing2\">"
echo " <action name=\"Execute\"><execute>mocp --toggle-pause</execute></action>"
echo " </item>"
echo " <item label=\"$playing3\">"
echo " <action name=\"Execute\"><execute>mocp --toggle-pause</execute></action>"
echo " </item>"
echo " </menu>"
echo " <separator />"
echo " <item label=\"play\">"
echo " <action name=\"Execute\"><execute>mocp --play</execute></action>"
echo " </item>"
echo " <item label=\"pause\">"
echo " <action name=\"Execute\"><execute>mocp --toggle-pause</execute></action>"
echo " </item>"
echo " <item label=\"prev\">"
echo " <action name=\"Execute\"><execute>mocp --previous</execute></action>"
echo " </item>"
echo " <item label=\"next\">"
echo " <action name=\"Execute\"><execute>mocp --next</execute></action>"
echo " </item>"
echo " <item label=\"stop\">"
echo " <action name=\"Execute\"><execute>mocp --stop</execute></action>"
echo " </item>"
echo "</openbox_pipe_menu>"Portable17p : CrunchBangLinux // EeePC : ArchLinux
Eeepad Transformer : Android Honeycomb 3.2 // GalaxyS : Android 2.2
Ma page DevArt : http://kookadimi.deviantart.com
Mes photos : http://www.fluidr.com/photos/kookadimi/sets
Hors ligne
C'est vraiment du pur bonheur ce post. Celui qui ne trouve pas quelque chose d'intéressant ici, n'a rien compris à la force d'Openbox. C'est tout de même impressionnant les multiples possibilitées offertes...
Merci à tous les contributeurs.
---------------------------------------------
| CRUNCHBANG #! 11 Waldorf + Openbox |
| ASUS Zenbook UX31E |
--------------------------------------------
Hors ligne
C'est dingue kooka, tu change 2fois de design /fond d'écran par jour lol.
Jolie scripts sinon 
HuHu ou (H de Hawai)²
Il sert à rien ! Mais c'est la classe quand même ..... ou pas.
Eeepc 1005Pe : Crunchbang / MadBox
Hors ligne
Bon, voilà... :-) mon premier poste sur Crunchbang.
J'ai décidé de me mettre au bash réceamment et je suis un amoureux de conky.
Je passe mon temps à tester de nouvelle configuration et je voulais un menu me permettant de gérer mes différents conky, les créer et les éditer.
Je pense adapter mon script de manière à ce qu'il fonctionne aussi pour tint2.
[== bash ==]
#!/bin/bash
#Version 0
#>Trouver un moyen de dissocier un nom et le fichier de config ?? ou useless
#Changé de manière à ce que Geany --> editeur de txt default
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
echo "<openbox_pipe_menu>"
echo "<separator label=\"Controle the conky power\" />"
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo "
<menu id=\"Conkyfly\" label=\"Conky Fly\">
<separator label=\"#!~~~~~~~#!\" />
"
liste=`ls ~/.config/conky`
for cfile in $liste
do
ps -ef |grep -w $cfile|awk '{print $8'}>tpp
check=`head -n 1 tpp`
if [ $check = "conky" ];
then
ps -ef |grep -w $cfile|awk '{print $2'}>tpp2
pid=`head -n 1 tpp2`
echo "
<item label=\"* $cfile\">
<action name=\"Execute\">
<execute>
kill -9 $pid
</execute>
</action>
</item>
"
else
echo "
<item label=\" :-) $cfile \">
<action name=\"Execute\">
<execute>
conky -c ~/.config/conky/$cfile
</execute>
</action>
</item>
"
fi
done
echo "</menu>"
echo "
<menu id=\"Edit_fly\" label=\"Mange your Fly\">
<separator label=\" ????? \" />
"
liste=`ls ~/.config/conky`
for cfile in $liste
do
#On affiche tous les conkys pouvants êtres lancés et on propose le lancemant
#Création d'un script pour tuer le bon conky ??
echo "
<item label=\"$cfile\">
<action name=\"Execute\">
<execute>
geany ~/.config/conky/$cfile
</execute>
</action>
</item>
"
done
echo "
</menu>
"
echo "<separator label=\"Basic conky !-! \" />"
if pidof conky | grep [0-9] > /dev/null
then
echo "
<item label=\"Edit \">
<action name=\"Execute\">
<execute>
geany ~/.config/conky/conkyrc ~/.config/conky/conk2yrc ~/.config/conky/conkyrc3 ~/.config/conky/conkyrc4 ~/bin/boot_conky.sh
</execute>
</action>
</item>
<item label=\":-( \">
<action name=\"Execute\">
<execute>
killall conky
</execute>
</action>
</item>
"
else
echo "<item label=\"Aucun conky détecté !\" />"
echo " <item label=\":-) \">
<action name=\"Execute\">
<execute>
boot_conky.sh
</execute>
</action>
</item>
"
fi
echo " <separator label=\"Help?\"/>
<item label=\"man page\">
<action name=\"Execute\">
<execute>
terminator --command="man conky"
</execute>
</action>
</item>
<item label=\"Wiki Page\">
<action name=\"Execute\">
<execute>
x-www-browser http://crunchbanglinux.org/wiki/conky
</execute>
</action>
</item>
"
echo "</openbox_pipe_menu>"Et une petite screenshot ici;
Voilà, tous commentaires et remarques sont les bienvenues.
?
Hors ligne
salut blop,
très sympa ce petit script, belle entrée dans le crunchbang'univers 
bienvenue à toi 
[arpinux.org][wmfs²][devart][livarp][FSF][distrozilla][books]
En ligne
Whaaa Blop sympa 
C'est le genre de scripts que je kiff bien 
En passant, tu as des conky à fond transparent ?! Ça m'intéresse, ça... Comment peut-on avoir un fond transparent ?
Serveur : Livarp 0.3.9
PC fixe : CrunchBang BPO 10 OpenBox
PC portable : CrunchBang 11 OpenBox
PC boulot : Crunchbang 10 OpenBox
Hors ligne
pour les fonds transparents : http://conky.pitstop.free.fr/wiki/index … r_%28fr%29 & http://conky.pitstop.free.fr/wiki/index … t_%28fr%29 ... sources : conky-pitstop ...
[arpinux.org][wmfs²][devart][livarp][FSF][distrozilla][books]
En ligne
J'ai testé les deux, et après plusieurs tentatives de bidouille, aucun résultat, je n'ai toujours pas de fond transparent :s
Merci quand même pour les liens 
J'y réfléchirai à tête reposé. J'ai ptetre loupé un truc quelque part xD
Serveur : Livarp 0.3.9
PC fixe : CrunchBang BPO 10 OpenBox
PC portable : CrunchBang 11 OpenBox
PC boulot : Crunchbang 10 OpenBox
Hors ligne
Au cas où, tu a activé cairo-compgnr avant ?
Sinon il faut juste télécharger et rendre exécutable le script lua, puis copier coller les lignes pour l’appeler avant TEXT dans ton conkyrc.
Voilà, si ça peut t'aider.
En fait si sa intéresse quelqu'un, je vais joindre mes fichiers de config sur devian-art dès que j'aurai fait le ménage.
Hors ligne
lol non, il n'était pas activé... Et après essai, je l'ai très très vite re-désactivé, car il m'a joyeusement fait bugger mon affichage (les plugins de transparence qui rendaient opaque, les plugins de "fade" et d'effet d'ouverture/fermeture complètement inopérents, ...)
Alors si je suis forcé de passer par là pour avoir un bg semi transparent sur conky, et ben je vais probablement devoir laisser tomber -_-'
Serveur : Livarp 0.3.9
PC fixe : CrunchBang BPO 10 OpenBox
PC portable : CrunchBang 11 OpenBox
PC boulot : Crunchbang 10 OpenBox
Hors ligne
bon, juste comme ça, le plus simple pour afficher un fond semi transparent, c'est quand même d'utiliser la foncion $image de conky .. et de créer un joli fond aux dimensions de ton conky .. 
[arpinux.org][wmfs²][devart][livarp][FSF][distrozilla][books]
En ligne
...
Merci, Arp 
J'ai plus qu'à me bidouiller ma tit image pour qu'elle soit comme que je veux 
RE-Merci 
Serveur : Livarp 0.3.9
PC fixe : CrunchBang BPO 10 OpenBox
PC portable : CrunchBang 11 OpenBox
PC boulot : Crunchbang 10 OpenBox
Hors ligne
Salut le topic date un peu mais je publie mon pipemenu pour les consommateurs d'internet
#!/bin/bash
echo '<openbox_pipe_menu>'
file="$HOME/.scripts/net.txt"
browser="iceweasel"
while read line
do
LABEL=`echo $line | cut -f1 -d:`
PLACE=`echo $line | cut -f2 -d:`
echo '<item label="'`echo $LABEL`'">'
echo '<action name="Execute"><execute>'
echo "$browser ${PLACE}"
echo '</execute></action>'
echo '</item>'
done < $file
echo '</openbox_pipe_menu>'On peut changer le navigateur et le fichir pour lire les raccourcis internet.
Ceux ci doivent être ainsi: label:adresse
ex: gmail:www.gmail.com
Pour ceux que ça intéresse, on doit pouvoir y inclure les favoris iceweasel
Voila ce que cela donne:
Dernière modification par benoitfra (2012-10-29 13:12:29)
transfuge d'ubuntu
Installation 100% linux aucune trace de WDOZ
Hors ligne
Bonjour à tous !
Voulant facilement démonter mes clefs USB à partir de tint2 et/ou des menus, je suis parti sur : obdevicemenu.
J'ai par contre voulu enrichir le menupipe proposé par obdevicemenu, tout d'abord en le francisant, et ensuite et surtout en y ajoutant des compléments avant et après. J'ai du pour cela modifier le script d'origine avec une fonction "avant" et "après". Avant, j'ai "Emplacement" avec la possibilité de lancer le gestionnaire de fichier sur Documents, Téléchargements... C'est codé en dur. A la fin, j'ai ajouté une catégorie "réseau" avec le lancement de Gigolo et du menupipe Dropbox de Crunchbang. Voilà ce que ça donne :
Si cela vous intéresse, il faut ajouter : <menu id="devices" label="Fichiers" execute="/usr/bin/obdevicemenu" /> au fichier de menu d'Openbox puis placer le script suivant sous /usr/bin/obdevicemenu :
#!/bin/bash
# CONFIGURATION
# {{{
unset GREP_OPTIONS
declare filemanager="/usr/bin/thunar"
declare notify="/usr/bin/notify-send"
declare notify_options="--expire-time=300"
declare optical_devices="-E ^/dev/sr[0-9]+"
declare removable_devices="-E ^/dev/sd[b-z][0-9]*|^/dev/mmcblk[0-9]+p*[0-9]*"
declare mount_options="--mount-options nosuid,noexec,noatime"
declare -i show_internal=0
declare -i show_notifications=1
declare -i show_optical_device_filename=1
declare -i show_removable_device_filename=1
declare -i fancy_sort=1
declare -i run_post_mount=0
declare -i run_post_unmount=0
declare -a blacklist=( )
declare CONFIGFILE
debutmenu() {
printf '%s\n' "<openbox_pipe_menu>"
printf '%s\n' "<separator label=\"Emplacements\" />"
printf '%s\n' "<item label=\"Documents\">"
printf '%s\n' "<action name=\"Execute\">"
printf '%s\n' "<command>$0 --open-directory ~/Documents</command>"
printf '%s\n' "</action>"
printf '%s\n' "</item>"
printf '%s\n' "<item label=\"Téléchargements\">"
printf '%s\n' "<action name=\"Execute\">"
printf '%s\n' "<command>$0 --open-directory ~/Téléchargements</command>"
printf '%s\n' "</action>"
printf '%s\n' "</item>"
}
finmenu() {
printf '%s\n' "<separator label=\"Réseau\" />"
printf '%s\n' "<item label=\"Systèmes de fichiers distants\">"
printf '%s\n' "<action name=\"Execute\">"
printf '%s\n' "<execute>"
printf '%s\n' "gigolo"
printf '%s\n' "</execute>"
printf '%s\n' "</action>"
printf '%s\n' "</item>"
printf '%s\n' "<menu execute=\"cb-dropbox-pipemenu\" id=\"dropbox\" label=\"Dropbox\"/>"
printf '%s\n' "</openbox_pipe_menu>"
}
if [[ -n "${XDG_CONFIG_HOME}" ]]; then
CONFIGFILE="${XDG_CONFIG_HOME}/obdevicemenu/config"
else
CONFIGFILE="${HOME}/.config/obdevicemenu/config"
fi
if [[ ! -f "${CONFIGFILE}" ]]; then
CONFIGFILE="/etc/obdevicemenu.conf"
fi
if [[ -f "${CONFIGFILE}" ]]; then
. "${CONFIGFILE}"
if (( $? != 0 )); then
debutmenu
printf '%s\n' "<separator label=\"obdevicemenu\" />"
printf '%s\n' "<item label=\"Fichier de configuration non détecté\" />"
finmenu
exit 1
fi
fi
if ! command -v udisks >/dev/null 2>&1; then
debutmenu
printf '%s\n' "<separator label=\"obdevicemenu\" />"
printf '%s\n' "<item label=\"udisks non installé\" />"
finmenu
exit 1
fi
# }}}
# API INTERNE
# {{{
finmenu() {
printf '%s\n' "<separator label=\"Réseau\" />"
printf '%s\n' "<item label=\"Systèmes de fichiers distants\">"
printf '%s\n' "<action name=\"Execute\">"
printf '%s\n' "<execute>"
printf '%s\n' "gigolo"
printf '%s\n' "</execute>"
printf '%s\n' "</action>"
printf '%s\n' "</item>"
printf '%s\n' "<menu execute=\"cb-dropbox-pipemenu\" id=\"dropbox\" label=\"Dropbox\"/>"
printf '%s\n' "</openbox_pipe_menu>"
}
notify() {
if [ -z "${notify_options}" ]; then
$notify "$*"
else
$notify ${notify_options} "$*"
fi
}
info_blank() {
udisks --show-info ${1} \
| grep -m 1 -w "^[[:space:]]*blank:" \
| awk '{print $2}'
}
info_ejectable() {
udisks --show-info ${1} \
| grep -m 1 -w "^[[:space:]]*ejectable:" \
| awk '{print $2}'
}
info_has_media() {
udisks --show-info ${1} \
| grep -m 1 -w "^[[:space:]]*has media:" \
| awk '{print $3}'
}
info_internal() {
udisks --show-info ${1} \
| grep -m 1 -w "^[[:space:]]*system internal:" \
| awk '{print $3}'
}
info_label() {
local info_label=
info_label="$(udisks --show-info ${1} \
| grep -m 1 -w "^ label:" \
| awk '{gsub(/_/,"");$1="";print substr($0, index($0,$2))}')"
[[ -n "${info_label}" ]] && printf '%s\n' "${info_label}"
}
info_media() {
udisks --show-info ${1} \
| grep -m 1 -w "^[[:space:]]*media:" \
| awk '{gsub(/_/,"");print $2}'
}
info_model() {
udisks --show-info ${1} \
| grep -m 1 -w "^[[:space:]]*model:" \
| awk '{gsub(/_/,"");$1="";print substr($0, index($0,$2))}'
}
info_mounted() {
udisks --show-info ${1} \
| grep -m 1 -w "^[[:space:]]*is mounted:" \
| awk '{print $3}'
}
info_mountpath() {
udisks --show-info ${1} \
| grep -m 1 -w "^[[:space:]]*mount paths:" \
| awk '{$1="";$2="";print substr($0, index($0,$3))}'
}
info_type() {
udisks --show-info ${1} \
| grep -m 1 -w "^[[:space:]]*type:" \
| awk '{gsub(/_/,"");print $2}'
}
info_vendor() {
udisks --show-info ${1} \
| grep -m 1 -w "^[[:space:]]*vendor:" \
| awk '{gsub(/_/,"");$1="";print substr($0, index($0,$2))}'
}
convert_size() {
local -i old_size="${1}"
local new_size=
printf '%s\n' "${old_size}" | grep -ow -E ^[1-9]{1}[0-9]*$ >/dev/null 2>&1
(( $? != 0 )) && return 1
if (( old_size > 21474836480 )); then
new_size="$((${old_size}/1073741824)) Go"
elif (( old_size > 10485760 )); then
new_size="$((${old_size}/1048576)) Mo"
elif (( old_size > 10240 )); then
new_size="$((${old_size}/1024)) Ko"
else
new_size="${old_size} octets"
fi
printf '%s\n' "${new_size}"
}
info_device_size() {
local info_device_size=
info_device_size="$(udisks --show-info ${1} \
| grep -m 1 -w "^[[:space:]]*size:" \
| awk '{print $2}')"
if [[ -n "${info_device_size}" ]]; then
info_device_size="$(convert_size "${info_device_size}")"
printf '%s\n' "${info_device_size}"
fi
}
info_partition_size() {
local info_partition_size=
info_partition_size="$(udisks --show-info ${1} \
| grep -m 1 -w " size:" \
| awk '{print $2}')"
if [[ -n "${info_partition_size}" ]]; then
info_partition_size="$(convert_size "${info_partition_size}")"
printf '%s\n' "${info_partition_size}"
fi
}
action_eject() {
local devname="${1}"
local -i mounted=0
mounted="$(info_mounted "${devname}")"
if (( mounted == 1 )); then
action_unmount "${devname}"
fi
mounted="$(info_mounted "${devname}")"
if (( mounted == 0 )); then
if (( show_notifications == 1 )); then
if command -v "${notify}" >/dev/null 2>&1; then
notify "$(printf '%s\n' "${devname} en cours d'éjection ...")"
notify "$(udisks --eject ${devname})"
fi
else
udisks --eject ${devname}
fi
fi
}
action_mount() {
local devname="${1}"
if (( show_notifications == 1 )); then
if command -v "${notify}" >/dev/null 2>&1; then
notify "$(printf '%s\n' "${devname} en cours de montage ...")"
notify "$(udisks --mount ${devname} ${mount_options})"
fi
else
udisks --mount ${devname} ${mount_options}
fi
if (( run_post_mount == 1 )); then
post_mount ${devname}
fi
}
action_open() {
local devname="${1}"
local info_mountpath="$(info_mountpath "${devname}")"
if [[ -n "${info_mountpath}" ]]; then
$filemanager "${info_mountpath}"
else
$filemanager
fi
}
action_unmount() {
local devname="${1}"
if (( show_notifications == 1 )); then
if command -v "${notify}" >/dev/null 2>&1; then
notify "$(printf '%s\n' "${devname} en cours de démontage ...")"
notify "$(udisks --unmount ${devname})"
fi
mounted="$(info_mounted ${devname})"
if (( mounted == 1 )); then
notify "$(printf '%s\n' "${devname} démonté")"
fi
else
udisks --unmount ${devname}
thunar
fi
if (( run_post_unmount == 1 )); then
post_unmount ${devname}
fi
}
action_unmount_all() {
for devname in $*; do
action_unmount ${devname}
done
}
action_info() {
local devname="${1}"
local devmajor="${devname%%[0-9]*}"
udisks --show-info ${devname} >/dev/null 2>&1
if (( $? != 0 )); then
printf '%s\n' "<openbox_pipe_menu>"
printf '%s\n' "<item label=\"erreur\" />"
printf '%s\n' "</openbox_pipe_menu>"
exit 0
fi
local info_label="$(info_label "${devname}")"
local info_vendor="$(info_vendor "${devmajor}")"
local info_model="$(info_model "${devmajor}")"
local info_device_size="$(info_device_size "${devmajor}")"
local info_type="$(info_type "${devname}")"
local info_media="$(info_media ${devname})"
if [[ "${devname}" != "${devmajor}" ]]; then
local info_partition_size="$(info_partition_size "${devname}")"
fi
printf '%s\n' "<openbox_pipe_menu>"
printf '%s\n' "<separator label=\"info\" />"
[[ -n "${info_device_filename}" ]] && \
printf '%s\n' "<item label=\"${devname}\" />"
[[ -n "${info_label}" ]] && \
printf '%s\n' "<item label=\"${info_label}\" />"
[[ -n "${info_vendor}" ]] && \
printf '%s\n' "<item label=\"fourni par ${info_vendor}\" />"
[[ -n "${info_model}" ]] && \
printf '%s\n' "<item label=\"${info_model}\" />"
[[ -n "${info_type}" ]] && \
printf '%s\n' "<item label=\"${info_type}\" />"
[[ -n "${info_media}" ]] && \
printf '%s\n' "<item label=\"${info_media}\" />"
[[ -n "${info_partition_size}" ]] && \
printf '%s\n' "<item label=\"${info_partition_size}\" />"
[[ -n "${info_device_size}" ]] && \
printf '%s\n' "<item label=\"${info_device_size}\" />"
printf '%s\n' "</openbox_pipe_menu>"
}
fancy_sort() {
local devname= devmajor= partition_number=
local -i array_position=0
array_position=0
for devname in ${removable[@]}; do
if [[ "${devname}" =~ ^/dev/dm-[0-9]+ ]]; then
devmajor="${devname%%[0-9]*}"
elif [[ "${devname}" =~ ^/dev/fd[0-9]+ ]]; then
devmajor="${devname%%[0-9]*}"
elif [[ "${devname}" =~ ^/dev/sd[a-z][0-9]+ ]]; then
devmajor="${devname%%[0-9]*}"
else
array_position=$((++array_position)); continue
fi
if [[ "${devname}" = "${devmajor}" ]]; then
array_position=$((++array_position)); continue
fi
partition_number="${devname#${devmajor}}"
removable[${array_position}]=${devmajor}$(printf '%02d' "${partition_number}")
array_position=$((++array_position))
done
removable=( $(printf '%s\n' "${removable[@]}" | sort) )
array_position=0
for devname in ${removable[@]}; do
if [[ "${devname}" =~ ^/dev/dm-[0-9]+ ]]; then
devmajor="${devname%%[0-9]*}"
elif [[ "${devname}" =~ ^/dev/fd[0-9]+ ]]; then
devmajor="${devname%%[0-9]*}"
elif [[ "${devname}" =~ ^/dev/sd[a-z][0-9]+ ]]; then
devmajor="${devname%%[0-9]*}"
else
array_position=$((++array_position)); continue
fi
if [[ "${devname}" = "${devmajor}" ]]; then
array_position=$((++array_position)); continue
fi
partition_number="${devname#${devmajor}}"
removable[${array_position}]=${devmajor}${partition_number#0}
array_position=$((++array_position))
done
}
# }}}
# FONCTIONS MENU
# {{{
device_menu() {
local -a removable=( )
#local -a optical=( )
local -a mounted_removable=( )
#local -a mounted_optical=( )
local -i total_removable=0
debutmenu
udisks --enumerate-device-files >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
printf '%s\n' "<item label=\"erreur\" />"
printf '%s\n' "</openbox_pipe_menu>"
exit 0
fi
printf '%s\n' "<separator label=\"Volumes amovibles\" />"
removable=( $(udisks --enumerate-device-files \
| grep -ow ${removable_devices} | sort) )
if (( fancy_sort == 1 )); then
fancy_sort
fi
for devname in ${removable[@]}; do
local devmajor=
local info_label=
local -i info_internal=
local -i mounted=
local -i partitions=
if [[ "${devname}" =~ ^/dev/mmcblk[0-9]+p*[0-9]* ]]; then
devmajor="${devname%%p[0-9]*}"
if [[ "${devname}" = "${devmajor}" ]]; then
partitions="$(udisks --enumerate-device-files \
| grep -ow -E ^${devname}p[0-9]+ -c)"
if (( partitions > 0 )); then
continue
fi
fi
else
devmajor="${devname%%[0-9]*}"
if [[ "${devname}" = "${devmajor}" ]]; then
partitions="$(udisks --enumerate-device-files \
| grep -ow -E ^${devname}[0-9]+ -c)"
if (( partitions > 0 )); then
continue
fi
fi
fi
info_internal="$(info_internal "${devmajor}")"
if (( info_internal == 1 )) && (( show_internal == 0 )); then
continue
fi
if (( info_internal == 0 )) || (( show_internal == 1 )); then
for string in ${blacklist[@]}; do
udisks --show-info "${devname}" | grep -E "${string}" >/dev/null 2>&1
(( $? == 0 )) && continue 2
done
total_removable=$((++total_removable))
info_label="$(info_label "${devname}")"
if [[ -z "${info_label}" ]]; then
info_label="$(info_label "${devmajor}")"
[[ -z "${info_label}" ]] && info_label="$(info_model "${devmajor}")"
[[ -z "${info_label}" ]] && info_label="$(info_vendor "${devmajor}")"
if [[ -z "${info_label}" ]]; then
info_label=""
else
info_label="${info_label}"
fi
fi
mounted="$(info_mounted "${devname}")"
if (( mounted == 0 )); then
if (( show_removable_device_filename == 1 )); then
printf '%s' "<menu id=\"mount${devname}\" "
printf '%s' "label=\"${devname#/dev/}: ${info_label}\" "
printf '%s' "execute=\"$0 --mount-menu removable "
printf '%s' "${devname}\" />"
printf '\n'
else
printf '%s' "<menu id=\"mount${devname}\" "
printf '%s' "label=\"${info_label}\" "
printf '%s' "execute=\"$0 --mount-menu removable "
printf '%s' "${devname}\" />"
printf '\n'
fi
else
if (( show_removable_device_filename == 1 )); then
printf '%s' "<menu id=\"mount${devname}\" "
printf '%s' "label=\"${devname#/dev/}: "
printf '%s' "${info_label} (monté)\" "
printf '%s' "execute=\"$0 --mount-menu removable "
printf '%s' "${devname}\" />"
printf '\n'
else
printf '%s' "<menu id=\"mount${devname}\" "
printf '%s' "label=\"${info_label} (monté)\" "
printf '%s' "execute=\"$0 --mount-menu removable "
printf '%s' "${devname}\" />"
printf '\n'
fi
mounted_removable[${#mounted_removable[*]}]=${devname}
fi
fi
done
if (( total_removable == 0 )); then
printf '%s\n' "<item label=\"Aucun\" />"
elif (( ${#mounted_removable[*]} > 0 )); then
printf '%s\n' "<item label=\"Démonter tous les médias\">"
printf '%s\n' "<action name=\"Execute\">"
printf '%s\n' "<command>$0 --unmount-all-removable \
${mounted_removable[*]}</command>"
printf '%s\n' "<prompt>Démonter toutes les média ? </prompt>"
printf '%s\n' "</action>"
printf '%s\n' "</item>"
fi
printf '%s\n' "<separator label=\"Disques optiques\" />"
optical=( $(udisks --enumerate-device-files \
| grep -ow ${optical_devices} | sort) )
if (( ${#optical[*]} == 0 )); then
printf '%s\n' "<item label=\"Aucun\" />"
finmenu
return 0
fi
for devname in ${optical[@]}; do
local info_label=
local -i info_blank=0
local -i info_has_media=0
local -i mounted=0
info_has_media="$(info_has_media "${devname}")"
for string in ${blacklist[@]}; do
udisks --show-info "${devname}" | grep -E "${string}" >/dev/null 2>&1
(( $? == 0 )) && continue 2
done
if (( info_has_media == 0 )); then
printf '%s\n' "<item label=\"${devname#/dev/} absent\" />"
else
info_blank="$(info_blank "${devname}")"
if (( info_blank == 1 )); then
info_label="média vide"
else
info_label="$(info_label ${devname})"
[[ -z "${info_label}" ]] && info_label="$(info_model "${devname}")"
[[ -z "${info_label}" ]] && info_label=""
fi
mounted="$(info_mounted "${devname}")"
if (( mounted == 0 )); then
if (( show_optical_device_filename == 1 )); then
printf '%s' "<menu id=\"mount${devname}\" "
printf '%s' "label=\"${devname#/dev/}: ${info_label}\" "
printf '%s' "execute=\"$0 --mount-menu optical "
printf '%s' "${devname}\" />"
printf '\n'
else
printf '%s' "<menu id=\"mount${devname}\" "
printf '%s' "label=\"${info_label}\" "
printf '%s' "execute=\"$0 --mount-menu optical "
printf '%s' "${devname}\" />"
printf '\n'
fi
else
if (( show_optical_device_filename == 1 )); then
printf '%s' "<menu id=\"mount${devname}\" "
printf '%s' "label=\"${devname#/dev/}: "
printf '%s' "${info_label} (monté)\" "
printf '%s' "execute=\"$0 --mount-menu optical "
printf '%s' "${devname}\" />"
printf '\n'
else
printf '%s' "<menu id=\"mount${devname}\" "
printf '%s' "label=\"${info_label} (monté)\" "
printf '%s' "execute=\"$0 --mount-menu optical "
printf '%s' "${devname}\" />"
printf '\n'
fi
mounted_optical[${#mounted_optical[*]}]=${devname}
fi
fi
done
if (( ${#mounted_optical[*]} > 0 )); then
printf '%s\n' "<item label=\"Démonter tous les médias\">"
printf '%s\n' "<action name=\"Execute\">"
printf '%s\n' "<command>$0 --unmount-all-optical \
${mounted_optical[*]}</command>"
printf '%s\n' "<prompt>Démonter tous les CD/DVD ?</prompt>"
printf '%s\n' "</action>"
printf '%s\n' "</item>"
fi
finmenu
}
mount_menu() {
local media_type="${1}"
local devname="${2}"
local info_label="${3}"
local devname_short="${devname##*/}"
local -i info_ejectable=0
local -i mounted=0
printf '%s\n' "<openbox_pipe_menu>"
if [[ "${media_type}" = "removable" ]]; then
if (( show_removable_device_filename == 1 )); then
printf '%s\n' "<separator label=\"${devname}\" />"
else
printf '%s\n' "<separator label=\"${info_label}\" />"
fi
elif [[ "${media_type}" = "optical" ]]; then
if (( show_optical_device_filename == 1 )); then
printf '%s\n' "<separator label=\"${devname}\" />"
else
printf '%s\n' "<separator label=\"${info_label}\" />"
fi
fi
mounted="$(info_mounted "${devname}")"
if (( mounted == 0 )); then
printf '%s\n' "<item label=\"Monter et ouvrir\">"
printf '%s\n' "<action name=\"Execute\">"
printf '%s\n' "<command>$0 --mount-and-open ${devname}</command>"
printf '%s\n' "</action>"
printf '%s\n' "</item>"
printf '%s\n' "<item label=\"Monter\">"
printf '%s\n' "<action name=\"Execute\">"
printf '%s\n' "<command>$0 --mount-device ${devname}</command>"
printf '%s\n' "</action>"
printf '%s\n' "</item>"
else
printf '%s\n' "<item label=\"Ouvrir\">"
printf '%s\n' "<action name=\"Execute\">"
printf '%s\n' "<command>$0 --open-directory ${devname}</command>"
printf '%s\n' "</action>"
printf '%s\n' "</item>"
printf '%s\n' "<item label=\"Démonter\">"
printf '%s\n' "<action name=\"Execute\">"
printf '%s\n' "<command>$0 --unmount-device ${devname}</command>"
printf '%s\n' "</action>"
printf '%s\n' "</item>"
fi
info_ejectable="$(info_ejectable "${devname}")"
if (( info_ejectable == 1 )); then
printf '%s\n' "<item label=\"Ejecter\">"
printf '%s\n' "<action name=\"Execute\">"
printf '%s\n' "<command>$0 --eject-device ${devname}</command>"
printf '%s\n' "</action>"
printf '%s\n' "</item>"
fi
printf '%s' "<menu id=\"showinfo${devname##*/}\" "
printf '%s' "label=\"Info\" "
printf '%s' "execute=\"$0 --show-info ${devname}\" />"
printf '\n'
printf '%s\n' "</openbox_pipe_menu>"
}
# }}}
# INT MAIN
if (( $# == 0 )); then
device_menu
exit 0
fi
case "${1}" in
"--mount-menu")
mount_menu ${2} ${3}
;;
"--mount-device")
action_mount "${2}"
;;
"--unmount-device")
action_unmount "${2}"
;;
"--eject-device")
action_eject "${2}"
;;
"--open-directory")
action_open "${2}"
;;
"--mount-and-open")
action_mount "${2}" && action_open "${2}"
;;
"--show-info")
action_info "${2}"
;;
"--unmount-all-removable")
shift 1 && action_unmount_all $@
;;
"--unmount-all-optical")
shift 1 && action_unmount_all $@
;;
esac
# vim: set ts=4 sw=4 noet foldmethod=marker :Et la conf suivante dans /etc/obdevicemenu.conf
#
# obdevicemenu.conf
#
# Place in /etc/obdevicemenu.conf for system wide configuration.
# Place in ~/.config/obdevicemenu/config for per-user configuration.
# XDG_CONFIG_HOME is respected if it has been set.
# Set filemanager command. The mount point is passed as the first argument.
#filemanager="/usr/bin/uxterm -wf -e /usr/bin/mc"
filemanager="/usr/bin/Thunar"
# Set whether notifications will be shown. This can be "0" or "1".
show_notifications="1"
# Set notification command path and options to pass. These are only used if
# show_notifications is set to "1". The messages are passed to this command
# as the final argument. notify_options can be left blank if you do not need
# to pass any options to the notification command.
notify="/usr/bin/notify-send"
notify_options="--expire-time=3000"
# Set optical device location. This string is matched using grep like so:
# udisks --enumerate-device-files | grep -ow ${optical_devices} | sort
# See the grep man page for more information.
optical_devices="-E ^/dev/sr[0-9]+"
# Set removable devices location. The default is to ignore /dev/sda*, which is
# usually the primary system drive. Devices such as SD card readers show up as
# /dev/mmcblk* and are also matched. This string is matched using grep like so:
# udisks --enumerate-device-files | grep -ow ${removable_devices} | sort
# See the grep man page for more information.
removable_devices="-E ^/dev/sd[b-z][0-9]*|^/dev/mmcblk[0-9]+p*[0-9]*"
###
### This example also includes LUKS encrypted partitions:
### removable_devices="-E ^/dev/sd[b-z][0-9]*|^/dev/mmcblk[0-9]+p*[0-9]*|^/dev/dm-[0-9]+"
###
### This example also includes LUKS encrypted partitions but hides /dev/dm-0 to
### /dev/dm-7 which are system partitions:
### removable_devices="-E ^/dev/sd[b-z][0-9]*|^/dev/dm-[8-9]|^/dev/dm-[1-9][0-9]+"
###
### This example also includes floppy drives (note that the device will always
### be shown whether or not there is a floppy disk inserted):
### removable_devices="-E ^/dev/sd[b-z][0-9]*|^/dev/fd[0-9]+"
###
# Set whether to show internal devices. This can be "0" or "1". If you have
# system drives that are always found at the same location (e.g. /dev/sda),
# it is better and faster to hide them using the "removable_devices" option.
show_internal="0"
# Set devices to blacklist. Any device whose "udisks --show-info" output
# contains a string listed here will be hidden. The strings are matched
# using "grep -E". The pipe menu does not display underscores, so the label
# shown by obdevicemenu may not be the real device label that must be matched
# here. In that case, check for the real label using "udisks --show-info".
blacklist=( )
###
### This example will match any device with "Photosmart" in any field.
### blacklist+=( 'Photosmart' )
###
### This example matches only the model field, to reduce false positives.
### blacklist+=( 'model: * Photosmart C4400' )
###
### This example matches several different devices. Note that the array can be
### split over multiple lines for convenience.
### blacklist+=( 'by-id: * /dev/disk/by-id/ata-ST9250410AS_5VG8EAYT-part4' )
### blacklist+=( 'label: * secret' )
### blacklist+=( 'vendor: * Huawei' )
###
# Set default mount options for Udisks.
mount_options="--mount-options nosuid,noexec,noatime"
# Set whether to show the device filename in the menu. This can be "0" or "1".
# Example: If this is set to "1" then the menu entry will show "sdb1: Cruzer",
# while if this is set to "0" then the menu entry will only show "Cruzer".
show_removable_device_filename="1"
show_optical_device_filename="1"
# Set whether to sort devices more thoroughly. This can be "0" or "1".
# This option is basically a big hack to get around a shortcoming of the sort
# command, which causes /dev/sdc11 to be shown in the menu before /dev/sdc2.
# It will deal with /dev/sd* and /dev/dm-* devices, but not /dev/mmcblk* as
# the sorting is not really that simple. It is a big hack so if you enable it
# then i can make no promises that it will be fast or bug free.
fancy_sort="0"
# Set custom commands to be run automatically after mounting or unmounting.
# This is useful for spinning down a hard drive after unmounting it. The
# device name (e.g. /dev/sdb1) is passed as the first and only argument.
# Uncomment the examples below, or modify them to pass any arbitrary commands.
# post_mount is run immediately after a successful mount operation, and
# post_unmount is run immediately after a successful unmount operation.
# Set "run_post_mount" to "0" to disable or "1" to enable.
run_post_mount="0"
# This example uses udisks to set the spindown timeout after mounting.
#post_mount() {
# udisks --set-spindown ${1} --spindown-timeout 240
#}
# Set "run_post_unmount" to "0" to disable or "1" to enable.
run_post_unmount="0"
# This example uses udisks to set the spindown timeout after unmounting.
#post_unmount() {
# udisks --set-spindown ${1} --spindown-timeout 240
#}En espérant que cela puisse servir à d'autres
Patrick
Hors ligne
Merci patrickV, je vais adopter ton script car c'est parfois saoulant de devoir ouvrir thunar juste pour démonter une clé... 
"Avec CrunchBang appréciez la Décroissance" (!)
Proc et Ram à 1G: Triple boot W$7 - Lmde GS - #!11 Waldorf
Ram usage 680M 350M 160M
Rapidité OS 60% 80% 100%
Hors ligne
J'oubliai : il faut libnotify-bin (dans les dépôt debian) pour que cela fonctionne. Ou alors tu interdit les notif (dans le fichier de conf)
Patrick
Hors ligne