inital commit of clone of old repo
This commit is contained in:
488
NOVA/usr/local/bin/LxMenuEditor
Executable file
488
NOVA/usr/local/bin/LxMenuEditor
Executable file
@ -0,0 +1,488 @@
|
||||
#!/bin/sh
|
||||
# Author : dave@meyer.LA
|
||||
# Date : 01/01/2011
|
||||
#
|
||||
# LxMenuEditor
|
||||
# Finally, a complete, straightforward, bulletproof menu editor for LXDE
|
||||
#
|
||||
# Dependencies: lxshortcut, zenity
|
||||
|
||||
#Trap to ensure we stay clean
|
||||
clean_up(){
|
||||
unset IFS
|
||||
unset LANG2
|
||||
cd "$HOME/.local/share/applications"
|
||||
rm -f tmpfile*
|
||||
}
|
||||
|
||||
trap 'clean_up' EXIT INT TERM QUIT SIGINT SIGQUIT SIGTERM
|
||||
|
||||
#Preliminaries:
|
||||
clean_up
|
||||
LANG2=`echo $LANG | tr '.' '\t' | awk '{ print $1 }'`
|
||||
export LANG2
|
||||
|
||||
#Functions:
|
||||
SanityCheck(){
|
||||
echo 10
|
||||
#Bar none, the most reliable method to overcome the problems associated with multiple files with spaces is to rename.
|
||||
cd "$HOME/.local/share/applications"
|
||||
IFS=$'\n'
|
||||
for FILE in `ls *.desktop | grep " "` ; do mv "$FILE" `echo $FILE | tr ' ' '_'` ; done
|
||||
unset IFS
|
||||
echo 20
|
||||
#Ensure there are Name= and Name[lang]= tags
|
||||
cd "$HOME/.local/share/applications"
|
||||
for FILE in `ls *.desktop`
|
||||
do NAM=`cat "$FILE" | grep -x ^Name=.* | sed -e 's/.*=//g'`
|
||||
NAML=`cat "$FILE" | grep -x ^Name.$LANG2.=.* | sed -e 's/.*=//g'`
|
||||
if [ "$NAM" ] || [ "$NAML" ]; then
|
||||
if [ "$NAM" ] && [ -z "$NAML" ]; then
|
||||
#Copy Name= to Name[lang]=
|
||||
echo "Name[$LANG2]=${NAM}" >> "$FILE"
|
||||
fi
|
||||
if [ "$NAML" ] && [ -z "$NAM" ]; then
|
||||
#Copy Name[lang]= to Name=
|
||||
echo "Name=${NAML}" >> "$FILE"
|
||||
fi
|
||||
fi
|
||||
if [ -z "$NAML" ] && [ -z "$NAM" ]; then #REM The return status of AND and OR lists is the exit status of the last command executed in the list : * with command1 && command2, command2 is executed only if command1 returns an exit status of zero (true) * with command1 ││ command2, command2 is executed only if command1 returns a non-zero exit status (false)
|
||||
echo "Name=<empty>" >> "$FILE"
|
||||
echo "Name[$LANG2]=<empty>" >> "$FILE"
|
||||
fi
|
||||
done
|
||||
echo 30
|
||||
for FILE in `ls *.desktop`
|
||||
do COM=`cat "$FILE" | grep -x ^Comment=.* | sed -e 's/.*=//g'`
|
||||
COML=`cat "$FILE" | grep -x ^Comment.$LANG2.=.* | sed -e 's/.*=//g'`
|
||||
if [ "$COM" ] || [ "$COML" ]; then
|
||||
if [ "$COM" ] && [ -z "$COML" ]; then
|
||||
#Copy Name= to Name[lang]=
|
||||
echo "Comment[$LANG2]=${COM}" >> "$FILE"
|
||||
fi
|
||||
if [ "$COML" ] && [ -z "$COM" ]; then
|
||||
#Copy Name[lang]= to Name=
|
||||
echo "Comment=${COML}" >> "$FILE"
|
||||
fi
|
||||
fi
|
||||
if [ -z "$COML" ] && [ -z "$COM" ]; then
|
||||
echo "Comment=<empty>" >> "$FILE"
|
||||
echo "Comment[$LANG2]=<empty>" >> "$FILE"
|
||||
fi
|
||||
done
|
||||
echo 40
|
||||
for ME in `grep -L ^Exec= *.desktop` ; do echo "Exec=<empty>" >> "$ME" ; done
|
||||
for MCat in `grep -L ^Categories= *.desktop` ; do echo "Categories=<empty>" >> "$MCat" ; done
|
||||
# All tagged not to show in LXDE get the NoDisplay=true for reliable filtering later
|
||||
for OSI in `grep -H -E -l -x -e 'OnlyShowIn.*' *.desktop | xargs -L50 grep -L -e 'OnlyShowIn=.*LXDE *'`
|
||||
do sed -e '/NoDisplay=.*/d' -e '/^$/ d' -i "$OSI"
|
||||
echo "NoDisplay=true" >> "$OSI"
|
||||
done
|
||||
echo 50
|
||||
|
||||
#Dups
|
||||
cd "$HOME/.local/share/applications"
|
||||
#Remove duplicates
|
||||
for FILE in *.desktop
|
||||
do occ=`grep -c ^Name= "$FILE"`
|
||||
#Non-integer trap.
|
||||
echo "$occ" | grep "[^0-9]" > /dev/null 2>&1
|
||||
echo $occ >tmpfile11 #found this to be req when debugging, go figure.
|
||||
if [ "$?" -eq 1 ]; then
|
||||
return
|
||||
else
|
||||
if [ "$occ" -gt 1 ]; then
|
||||
linetokeep=`grep -m 1 ^Name=.* "$FILE"`
|
||||
sed -e '/^Name=.*/d' -e '/^$/ d' -i "$FILE"
|
||||
echo "$linetokeep" >> "$FILE"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo 60
|
||||
for FILE in *.desktop
|
||||
do occ=`grep -c ^Exec= "$FILE"`
|
||||
#Non-integer trap.
|
||||
echo "$occ" | grep "[^0-9]" > /dev/null 2>&1
|
||||
echo $occ >tmpfile11 #found this to be req when debugging, go figure.
|
||||
if [ "$?" -eq 1 ]; then
|
||||
return
|
||||
else
|
||||
if [ "$occ" -gt 1 ]; then
|
||||
linetokeep=`grep -m 1 ^Exec=.* "$FILE"`
|
||||
sed -e '/^Exec=.*/d' -e '/^$/ d' -i "$FILE"
|
||||
echo "$linetokeep" >> "$FILE"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo 70
|
||||
for FILE in *.desktop
|
||||
do occ=`grep -c ^Comment= "$FILE"`
|
||||
#Non-integer trap.
|
||||
echo "$occ" | grep "[^0-9]" > /dev/null 2>&1
|
||||
echo $occ >tmpfile11 #found this to be req when debugging, go figure.
|
||||
if [ "$?" -eq 1 ]; then
|
||||
return
|
||||
else
|
||||
if [ "$occ" -gt 1 ]; then
|
||||
linetokeep=`grep -m 1 ^Comment=.* "$FILE"`
|
||||
sed -e '/^Comment=.*/d' -e '/^$/ d' -i "$FILE"
|
||||
echo "$linetokeep" >> "$FILE"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo 80
|
||||
for FILE in *.desktop
|
||||
do occ=`grep -c ^Categories= "$FILE"`
|
||||
#Non-integer trap.
|
||||
echo "$occ" | grep "[^0-9]" > /dev/null 2>&1
|
||||
echo $occ >tmpfile11 #found this to be req when debugging, go figure.
|
||||
if [ "$?" -eq 1 ]; then
|
||||
return
|
||||
else
|
||||
if [ "$occ" -gt 1 ]; then
|
||||
linetokeep=`grep -m 1 ^Categories=.* "$FILE"`
|
||||
sed -e '/^Categories=.*/d' -e '/^$/ d' -i "$FILE"
|
||||
echo "$linetokeep" >> "$FILE"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo 90
|
||||
for FILE in *.desktop
|
||||
do occ=`grep -c ^Name.$LANG2.= "$FILE"`
|
||||
#Non-integer trap.
|
||||
echo "$occ" | grep "[^0-9]" > /dev/null 2>&1
|
||||
echo $occ >tmpfile11 #found this to be req when debugging, go figure.
|
||||
if [ "$?" -eq 1 ]; then
|
||||
return
|
||||
else
|
||||
if [ "$occ" -gt 1 ]; then
|
||||
linetokeep=`grep -m 1 ^Name.$LANG2.=.* "$FILE"`
|
||||
sed -e '/Name\['"$LANG2"'\]=.*/d' -e '/^$/ d' -i "$FILE"
|
||||
echo "$linetokeep" >> "$FILE"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo 95
|
||||
for FILE in *.desktop
|
||||
do occ=`grep -c ^Comment.$LANG2.= "$FILE"`
|
||||
#Non-integer trap.
|
||||
echo "$occ" | grep "[^0-9]" > /dev/null 2>&1
|
||||
echo $occ >tmpfile11 #found this to be req when debugging, go figure.
|
||||
if [ "$?" -eq 1 ]; then
|
||||
return
|
||||
else
|
||||
if [ "$occ" -gt 1 ]; then
|
||||
linetokeep=`grep -m 1 ^Comment.$LANG2.=.* "$FILE"`
|
||||
sed -e '/Comment\['"$LANG2"'\]=.*/d' -e '/^$/ d' -i "$FILE"
|
||||
echo "$linetokeep" >> "$FILE"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo 101
|
||||
}
|
||||
|
||||
SanityCheck | zenity --progress --auto-close --auto-kill --width=500 --title="Applying sanity checks and auto-corrections" --text="This essential step ensures LXDE operates error-free. \n\nIt speeds up .desktop file processing and menu access. \n\nPlease, it's worth the wait..."
|
||||
EXIT=$?
|
||||
if [ $EXIT -ne 0 ] ; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
TurnOn(){
|
||||
cd "$HOME/.local/share/applications"
|
||||
#To show comment out:
|
||||
#"NotShowIn" lines that include "LXDE" with a single "#"
|
||||
#"OnlyShowIn" lines that do not include "LXDE" with a single "#"
|
||||
#"Hidden=true" with a single "#"
|
||||
#rm NoDisplay=true
|
||||
for FILE in `echo "$ToTurnOn"` ; do sed '
|
||||
s/NotShowIn.*LXDE/#&/g
|
||||
/^##/s/#//1
|
||||
/LXDE/!s/OnlyShowIn/#&/g
|
||||
/^##/s/#//1
|
||||
s/Hidden=true/#&/g
|
||||
/^##/s/#//1
|
||||
/NoDisplay=.*/d
|
||||
/^$/ d' -i "$HOME/.local/share/applications"/"$FILE" ; done
|
||||
#This may generate a minor error like "Output line too long" . Barnette @ http://www.grymoire.com/Unix/Sed.html#uh-41 considers this a bug, and has reported it to Sun.
|
||||
}
|
||||
|
||||
TurnOff(){
|
||||
cd "$HOME/.local/share/applications"
|
||||
#To hide:
|
||||
#rm "NoDisplay=" and prevent duplicates
|
||||
#add "NoDisplay=true"
|
||||
for FILE in `echo "$ToTurnOff"` ; do sed -e '/NoDisplay=.*/d' -e '/^$/ d' -i "$HOME/.local/share/applications"/"$FILE" ; done
|
||||
for FILE in `echo "$ToTurnOff"` ; do echo "NoDisplay=true" >> "$HOME/.local/share/applications"/"$FILE" ; done
|
||||
}
|
||||
|
||||
MainMenuLoop(){
|
||||
while :
|
||||
do
|
||||
|
||||
#Choices choices choices...
|
||||
chose=`zenity --list --height="260" --width="250" --title="LXDE Menu Editor" --text="What do you want to do? \n\nClick <b>CANCEL</b> to <b>EXIT</b>." --column="" "Create a launcher" "Edit a launcher" "Show or Hide launcher(s)" "Delete existing launcher(s)" "Override system-wide launchers"`
|
||||
#Clicking CANCEL or empty OK exits the script
|
||||
EXIT=$?
|
||||
if [ $EXIT -ne 0 ] ; then
|
||||
exit 0
|
||||
fi
|
||||
if [ -z "$chose" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$chose" = "Create a launcher" ]; then
|
||||
DefineName(){
|
||||
itemname=`zenity --entry --text="Enter a name (example: lxterminal) \n\nNote that capital letters are filed before lower case letters. \n\n(This name is only for the *.desktop file.)"`
|
||||
#Clicking CANCEL loops back, OK asks again
|
||||
EXIT=$?
|
||||
if [ $EXIT -ne 0 ] ; then
|
||||
MainMenuLoop
|
||||
else
|
||||
FileExists
|
||||
fi
|
||||
}
|
||||
|
||||
FileExists(){
|
||||
cd "$HOME/.local/share/applications"
|
||||
if [ -e "$itemname".desktop ]; then
|
||||
zenity --question --title="Warning" --width="200" --text="${itemname}.desktop already exists. \n\n<b>Overwrite?</b>"
|
||||
#Clicking CANCEL loops back, OK continues
|
||||
EXIT=$?
|
||||
if [ $EXIT -ne 0 ] ; then
|
||||
DefineName
|
||||
else
|
||||
Create
|
||||
fi
|
||||
else
|
||||
Create
|
||||
fi
|
||||
}
|
||||
|
||||
Create(){
|
||||
if [ "$itemname" ]; then
|
||||
cd "$HOME/.local/share/applications"
|
||||
lxshortcut -o "$itemname".desktop
|
||||
#Sanity check: test if the new launcher is more than an empty file
|
||||
SANCHK=`du -b "$itemname".desktop | awk '{ print $1 }'`
|
||||
#If no then rm and notify of cancelation before returning to main menu
|
||||
if [ "$SANCHK" -lt 110 ]; then
|
||||
rm "$HOME/.local/share/applications"/"$itemname".desktop
|
||||
zenity --info --title="Warning" --width="200" --text="${itemname}.desktop was empty and was therefore DISCARDED. \n\n\nPlease try again."
|
||||
else
|
||||
select=`zenity --list --height="330" --width="400" --text="Choose the LXMenu Section(s) to file ${itemname}.desktop under." --checklist --multiple --separator=";" --hide-column=2 --print-column=2 --column="" --column="Returned Output" --column="Category" FALSE Utility Accessories FALSE Graphics Graphics FALSE Network Internet FALSE Office Office TRUE Other Other FALSE AudioVideo "Sound & Video" FALSE System "System Tools" FALSE Accessibility "Universal Access" FALSE Settings "System -> Preferences" FALSE SystemSetup "System -> Administration"`
|
||||
#Failure to select at least one checkmark results in the Categories tag being set to Other
|
||||
if `grep -qw "^Categories=;" "$itemname".desktop` ; then
|
||||
sed -e '/^Categories=.*/d' -e '/^$/ d' -i "$itemname".desktop
|
||||
echo "Categories=Other;" >> "$HOME/.local/share/applications"/"$itemname".desktop
|
||||
zenity --info --title="Note" --width="200" --text="${itemname}.desktop filed under <i>Other</i> by default."
|
||||
else
|
||||
echo "Categories=${select};" >> "$HOME/.local/share/applications"/"$itemname".desktop
|
||||
fi
|
||||
#Sanity Check: test if the new launcher is more than an empty file
|
||||
SANCHK=`du -b "$itemname".desktop | awk '{ print $1 }'`
|
||||
#If no then delete and notify of cancelation before returning to main menu
|
||||
if [ "$SANCHK" -lt 123 ]; then
|
||||
rm "$HOME/.local/share/applications"/"$itemname".desktop
|
||||
zenity --info --title="Warning" --width="200" --text="${itemname}.desktop was empty and was therefore DISCARDED. \n\n\nPlease try again."
|
||||
fi
|
||||
fi
|
||||
#Failure to select a file yet clicking OK
|
||||
elif [ !"$itemname" ]; then
|
||||
zenity --question --title="Note" --width="200" --text="Please enter a name."
|
||||
EXIT=$?
|
||||
if [ $EXIT -ne 0 ] ; then
|
||||
MainMenuLoop
|
||||
else
|
||||
DefineName
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
DefineName
|
||||
#rm spaces in new name.
|
||||
cd "$HOME/.local/share/applications"
|
||||
IFS=$'\n'
|
||||
for FILE in `ls *.desktop | grep " "` ; do mv "$FILE" `echo $FILE | tr ' ' '_'` ; done
|
||||
unset IFS
|
||||
fi
|
||||
# Loop back to the main menu to continue
|
||||
|
||||
if [ "$chose" = "Edit a launcher" ]; then
|
||||
#Rescan to reflect changes since the last operation
|
||||
scan_OFF=`grep -H -E -l -x -e 'NoDisplay=true' -e 'Hidden=true' -e 'NotShowIn.*LXDE.*' *.desktop`
|
||||
scan_ON=`ls *.desktop | grep -v "$scan_OFF"`
|
||||
scan_ON_displayname=`echo "$scan_ON" | xargs grep -x ^Name.$LANG2.=.* | sed -e 's/.*=//g'`
|
||||
scan_ON_command=`echo "$scan_ON" | xargs grep -x ^Exec=.* | sed -e 's/.*=//g'`
|
||||
scan_ON_comment=`echo "$scan_ON" | xargs grep -x ^Comment.$LANG2.=.* | sed -e 's/.*=//g'`
|
||||
scan_ON_categories=`echo "$scan_ON" | xargs grep -x ^Categories=.* | sed -e 's/.*=//g'`
|
||||
#Format to suit zenity's rigidly anal --list input requirements
|
||||
echo "${scan_ON_displayname}" | sed -e 's/^$/<empty>/g' > tmpfile1
|
||||
echo "${scan_ON}" > tmpfile2
|
||||
echo "${scan_ON_command}" | sed 's/^$/<empty>/g' > tmpfile3
|
||||
echo "${scan_ON_comment}" | sed 's/^$/<empty>/g' > tmpfile4
|
||||
echo "${scan_ON_categories}" | sed 's/^$/<empty>/g' > tmpfile5
|
||||
zlist=`pr -m -t -s"|" tmpfile1 tmpfile2 tmpfile3 tmpfile4 tmpfile5 | awk '{print $0}' | sed -e 's/|/\n/g'`
|
||||
|
||||
IFS=$'\n'
|
||||
selected=`zenity --list --height="700" --width="1300" --title="Launchers currently showing" --text="Select the launcher to <b>EDIT</b>" --print-column=2 --column="Display Name" --column=Filename --column=Command --column="Tooltip Comment" --column=Categories $zlist`
|
||||
unset IFS
|
||||
#Clicking CANCEL loops back to main menu
|
||||
EXIT=$?
|
||||
if [ $EXIT -ne 0 ] ; then
|
||||
MainMenuLoop
|
||||
fi
|
||||
if [ $selected ]; then
|
||||
#Test if Categories exist, if not asign to Other
|
||||
NOCAT=`grep -L ^Categories= $selected`
|
||||
if [ "$NOCAT" = $selected ]; then
|
||||
echo "Categories=Other;" >> "$HOME/.local/share/applications"/$selected
|
||||
fi
|
||||
lxshortcut -i $selected
|
||||
#ensure default tags correspond to language-set tags for Comment= tags
|
||||
TAG1=`grep "^Name.$LANG2.=.*" "$HOME/.local/share/applications"/"$selected" | sed 's/^Name.*=//'`
|
||||
if [ "$TAG1" ]; then
|
||||
#rm Name= line
|
||||
sed -e '/^Name=/d' -e '/^$/ d' -i "$HOME/.local/share/applications"/"$selected"
|
||||
#copy Name[en_US]= tag to Name= tag
|
||||
echo "Name=${TAG1}" >> "$HOME/.local/share/applications"/"$selected"
|
||||
fi
|
||||
TAG2=`grep "^Comment.$LANG2.=.*" "$HOME/.local/share/applications"/"$selected" | sed 's/^Comment.*=//'`
|
||||
if [ "$TAG2" ]; then
|
||||
#rm Comment= line
|
||||
sed -e '/^Comment=/d' -e '/^$/ d' -i "$HOME/.local/share/applications"/"$selected"
|
||||
#copy Comment[en_US]= tag to Comment= tag
|
||||
echo "Comment=${TAG2}" >> "$HOME/.local/share/applications"/"$selected"
|
||||
fi
|
||||
BEFORE=`grep Categories $selected`
|
||||
if `grep Categories $selected | grep -qw Utility` ; then a1=TRUE ; else a1=FALSE ; fi
|
||||
if `grep Categories $selected | grep -qw Graphics` ; then b1=TRUE ; else b1=FALSE ; fi
|
||||
if `grep Categories $selected | grep -qw Network` ; then c1=TRUE ; else c1=FALSE ; fi
|
||||
if `grep Categories $selected | grep -qw Office` ; then d1=TRUE ; else d1=FALSE ; fi
|
||||
if `grep Categories $selected | grep -qw Other` ; then e1=TRUE ; else e1=FALSE ; fi
|
||||
if `grep Categories $selected | grep -qw AudioVideo` ; then f1=TRUE ; else f1=FALSE ; fi
|
||||
if `grep Categories $selected | grep -qw System` ; then g1=TRUE ; else g1=FALSE ; fi
|
||||
if `grep Categories $selected | grep -qw Accessibility` ; then h1=TRUE ; else h1=FALSE ; fi
|
||||
if `grep Categories $selected | grep -qw Settings` ; then i1=TRUE ; else i1=FALSE ; fi
|
||||
if `grep Categories $selected | grep -qw SystemSetup` ; then j1=TRUE ; else j1=FALSE ; fi
|
||||
select=`zenity --list --height="330" --width="400" --text="Choose the LXMenu Section(s) to file $selected under." --checklist --multiple --separator=";" --hide-column=2 --print-column=2 --column="" --column="Returned Output" --column="Category" $a1 Utility Accessories $b1 Graphics Graphics $c1 Network Internet $d1 Office Office $e1 Other Other $f1 AudioVideo "Sound & Video" $g1 System "System Tools" $h1 Accessibility "Universal Access" $i1 Settings "System -> Preferences" $j1 SystemSetup "System -> Administration"`
|
||||
EXIT=$?
|
||||
if [ $EXIT -ne 0 ] ; then
|
||||
AFTER="$BEFORE"
|
||||
else
|
||||
AFTER=`echo "Categories=${select};"`
|
||||
fi
|
||||
if [ "$BEFORE" != "$AFTER" ]; then
|
||||
sed -e '/^Categories=.*/d' -i $selected
|
||||
echo "Categories=${select};" >> "$HOME/.local/share/applications"/$selected
|
||||
fi
|
||||
#Failure to select at least one checkmark results in the Categories tag being set to Other
|
||||
if `grep -qw "^Categories=;" $selected` ; then
|
||||
sed -e '/^Categories=.*/d' -i $selected
|
||||
echo "Categories=Other;" >> "$HOME/.local/share/applications"/$selected
|
||||
zenity --info --title="Note" --width="200" --text="$selected filed under <i>Other</i> by default."
|
||||
fi
|
||||
#Failure to select a file yet clicking OK
|
||||
elif [ !"$selected" ]; then
|
||||
zenity --info --title="Note" --width="200" --text="No launcher selected to edit."
|
||||
fi
|
||||
fi
|
||||
#Loop back to the main menu to continue
|
||||
|
||||
if [ "$chose" = "Show or Hide launcher(s)" ]; then
|
||||
#Rescan to reflect changes since the last operation
|
||||
scan_OFF=`grep -H -E -l -x -e 'NoDisplay=true' -e 'Hidden=true' -e 'NotShowIn.*LXDE.*' *.desktop`
|
||||
scan_ON=`ls *.desktop | grep -v "$scan_OFF"`
|
||||
scan_ON_displayname=`echo "$scan_ON" | xargs grep -x ^Name.$LANG2.=.* | sed -e 's/.*=//g'`
|
||||
scan_ON_command=`echo "$scan_ON" | xargs grep -x ^Exec=.* | sed -e 's/.*=//g'`
|
||||
scan_ON_comment=`echo "$scan_ON" | xargs grep -x ^Comment.$LANG2.=.* | sed -e 's/.*=//g'`
|
||||
#Format to suit zenity's rigidly anal --list input requirements
|
||||
echo "${scan_ON_displayname}" | sed -e 's/^$/<empty>/g' -e 's/^/TRUE|/g' > tmpfile1
|
||||
echo "${scan_ON}" > tmpfile2
|
||||
echo "${scan_ON_command}" | sed 's/^$/<empty>/g' > tmpfile3
|
||||
echo "${scan_ON_comment}" | sed 's/^$/<empty>/g' > tmpfile4
|
||||
|
||||
scan_OFF_displayname=`echo "$scan_OFF" | xargs grep -x ^Name.$LANG2.=.* | sed -e 's/.*=//g'`
|
||||
scan_OFF_command=`echo "$scan_OFF" | xargs grep -x ^Exec=.* | sed -e 's/.*=//g'`
|
||||
scan_OFF_comment=`echo "$scan_OFF" | xargs grep -x ^Comment.$LANG2.=.* | sed -e 's/.*=//g'`
|
||||
#Format to suit zenity's rigidly anal --list input requirements
|
||||
echo "${scan_OFF_displayname}" | sed -e 's/^$/<empty>/g' -e 's/^/FALSE|/g' > tmpfile5
|
||||
echo "${scan_OFF}" > tmpfile6
|
||||
echo "${scan_OFF_command}" | sed 's/^$/<empty>/g' > tmpfile7
|
||||
echo "${scan_OFF_comment}" | sed 's/^$/<empty>/g' > tmpfile8
|
||||
zlist1=`pr -m -t -s"|" tmpfile1 tmpfile2 tmpfile3 tmpfile4 | awk '{print $0}' | sed -e 's/|/\n/g'`
|
||||
zlist2=`pr -m -t -s"|" tmpfile5 tmpfile6 tmpfile7 tmpfile8 | awk '{print $0}' | sed -e 's/|/\n/g'`
|
||||
|
||||
IFS=$'\n'
|
||||
selected2=`zenity --list --checklist --height="700" --width="1300" --title="All launchers" --text="Select the launcher(s) to <b>SHOW</b>" --print-column=3 --column="Sort" --column="Display Name" --column=Filename --column=Command --column="Tooltip Comment" $zlist1 $zlist2`
|
||||
unset IFS
|
||||
#Clicking Cancel or selecting nothing yet clicking OK loops the script back to the main menu
|
||||
EXIT=$?
|
||||
if [ $EXIT -eq 0 -a "$selected2" ] ; then
|
||||
echo "$selected2" | sed 's/|/\n/g' > tmpfile9
|
||||
ToTurnOn=`diff -T tmpfile2 tmpfile9 | grep ">".* | awk '{print $2}'`
|
||||
ToTurnOff=`diff -T tmpfile2 tmpfile9 | grep "<".* | awk '{print $2}'`
|
||||
if [ "$ToTurnOn" ]; then
|
||||
TurnOn
|
||||
fi
|
||||
if [ "$ToTurnOff" ]; then
|
||||
TurnOff
|
||||
fi
|
||||
else
|
||||
MainMenuLoop
|
||||
fi
|
||||
fi
|
||||
#Loop back to the main menu to continue
|
||||
|
||||
if [ "$chose" = "Delete existing launcher(s)" ]; then
|
||||
scan_ALL=`ls "$HOME/.local/share/applications" | grep .desktop | grep -v wine-extension | grep -v userapp` #exclude userapp and wine-extension
|
||||
selected3=`zenity --list --height="600" --width="400" --text="Select launcher(s) to <b>DELETE</b> \n-->Use ctrl+ or shift+click for multiple selection" --multiple --separator=$'\n' --print-column=ALL --column="All launchers" $scan_ALL`
|
||||
#Clicking Cancel loops the script back to the main menu
|
||||
EXIT=$?
|
||||
if [ $EXIT -ne 0 ] ; then
|
||||
MainMenuLoop
|
||||
fi
|
||||
if [ "$selected3" ]; then
|
||||
zenity --question --title="Warning" --text="You are about to permanently <b>REMOVE</b>: \n\n$selected3. \n\nDo you want to proceed? \n\nIf you're unsure: hide DON'T remove."
|
||||
CONF=$?
|
||||
if [ $CONF -eq 0 ] ; then
|
||||
cd "$HOME/.local/share/applications"
|
||||
rm $selected3
|
||||
zenity --info --title="Info" --text="$selected3 \n\n...permanently REMOVED"
|
||||
fi
|
||||
#Failure to select a file yet clicking OK
|
||||
elif [ !"$selected3" ]; then
|
||||
zenity --info --title="Note" --width="200" --text="Nothing was deleted. \n\nPlease select at least one launcher and press OK."
|
||||
fi
|
||||
fi
|
||||
#Loop back to the main menu to continue
|
||||
|
||||
if [ "$chose" = "Override system-wide launchers" ]; then
|
||||
zenity --question --width=580 --title="Warning" --text="This will import root launchers so they can be configured for this user. \n\nAs a nice side-effect, it will also speed up rendering of the menu in lxpanel. \n\nIt is recommended to <b>DO THIS ONCE</b>. \n\nImporting will NOT overwrite user-configured launchers. \n\nDo you want to proceed?"
|
||||
CONF2=$?
|
||||
if [ $CONF2 -eq 0 ] ; then
|
||||
cd "$HOME/.local/share/applications"
|
||||
zenity --info --width=580 --title="Note" --text='Find the directory that contains the *.desktop files you wish to gain control of. Sub-directories will NOT be imported. \n\nKDE users BEWARE: You must checkmark -Only Show In KDE- using the KDE menu editor (ie: kmenuedit) or your menus will show duplicates. \n\nThis operation is much quicker and easier through the CLI.\nOpen a terminal in the KDE directory containing the .desktop files and usually found in /usr/share/applications. As root issue the following: \n\n(Use Copy-Paste but replace your-kde-directory.)\n\nfor FILE in `grep -L ^OnlyShowIn= *.desktop` ; do echo "OnlyShowIn=KDE;" >> /usr/share/applications/your-kde-directory/"$FILE" ; done'
|
||||
rootDIR=`zenity --file-selection --title="Confirmation request" --directory --filename=/usr/share/applications/`
|
||||
echo $rootDIR
|
||||
EXIT=$?
|
||||
if [ $EXIT -ne 0 ] ; then
|
||||
MainMenuLoop
|
||||
fi
|
||||
if [ "$rootDIR" ]; then
|
||||
cd $rootDIR
|
||||
for launcher in `ls *.desktop` ; do cp -n $rootDIR/"$launcher" "$HOME/.local/share/applications/"; done
|
||||
#add any default changes to set after ";" and before "done" ie: echo "OnlyShowIn=LXDE;" >> "/$HOME/.local/share/applications/$launcher;
|
||||
cd "$HOME/.local/share/applications"
|
||||
fi
|
||||
fi
|
||||
SanityCheck | zenity --progress --auto-close --auto-kill --width=500 --title="Applying sanity checks and auto-corrections" --text="This essential step ensures LXDE operates error-free. \n\nIt speeds up .desktop file processing and menu access. \n\nPlease, it's worth the wait..."
|
||||
EXIT=$?
|
||||
if [ $EXIT -ne 0 ] ; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
MainMenuLoop
|
||||
clean_up
|
||||
exit 0
|
1
NOVA/usr/local/bin/ajaxlife
Executable file
1
NOVA/usr/local/bin/ajaxlife
Executable file
@ -0,0 +1 @@
|
||||
surf beast:9000
|
18
NOVA/usr/local/bin/appremove-testy
Executable file
18
NOVA/usr/local/bin/appremove-testy
Executable file
@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
declare -A usage
|
||||
|
||||
exec 0< <(pacman -Ql | grep bin)
|
||||
|
||||
while read pkg binary; do
|
||||
lastused=$(stat -c '%X' "$binary")
|
||||
if [[ -z ${usage[$pkg]} ]] || (( lastused > ${usage[$pkg]} )); then
|
||||
usage[$pkg]=$lastused
|
||||
fi
|
||||
done
|
||||
|
||||
for key in "${!usage[@]}"; do
|
||||
printf '%s\t%s\n' "${usage[$key]}" "$key"
|
||||
done | sort -rn | while read time pkg; do
|
||||
printf '%(%c)T\t%s\n' "$time" "$pkg"
|
||||
done
|
54
NOVA/usr/local/bin/appremove-testy2
Executable file
54
NOVA/usr/local/bin/appremove-testy2
Executable file
@ -0,0 +1,54 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import os
|
||||
import time
|
||||
import re
|
||||
import sys
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
def list_unused_packages(days):
|
||||
'''
|
||||
list packages not acessed in arch for n days
|
||||
it checks if any of files in package were acessed before n days,
|
||||
if not add it to list of unused_packages.
|
||||
'''
|
||||
lt_time = datetime.now() - timedelta(days=days)
|
||||
epoch_lt_time = time.mktime(lt_time.timetuple())
|
||||
|
||||
# get list of installed packages
|
||||
installed_packages = os.popen('pacman -Q').read().split('\n')[:-1]
|
||||
|
||||
|
||||
unused_packages = []
|
||||
for package in installed_packages:
|
||||
# get files of package
|
||||
files = os.popen('pacman -Ql ' + re.match('^.* ', package).group())
|
||||
files = files.read().split('\n')[:-1]
|
||||
acessed = False
|
||||
for path in files:
|
||||
valid_file = re.search(' (.*\w)$', path) # exclude directories
|
||||
if valid_file:
|
||||
try:
|
||||
atime = os.path.getatime(valid_file.group(1))
|
||||
if atime > epoch_lt_time:
|
||||
acessed = True
|
||||
break
|
||||
except OSError:
|
||||
# broken symlink?
|
||||
pass
|
||||
if not acessed:
|
||||
unused_packages.append(package)
|
||||
|
||||
return unused_packages
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
unused_packages = list_unused_packages(int(sys.argv[1]))
|
||||
print ('\n'.join(unused_packages))
|
||||
if unused_packages:
|
||||
print ('packages not used for at least {0} days'.format(sys.argv[1]))
|
||||
else:
|
||||
print ('all packages were acessed.')
|
||||
except IndexError:
|
||||
print ('usage: unused_packages days')
|
2
NOVA/usr/local/bin/archage
Executable file
2
NOVA/usr/local/bin/archage
Executable file
@ -0,0 +1,2 @@
|
||||
head -n1 /var/log/pacman.log
|
||||
echo $(($(($(date +%s) - $(date -d "$(head -1 /var/log/pacman.log | cut -d ' ' -f 1,2 | tr -d '[]')" +%s))) / 86400)) days
|
34
NOVA/usr/local/bin/colorspacman
Executable file
34
NOVA/usr/local/bin/colorspacman
Executable file
@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# ANSI color scheme script featuring Space Invaders
|
||||
#
|
||||
# Original: http://crunchbanglinux.org/forums/post/126921/#p126921
|
||||
# Modified by lolilolicon
|
||||
#
|
||||
|
||||
f=3 b=4
|
||||
for j in f b; do
|
||||
for i in {0..7}; do
|
||||
printf -v $j$i %b "\e[${!j}${i}m"
|
||||
done
|
||||
done
|
||||
bld=$'\e[1m'
|
||||
rst=$'\e[0m'
|
||||
|
||||
cat << EOF
|
||||
|
||||
$f3 ▄███████▄ $f1 ▄██████▄ $f2 ▄██████▄ $f4 ▄██████▄ $f5 ▄██████▄ $f6 ▄██████▄
|
||||
$f3▄█████████▀▀ $f1▄$f7█▀█$f1██$f7█▀█$f1██▄ $f2▄$f7█▀█$f2██$f7█▀█$f2██▄ $f4▄$f7█▀█$f4██$f7█▀█$f4██▄ $f5▄$f7█▀█$f5██$f7█▀█$f5██▄ $f6▄$f7█▀█$f6██$f7█▀█$f6██▄
|
||||
$f3███████▀ $f1█$f7▄▄█$f1██$f7▄▄█$f1███ $f2█$f7▄▄█$f2██$f7▄▄█$f2███ $f4█$f7▄▄█$f4██$f7▄▄█$f4███ $f5█$f7▄▄█$f5██$f7▄▄█$f5███ $f6█$f7▄▄█$f6██$f7▄▄█$f6███
|
||||
$f3███████▄ $f1████████████ $f2████████████ $f4████████████ $f5████████████ $f6████████████
|
||||
$f3▀█████████▄▄ $f1██▀██▀▀██▀██ $f2██▀██▀▀██▀██ $f4██▀██▀▀██▀██ $f5██▀██▀▀██▀██ $f6██▀██▀▀██▀██
|
||||
$f3 ▀███████▀ $f1▀ ▀ ▀ ▀ $f2▀ ▀ ▀ ▀ $f4▀ ▀ ▀ ▀ $f5▀ ▀ ▀ ▀ $f6▀ ▀ ▀ ▀
|
||||
|
||||
$bld$f3 ▄███████▄ $f1 ▄██████▄ $f2 ▄██████▄ $f4 ▄██████▄ $f5 ▄██████▄ $f6 ▄██████▄
|
||||
$bld$f3▄█████████▀▀ $f1▄$f7█▀█$f1██$f7█▀█$f1██▄ $f2▄$f7█▀█$f2██$f7█▀█$f2██▄ $f4▄$f7█▀█$f4██$f7█▀█$f4██▄ $f5▄$f7█▀█$f5██$f7█▀█$f5██▄ $f6▄$f7█▀█$f6██$f7█▀█$f6██▄
|
||||
$bld$f3███████▀ $f1█$f7▄▄█$f1██$f7▄▄█$f1███ $f2█$f7▄▄█$f2██$f7▄▄█$f2███ $f4█$f7▄▄█$f4██$f7▄▄█$f4███ $f5█$f7▄▄█$f5██$f7▄▄█$f5███ $f6█$f7▄▄█$f6██$f7▄▄█$f6███
|
||||
$bld$f3███████▄ $f1████████████ $f2████████████ $f4████████████ $f5████████████ $f6████████████
|
||||
$bld$f3▀█████████▄▄ $f1██▀██▀▀██▀██ $f2██▀██▀▀██▀██ $f4██▀██▀▀██▀██ $f5██▀██▀▀██▀██ $f6██▀██▀▀██▀██
|
||||
$bld$f3 ▀███████▀ $f1▀ ▀ ▀ ▀ $f2▀ ▀ ▀ ▀ $f4▀ ▀ ▀ ▀ $f5▀ ▀ ▀ ▀ $f6▀ ▀ ▀ ▀
|
||||
|
||||
EOF
|
1
NOVA/usr/local/bin/colortest
Executable file
1
NOVA/usr/local/bin/colortest
Executable file
@ -0,0 +1 @@
|
||||
(x=`tput op` y=`printf %80s`;for i in {0..256};do o=00$i;echo -e ${o:${#o}-3:3} `tput setaf $i;tput setab $i`${y// /=}$x;done)
|
2
NOVA/usr/local/bin/depremove
Executable file
2
NOVA/usr/local/bin/depremove
Executable file
@ -0,0 +1,2 @@
|
||||
sudo pacman -Rsn $(pacman -Qqdt)
|
||||
|
1
NOVA/usr/local/bin/duckduckgo
Executable file
1
NOVA/usr/local/bin/duckduckgo
Executable file
@ -0,0 +1 @@
|
||||
surf duckduckgo.com
|
248
NOVA/usr/local/bin/gimpbox
Executable file
248
NOVA/usr/local/bin/gimpbox
Executable file
@ -0,0 +1,248 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: UTF-8 -*-
|
||||
'''gimpbox.py
|
||||
|
||||
启动单窗口的 Gimp
|
||||
|
||||
用法:
|
||||
python gimpbox.py
|
||||
或
|
||||
gimp & sleep 5s ; python gimpbox.py
|
||||
|
||||
'''
|
||||
|
||||
import gtk, gobject
|
||||
import wnck
|
||||
import time
|
||||
import os
|
||||
import sys
|
||||
|
||||
import gettext
|
||||
gettext.install('gimp20')
|
||||
STR_GIMP = _('GNU Image Manipulation Program') or 'GNU 图像处理程序'
|
||||
STR_TOOLBOX = _('Toolbox') or '工具箱'
|
||||
STR_LAYER = _('Layer') or '图层'
|
||||
|
||||
def get_screenshot_thumb(drawable, width=32, height=32):
|
||||
w, h = drawable.get_size()
|
||||
## gimp 图像窗口截图时减去菜单栏等非图像区域
|
||||
x = 15
|
||||
y = 45
|
||||
w = w - x
|
||||
h = h - y - 32
|
||||
screenshot = gtk.gdk.Pixbuf.get_from_drawable(
|
||||
gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, w, h),
|
||||
drawable,
|
||||
gtk.gdk.colormap_get_system(),
|
||||
x, y, 0, 0, w, h)
|
||||
#screenshot.save(filename, 'png')
|
||||
if not screenshot:
|
||||
return None
|
||||
return screenshot.scale_simple(width, height, gtk.gdk.InterpType(2))
|
||||
|
||||
class mainwindow:
|
||||
'''主窗口
|
||||
'''
|
||||
def __init__(self, create = True, accel_group = None, tooltips = None):
|
||||
'''建立主窗口和布局
|
||||
'''
|
||||
|
||||
self.mainwindow = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
||||
self.mainwindow.set_icon_name("gimp")
|
||||
self.mainwindow.set_default_size(700, 500)
|
||||
self.mainwindow.maximize()
|
||||
self.mainwindow.set_title(_("GimpBox"))
|
||||
#self.mainwindow.set_position(gtk.WIN_POS_CENTER)
|
||||
self.mainwindow.show()
|
||||
self.mainwindow.connect("delete_event", self.quit)
|
||||
|
||||
self.screen = wnck.screen_get_default()
|
||||
|
||||
self.hpaned1 = gtk.HPaned()
|
||||
self.hpaned1.set_position(180)
|
||||
self.hpaned1.show()
|
||||
|
||||
self.toolboxarea = gtk.Socket()
|
||||
self.toolboxarea.show()
|
||||
self.hpaned1.pack1(self.toolboxarea, False, True)
|
||||
|
||||
self.hpaned2 = gtk.HPaned()
|
||||
self.hpaned2.show()
|
||||
|
||||
self.notebook = gtk.Notebook()
|
||||
self.notebook.set_tab_pos(gtk.POS_BOTTOM)
|
||||
self.notebook.popup_enable()
|
||||
self.notebook.set_scrollable(True)
|
||||
self.notebook.show()
|
||||
|
||||
self.hpaned2.pack1(self.notebook, False, True)
|
||||
|
||||
self.miscboxarea = gtk.Socket()
|
||||
self.miscboxarea.show()
|
||||
self.hpaned2.pack2(self.miscboxarea, False, False)
|
||||
|
||||
self.hpaned1.pack2(self.hpaned2, True, True)
|
||||
|
||||
self.mainwindow.add(self.hpaned1)
|
||||
|
||||
gobject.idle_add(self.start)
|
||||
#self.toolboxarea.connect('realize', self.start)
|
||||
|
||||
self.mainwindow.show_all()
|
||||
pass
|
||||
|
||||
def start(self, *args):
|
||||
'''开始处理
|
||||
'''
|
||||
self.hpaned2.set_position(self.hpaned2.get_allocation()[2] - 180)
|
||||
self.query_windows()
|
||||
gobject.timeout_add(2000, self.update_thumb)
|
||||
pass
|
||||
|
||||
def _on_window_open(self, screen, wnck_window):
|
||||
'''新窗口事件
|
||||
'''
|
||||
gobject.timeout_add(2000, self.proc_window, wnck_window)
|
||||
pass
|
||||
|
||||
def proc_window(self, wnck_window, *args):
|
||||
'''挑选窗口
|
||||
'''
|
||||
if not wnck_window.get_application():
|
||||
return
|
||||
if wnck_window.get_application().get_icon_name() != STR_GIMP:
|
||||
return
|
||||
if wnck_window.get_window_type() == wnck.WINDOW_UTILITY:
|
||||
if wnck_window.get_icon_name().startswith(STR_TOOLBOX):
|
||||
self._add_wnck_window_to_drawingarea(wnck_window, self.toolboxarea)
|
||||
pass
|
||||
elif STR_LAYER in wnck_window.get_icon_name():
|
||||
self._add_wnck_window_to_drawingarea(wnck_window, self.miscboxarea)
|
||||
pass
|
||||
pass
|
||||
elif wnck_window.get_window_type() == wnck.WINDOW_NORMAL:
|
||||
if wnck_window.get_icon_name().startswith('GNU') \
|
||||
or wnck_window.get_icon_name().endswith('GIMP') \
|
||||
or wnck_window.get_icon_name().endswith('GNU'):
|
||||
self.add_wnck_window_to_tab(wnck_window)
|
||||
pass
|
||||
pass
|
||||
pass
|
||||
|
||||
def query_windows(self):
|
||||
'''遍历现有窗口
|
||||
'''
|
||||
for w in self.screen.get_windows_stacked():
|
||||
gobject.timeout_add(500, self.proc_window, w)
|
||||
pass
|
||||
if not self.tabs:
|
||||
if sys.argv[1:]:
|
||||
os.popen('(sleep 0.5 ; gimp %s & ) &' % (' '.join([ '"%s"' % i.replace('"', '\\"') for i in sys.argv[1:] ])))
|
||||
pass
|
||||
else:
|
||||
os.popen('(sleep 0.5 ; gimp & ) &')
|
||||
pass
|
||||
pass
|
||||
self.screen.connect('window-opened', self._on_window_open)
|
||||
pass
|
||||
|
||||
def _on_add_wnck_window_to_drawingarea(self, widget, wnck_window, drawingarea=None):
|
||||
self._add_wnck_window_to_drawingarea(wnck_window, drawingarea)
|
||||
pass
|
||||
|
||||
def _add_wnck_window_to_drawingarea(self, wnck_window, drawingarea=None):
|
||||
'''真正将窗口曳入标签
|
||||
'''
|
||||
drawingarea.wnck_window = wnck_window
|
||||
return drawingarea.add_id(wnck_window.get_xid())
|
||||
|
||||
def on_tab_window_name_change(self, wnck_window, drawingarea):
|
||||
'''处理窗口标题
|
||||
'''
|
||||
name = wnck_window.get_name()
|
||||
drawingarea.tabmenu.set_text(name)
|
||||
pass
|
||||
|
||||
def on_tab_window_icon_change(self, wnck_window, drawingarea):
|
||||
'''处理窗口图标
|
||||
'''
|
||||
icon = wnck_window.get_icon()
|
||||
drawingarea.tabimage.set_from_pixbuf(icon)
|
||||
pass
|
||||
|
||||
def update_thumb(self):
|
||||
'''更新标签栏缩略图
|
||||
'''
|
||||
if self.notebook.get_n_pages():
|
||||
box = self.notebook.get_nth_page( self.notebook.get_current_page() )
|
||||
if not box.window:
|
||||
return True
|
||||
pixbuf = get_screenshot_thumb(box.window, 48, 48)
|
||||
if not pixbuf:
|
||||
return True
|
||||
img = self.notebook.get_tab_label(box)
|
||||
if img.get_pixbuf() != pixbuf:
|
||||
img.set_from_pixbuf(pixbuf)
|
||||
img.show()
|
||||
pass
|
||||
pass
|
||||
return True
|
||||
|
||||
def _tab_remove(self, drawingarea):
|
||||
'''当标签页有窗口关闭
|
||||
'''
|
||||
box = drawingarea.parent
|
||||
self.notebook.remove(box)
|
||||
wnck_window = drawingarea.wnck_window
|
||||
if wnck_window in self.tabs:
|
||||
del self.tabs[wnck_window]
|
||||
pass
|
||||
if not self.notebook.get_n_pages():
|
||||
self.quit()
|
||||
pass
|
||||
pass
|
||||
|
||||
tabs = {}
|
||||
def add_wnck_window_to_tab(self, wnck_window):
|
||||
'''将窗口添加到标签
|
||||
'''
|
||||
notebook = self.notebook
|
||||
drawingarea = gtk.Socket()
|
||||
drawingarea.show()
|
||||
drawingarea.connect('realize', self._on_add_wnck_window_to_drawingarea, wnck_window, drawingarea)
|
||||
drawingarea.connect('plug-removed', self._tab_remove)
|
||||
tabimage = gtk.Image()
|
||||
tabimage.set_from_pixbuf(wnck_window.get_icon())
|
||||
tabimage.set_padding(0, 0)
|
||||
tabimage.show()
|
||||
tabmenu = gtk.Label(wnck_window.get_name())
|
||||
|
||||
box = gtk.Viewport()
|
||||
box.add(drawingarea)
|
||||
box.show()
|
||||
|
||||
box.set_flags(gtk.CAN_FOCUS)
|
||||
|
||||
drawingarea.box = box
|
||||
drawingarea.tabimage = tabimage
|
||||
drawingarea.tabmenu = tabmenu
|
||||
drawingarea.wnck_window = wnck_window
|
||||
|
||||
notebook.append_page_menu(box, tabimage, tabmenu)
|
||||
notebook.set_current_page( notebook.page_num(box) )
|
||||
|
||||
notebook.set_tab_reorderable(drawingarea, 1)
|
||||
|
||||
self.tabs[wnck_window] = drawingarea
|
||||
|
||||
pass
|
||||
|
||||
def quit(self, *args):
|
||||
gtk.main_quit()
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
win=mainwindow()
|
||||
gtk.main()
|
||||
|
1
NOVA/usr/local/bin/lockscreen
Executable file
1
NOVA/usr/local/bin/lockscreen
Executable file
@ -0,0 +1 @@
|
||||
xscreensaver-command -lock
|
1
NOVA/usr/local/bin/menugen
Executable file
1
NOVA/usr/local/bin/menugen
Executable file
@ -0,0 +1 @@
|
||||
xdg_menu --fullmenu --format awesome --root-menu /etc/xdg/menus/arch-applications.menu >~/.config/awesome/menu
|
46
NOVA/usr/local/bin/mpdpl2html
Executable file
46
NOVA/usr/local/bin/mpdpl2html
Executable file
@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# mpdpl2html - MPD playlist to HTML
|
||||
# by pfish - 2010
|
||||
# Version 0.1
|
||||
# License: GPL 2
|
||||
#
|
||||
# Requirements:
|
||||
# mpd
|
||||
# mpc
|
||||
# sed
|
||||
#
|
||||
|
||||
#USER=`whoami`
|
||||
STATS=`mpc stats | sed 's/$/\<br \/\>/'`
|
||||
PLAYLIST=`mpc playlist | sed 's/$/\<br \/\>/'`
|
||||
VERSION=`mpc version`
|
||||
FILE="mpdplaylist.html"
|
||||
DATE=`date -R`
|
||||
|
||||
echo "<!-- Generated with mpdpl2html by pfish - $DATE -->
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />
|
||||
<title>MPD playlist of $USER</title>
|
||||
<style type=\"text/css\">
|
||||
body {color: #ffffff; background-color: #001A57; font-size: 12px;}
|
||||
h1 {color: #f28500; margin: 0; padding: 0;}
|
||||
h2 {color: #f28500; margin: 0; padding: 0;}
|
||||
hr {color: #f28500; border: 1;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>MPD playlist of $USER</h1>
|
||||
<hr />
|
||||
<h2>Statistics:</h2>
|
||||
$VERSION
|
||||
<br /><br />
|
||||
$STATS
|
||||
<br />
|
||||
<h2>Playlist:</h2>
|
||||
$PLAYLIST
|
||||
<hr />
|
||||
<small>Generated with mpdpl2html by pfish - $DATE</small>
|
||||
</body>
|
||||
</html>" > $FILE
|
604
NOVA/usr/local/bin/repo
Executable file
604
NOVA/usr/local/bin/repo
Executable file
@ -0,0 +1,604 @@
|
||||
#!/bin/sh
|
||||
|
||||
## repo default configuration
|
||||
##
|
||||
REPO_URL='git://android.git.kernel.org/tools/repo.git'
|
||||
REPO_REV='stable'
|
||||
|
||||
# Copyright (C) 2008 Google Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
magic='--calling-python-from-/bin/sh--'
|
||||
"""exec" python -E "$0" "$@" """#$magic"
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
if sys.argv[-1] == '#%s' % magic:
|
||||
del sys.argv[-1]
|
||||
del magic
|
||||
|
||||
# increment this whenever we make important changes to this script
|
||||
VERSION = (1, 10)
|
||||
|
||||
# increment this if the MAINTAINER_KEYS block is modified
|
||||
KEYRING_VERSION = (1,0)
|
||||
MAINTAINER_KEYS = """
|
||||
|
||||
Repo Maintainer <repo@android.kernel.org>
|
||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
Version: GnuPG v1.4.2.2 (GNU/Linux)
|
||||
|
||||
mQGiBEj3ugERBACrLJh/ZPyVSKeClMuznFIrsQ+hpNnmJGw1a9GXKYKk8qHPhAZf
|
||||
WKtrBqAVMNRLhL85oSlekRz98u41H5si5zcuv+IXJDF5MJYcB8f22wAy15lUqPWi
|
||||
VCkk1l8qqLiuW0fo+ZkPY5qOgrvc0HW1SmdH649uNwqCbcKb6CxaTxzhOwCgj3AP
|
||||
xI1WfzLqdJjsm1Nq98L0cLcD/iNsILCuw44PRds3J75YP0pze7YF/6WFMB6QSFGu
|
||||
aUX1FsTTztKNXGms8i5b2l1B8JaLRWq/jOnZzyl1zrUJhkc0JgyZW5oNLGyWGhKD
|
||||
Fxp5YpHuIuMImopWEMFIRQNrvlg+YVK8t3FpdI1RY0LYqha8pPzANhEYgSfoVzOb
|
||||
fbfbA/4ioOrxy8ifSoga7ITyZMA+XbW8bx33WXutO9N7SPKS/AK2JpasSEVLZcON
|
||||
ae5hvAEGVXKxVPDjJBmIc2cOe7kOKSi3OxLzBqrjS2rnjiP4o0ekhZIe4+ocwVOg
|
||||
e0PLlH5avCqihGRhpoqDRsmpzSHzJIxtoeb+GgGEX8KkUsVAhbQpUmVwbyBNYWlu
|
||||
dGFpbmVyIDxyZXBvQGFuZHJvaWQua2VybmVsLm9yZz6IYAQTEQIAIAUCSPe6AQIb
|
||||
AwYLCQgHAwIEFQIIAwQWAgMBAh4BAheAAAoJEBZTDV6SD1xl1GEAn0x/OKQpy7qI
|
||||
6G73NJviU0IUMtftAKCFMUhGb/0bZvQ8Rm3QCUpWHyEIu7kEDQRI97ogEBAA2wI6
|
||||
5fs9y/rMwD6dkD/vK9v4C9mOn1IL5JCPYMJBVSci+9ED4ChzYvfq7wOcj9qIvaE0
|
||||
GwCt2ar7Q56me5J+byhSb32Rqsw/r3Vo5cZMH80N4cjesGuSXOGyEWTe4HYoxnHv
|
||||
gF4EKI2LK7xfTUcxMtlyn52sUpkfKsCpUhFvdmbAiJE+jCkQZr1Z8u2KphV79Ou+
|
||||
P1N5IXY/XWOlq48Qf4MWCYlJFrB07xjUjLKMPDNDnm58L5byDrP/eHysKexpbakL
|
||||
xCmYyfT6DV1SWLblpd2hie0sL3YejdtuBMYMS2rI7Yxb8kGuqkz+9l1qhwJtei94
|
||||
5MaretDy/d/JH/pRYkRf7L+ke7dpzrP+aJmcz9P1e6gq4NJsWejaALVASBiioqNf
|
||||
QmtqSVzF1wkR5avZkFHuYvj6V/t1RrOZTXxkSk18KFMJRBZrdHFCWbc5qrVxUB6e
|
||||
N5pja0NFIUCigLBV1c6I2DwiuboMNh18VtJJh+nwWeez/RueN4ig59gRTtkcc0PR
|
||||
35tX2DR8+xCCFVW/NcJ4PSePYzCuuLvp1vEDHnj41R52Fz51hgddT4rBsp0nL+5I
|
||||
socSOIIezw8T9vVzMY4ArCKFAVu2IVyBcahTfBS8q5EM63mONU6UVJEozfGljiMw
|
||||
xuQ7JwKcw0AUEKTKG7aBgBaTAgT8TOevpvlw91cAAwUP/jRkyVi/0WAb0qlEaq/S
|
||||
ouWxX1faR+vU3b+Y2/DGjtXQMzG0qpetaTHC/AxxHpgt/dCkWI6ljYDnxgPLwG0a
|
||||
Oasm94BjZc6vZwf1opFZUKsjOAAxRxNZyjUJKe4UZVuMTk6zo27Nt3LMnc0FO47v
|
||||
FcOjRyquvgNOS818irVHUf12waDx8gszKxQTTtFxU5/ePB2jZmhP6oXSe4K/LG5T
|
||||
+WBRPDrHiGPhCzJRzm9BP0lTnGCAj3o9W90STZa65RK7IaYpC8TB35JTBEbrrNCp
|
||||
w6lzd74LnNEp5eMlKDnXzUAgAH0yzCQeMl7t33QCdYx2hRs2wtTQSjGfAiNmj/WW
|
||||
Vl5Jn+2jCDnRLenKHwVRFsBX2e0BiRWt/i9Y8fjorLCXVj4z+7yW6DawdLkJorEo
|
||||
p3v5ILwfC7hVx4jHSnOgZ65L9s8EQdVr1ckN9243yta7rNgwfcqb60ILMFF1BRk/
|
||||
0V7wCL+68UwwiQDvyMOQuqkysKLSDCLb7BFcyA7j6KG+5hpsREstFX2wK1yKeraz
|
||||
5xGrFy8tfAaeBMIQ17gvFSp/suc9DYO0ICK2BISzq+F+ZiAKsjMYOBNdH/h0zobQ
|
||||
HTHs37+/QLMomGEGKZMWi0dShU2J5mNRQu3Hhxl3hHDVbt5CeJBb26aQcQrFz69W
|
||||
zE3GNvmJosh6leayjtI9P2A6iEkEGBECAAkFAkj3uiACGwwACgkQFlMNXpIPXGWp
|
||||
TACbBS+Up3RpfYVfd63c1cDdlru13pQAn3NQy/SN858MkxN+zym86UBgOad2
|
||||
=CMiZ
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
||||
"""
|
||||
|
||||
GIT = 'git' # our git command
|
||||
MIN_GIT_VERSION = (1, 5, 4) # minimum supported git version
|
||||
repodir = '.repo' # name of repo's private directory
|
||||
S_repo = 'repo' # special repo reposiory
|
||||
S_manifests = 'manifests' # special manifest repository
|
||||
REPO_MAIN = S_repo + '/main.py' # main script
|
||||
|
||||
|
||||
import optparse
|
||||
import os
|
||||
import re
|
||||
import readline
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
home_dot_repo = os.path.expanduser('~/.repoconfig')
|
||||
gpg_dir = os.path.join(home_dot_repo, 'gnupg')
|
||||
|
||||
extra_args = []
|
||||
init_optparse = optparse.OptionParser(usage="repo init -u url [options]")
|
||||
|
||||
# Logging
|
||||
group = init_optparse.add_option_group('Logging options')
|
||||
group.add_option('-q', '--quiet',
|
||||
dest="quiet", action="store_true", default=False,
|
||||
help="be quiet")
|
||||
|
||||
# Manifest
|
||||
group = init_optparse.add_option_group('Manifest options')
|
||||
group.add_option('-u', '--manifest-url',
|
||||
dest='manifest_url',
|
||||
help='manifest repository location', metavar='URL')
|
||||
group.add_option('-o', '--origin',
|
||||
dest='manifest_origin',
|
||||
help="use REMOTE instead of 'origin' to track upstream",
|
||||
metavar='REMOTE')
|
||||
group.add_option('-b', '--manifest-branch',
|
||||
dest='manifest_branch',
|
||||
help='manifest branch or revision', metavar='REVISION')
|
||||
group.add_option('-m', '--manifest-name',
|
||||
dest='manifest_name',
|
||||
help='initial manifest file (deprecated)',
|
||||
metavar='NAME.xml')
|
||||
group.add_option('--mirror',
|
||||
dest='mirror', action='store_true',
|
||||
help='mirror the forrest')
|
||||
group.add_option('--reference',
|
||||
dest='reference',
|
||||
help='location of mirror directory', metavar='DIR')
|
||||
|
||||
# Tool
|
||||
group = init_optparse.add_option_group('repo Version options')
|
||||
group.add_option('--repo-url',
|
||||
dest='repo_url',
|
||||
help='repo repository location', metavar='URL')
|
||||
group.add_option('--repo-branch',
|
||||
dest='repo_branch',
|
||||
help='repo branch or revision', metavar='REVISION')
|
||||
group.add_option('--no-repo-verify',
|
||||
dest='no_repo_verify', action='store_true',
|
||||
help='do not verify repo source code')
|
||||
|
||||
|
||||
class CloneFailure(Exception):
|
||||
"""Indicate the remote clone of repo itself failed.
|
||||
"""
|
||||
|
||||
|
||||
def _Init(args):
|
||||
"""Installs repo by cloning it over the network.
|
||||
"""
|
||||
opt, args = init_optparse.parse_args(args)
|
||||
if args or not opt.manifest_url:
|
||||
init_optparse.print_usage()
|
||||
sys.exit(1)
|
||||
|
||||
url = opt.repo_url
|
||||
if not url:
|
||||
url = REPO_URL
|
||||
extra_args.append('--repo-url=%s' % url)
|
||||
|
||||
branch = opt.repo_branch
|
||||
if not branch:
|
||||
branch = REPO_REV
|
||||
extra_args.append('--repo-branch=%s' % branch)
|
||||
|
||||
if branch.startswith('refs/heads/'):
|
||||
branch = branch[len('refs/heads/'):]
|
||||
if branch.startswith('refs/'):
|
||||
print >>sys.stderr, "fatal: invalid branch name '%s'" % branch
|
||||
raise CloneFailure()
|
||||
|
||||
if not os.path.isdir(repodir):
|
||||
try:
|
||||
os.mkdir(repodir)
|
||||
except OSError, e:
|
||||
print >>sys.stderr, \
|
||||
'fatal: cannot make %s directory: %s' % (
|
||||
repodir, e.strerror)
|
||||
# Don't faise CloneFailure; that would delete the
|
||||
# name. Instead exit immediately.
|
||||
#
|
||||
sys.exit(1)
|
||||
|
||||
_CheckGitVersion()
|
||||
try:
|
||||
if _NeedSetupGnuPG():
|
||||
can_verify = _SetupGnuPG(opt.quiet)
|
||||
else:
|
||||
can_verify = True
|
||||
|
||||
if not opt.quiet:
|
||||
print >>sys.stderr, 'Getting repo ...'
|
||||
print >>sys.stderr, ' from %s' % url
|
||||
|
||||
dst = os.path.abspath(os.path.join(repodir, S_repo))
|
||||
_Clone(url, dst, opt.quiet)
|
||||
|
||||
if can_verify and not opt.no_repo_verify:
|
||||
rev = _Verify(dst, branch, opt.quiet)
|
||||
else:
|
||||
rev = 'refs/remotes/origin/%s^0' % branch
|
||||
|
||||
_Checkout(dst, branch, rev, opt.quiet)
|
||||
except CloneFailure:
|
||||
if opt.quiet:
|
||||
print >>sys.stderr, \
|
||||
'fatal: repo init failed; run without --quiet to see why'
|
||||
raise
|
||||
|
||||
|
||||
def _CheckGitVersion():
|
||||
cmd = [GIT, '--version']
|
||||
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||
ver_str = proc.stdout.read().strip()
|
||||
proc.stdout.close()
|
||||
proc.wait()
|
||||
|
||||
if not ver_str.startswith('git version '):
|
||||
print >>sys.stderr, 'error: "%s" unsupported' % ver_str
|
||||
raise CloneFailure()
|
||||
|
||||
ver_str = ver_str[len('git version '):].strip()
|
||||
ver_act = tuple(map(lambda x: int(x), ver_str.split('.')[0:3]))
|
||||
if ver_act < MIN_GIT_VERSION:
|
||||
need = '.'.join(map(lambda x: str(x), MIN_GIT_VERSION))
|
||||
print >>sys.stderr, 'fatal: git %s or later required' % need
|
||||
raise CloneFailure()
|
||||
|
||||
|
||||
def _NeedSetupGnuPG():
|
||||
if not os.path.isdir(home_dot_repo):
|
||||
return True
|
||||
|
||||
kv = os.path.join(home_dot_repo, 'keyring-version')
|
||||
if not os.path.exists(kv):
|
||||
return True
|
||||
|
||||
kv = open(kv).read()
|
||||
if not kv:
|
||||
return True
|
||||
|
||||
kv = tuple(map(lambda x: int(x), kv.split('.')))
|
||||
if kv < KEYRING_VERSION:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def _SetupGnuPG(quiet):
|
||||
if not os.path.isdir(home_dot_repo):
|
||||
try:
|
||||
os.mkdir(home_dot_repo)
|
||||
except OSError, e:
|
||||
print >>sys.stderr, \
|
||||
'fatal: cannot make %s directory: %s' % (
|
||||
home_dot_repo, e.strerror)
|
||||
sys.exit(1)
|
||||
|
||||
if not os.path.isdir(gpg_dir):
|
||||
try:
|
||||
os.mkdir(gpg_dir, 0700)
|
||||
except OSError, e:
|
||||
print >>sys.stderr, \
|
||||
'fatal: cannot make %s directory: %s' % (
|
||||
gpg_dir, e.strerror)
|
||||
sys.exit(1)
|
||||
|
||||
env = os.environ.copy()
|
||||
env['GNUPGHOME'] = gpg_dir.encode()
|
||||
|
||||
cmd = ['gpg', '--import']
|
||||
try:
|
||||
proc = subprocess.Popen(cmd,
|
||||
env = env,
|
||||
stdin = subprocess.PIPE)
|
||||
except OSError, e:
|
||||
if not quiet:
|
||||
print >>sys.stderr, 'warning: gpg (GnuPG) is not available.'
|
||||
print >>sys.stderr, 'warning: Installing it is strongly encouraged.'
|
||||
print >>sys.stderr
|
||||
return False
|
||||
|
||||
proc.stdin.write(MAINTAINER_KEYS)
|
||||
proc.stdin.close()
|
||||
|
||||
if proc.wait() != 0:
|
||||
print >>sys.stderr, 'fatal: registering repo maintainer keys failed'
|
||||
sys.exit(1)
|
||||
print
|
||||
|
||||
fd = open(os.path.join(home_dot_repo, 'keyring-version'), 'w')
|
||||
fd.write('.'.join(map(lambda x: str(x), KEYRING_VERSION)) + '\n')
|
||||
fd.close()
|
||||
return True
|
||||
|
||||
|
||||
def _SetConfig(local, name, value):
|
||||
"""Set a git configuration option to the specified value.
|
||||
"""
|
||||
cmd = [GIT, 'config', name, value]
|
||||
if subprocess.Popen(cmd, cwd = local).wait() != 0:
|
||||
raise CloneFailure()
|
||||
|
||||
|
||||
def _Fetch(local, quiet, *args):
|
||||
cmd = [GIT, 'fetch']
|
||||
if quiet:
|
||||
cmd.append('--quiet')
|
||||
err = subprocess.PIPE
|
||||
else:
|
||||
err = None
|
||||
cmd.extend(args)
|
||||
cmd.append('origin')
|
||||
|
||||
proc = subprocess.Popen(cmd, cwd = local, stderr = err)
|
||||
if err:
|
||||
proc.stderr.read()
|
||||
proc.stderr.close()
|
||||
if proc.wait() != 0:
|
||||
raise CloneFailure()
|
||||
|
||||
|
||||
def _Clone(url, local, quiet):
|
||||
"""Clones a git repository to a new subdirectory of repodir
|
||||
"""
|
||||
try:
|
||||
os.mkdir(local)
|
||||
except OSError, e:
|
||||
print >>sys.stderr, \
|
||||
'fatal: cannot make %s directory: %s' \
|
||||
% (local, e.strerror)
|
||||
raise CloneFailure()
|
||||
|
||||
cmd = [GIT, 'init', '--quiet']
|
||||
try:
|
||||
proc = subprocess.Popen(cmd, cwd = local)
|
||||
except OSError, e:
|
||||
print >>sys.stderr
|
||||
print >>sys.stderr, "fatal: '%s' is not available" % GIT
|
||||
print >>sys.stderr, 'fatal: %s' % e
|
||||
print >>sys.stderr
|
||||
print >>sys.stderr, 'Please make sure %s is installed'\
|
||||
' and in your path.' % GIT
|
||||
raise CloneFailure()
|
||||
if proc.wait() != 0:
|
||||
print >>sys.stderr, 'fatal: could not create %s' % local
|
||||
raise CloneFailure()
|
||||
|
||||
_SetConfig(local, 'remote.origin.url', url)
|
||||
_SetConfig(local, 'remote.origin.fetch',
|
||||
'+refs/heads/*:refs/remotes/origin/*')
|
||||
_Fetch(local, quiet)
|
||||
_Fetch(local, quiet, '--tags')
|
||||
|
||||
|
||||
def _Verify(cwd, branch, quiet):
|
||||
"""Verify the branch has been signed by a tag.
|
||||
"""
|
||||
cmd = [GIT, 'describe', 'origin/%s' % branch]
|
||||
proc = subprocess.Popen(cmd,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
cwd = cwd)
|
||||
cur = proc.stdout.read().strip()
|
||||
proc.stdout.close()
|
||||
|
||||
proc.stderr.read()
|
||||
proc.stderr.close()
|
||||
|
||||
if proc.wait() != 0 or not cur:
|
||||
print >>sys.stderr
|
||||
print >>sys.stderr,\
|
||||
"fatal: branch '%s' has not been signed" \
|
||||
% branch
|
||||
raise CloneFailure()
|
||||
|
||||
m = re.compile(r'^(.*)-[0-9]{1,}-g[0-9a-f]{1,}$').match(cur)
|
||||
if m:
|
||||
cur = m.group(1)
|
||||
if not quiet:
|
||||
print >>sys.stderr
|
||||
print >>sys.stderr, \
|
||||
"info: Ignoring branch '%s'; using tagged release '%s'" \
|
||||
% (branch, cur)
|
||||
print >>sys.stderr
|
||||
|
||||
env = os.environ.copy()
|
||||
env['GNUPGHOME'] = gpg_dir.encode()
|
||||
|
||||
cmd = [GIT, 'tag', '-v', cur]
|
||||
proc = subprocess.Popen(cmd,
|
||||
stdout = subprocess.PIPE,
|
||||
stderr = subprocess.PIPE,
|
||||
cwd = cwd,
|
||||
env = env)
|
||||
out = proc.stdout.read()
|
||||
proc.stdout.close()
|
||||
|
||||
err = proc.stderr.read()
|
||||
proc.stderr.close()
|
||||
|
||||
if proc.wait() != 0:
|
||||
print >>sys.stderr
|
||||
print >>sys.stderr, out
|
||||
print >>sys.stderr, err
|
||||
print >>sys.stderr
|
||||
raise CloneFailure()
|
||||
return '%s^0' % cur
|
||||
|
||||
|
||||
def _Checkout(cwd, branch, rev, quiet):
|
||||
"""Checkout an upstream branch into the repository and track it.
|
||||
"""
|
||||
cmd = [GIT, 'update-ref', 'refs/heads/default', rev]
|
||||
if subprocess.Popen(cmd, cwd = cwd).wait() != 0:
|
||||
raise CloneFailure()
|
||||
|
||||
_SetConfig(cwd, 'branch.default.remote', 'origin')
|
||||
_SetConfig(cwd, 'branch.default.merge', 'refs/heads/%s' % branch)
|
||||
|
||||
cmd = [GIT, 'symbolic-ref', 'HEAD', 'refs/heads/default']
|
||||
if subprocess.Popen(cmd, cwd = cwd).wait() != 0:
|
||||
raise CloneFailure()
|
||||
|
||||
cmd = [GIT, 'read-tree', '--reset', '-u']
|
||||
if not quiet:
|
||||
cmd.append('-v')
|
||||
cmd.append('HEAD')
|
||||
if subprocess.Popen(cmd, cwd = cwd).wait() != 0:
|
||||
raise CloneFailure()
|
||||
|
||||
|
||||
def _FindRepo():
|
||||
"""Look for a repo installation, starting at the current directory.
|
||||
"""
|
||||
dir = os.getcwd()
|
||||
repo = None
|
||||
|
||||
olddir = None
|
||||
while dir != '/' \
|
||||
and dir != olddir \
|
||||
and not repo:
|
||||
repo = os.path.join(dir, repodir, REPO_MAIN)
|
||||
if not os.path.isfile(repo):
|
||||
repo = None
|
||||
olddir = dir
|
||||
dir = os.path.dirname(dir)
|
||||
return (repo, os.path.join(dir, repodir))
|
||||
|
||||
|
||||
class _Options:
|
||||
help = False
|
||||
|
||||
|
||||
def _ParseArguments(args):
|
||||
cmd = None
|
||||
opt = _Options()
|
||||
arg = []
|
||||
|
||||
for i in xrange(0, len(args)):
|
||||
a = args[i]
|
||||
if a == '-h' or a == '--help':
|
||||
opt.help = True
|
||||
|
||||
elif not a.startswith('-'):
|
||||
cmd = a
|
||||
arg = args[i + 1:]
|
||||
break
|
||||
return cmd, opt, arg
|
||||
|
||||
|
||||
def _Usage():
|
||||
print >>sys.stderr,\
|
||||
"""usage: repo COMMAND [ARGS]
|
||||
|
||||
repo is not yet installed. Use "repo init" to install it here.
|
||||
|
||||
The most commonly used repo commands are:
|
||||
|
||||
init Install repo in the current working directory
|
||||
help Display detailed help on a command
|
||||
|
||||
For access to the full online help, install repo ("repo init").
|
||||
"""
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def _Help(args):
|
||||
if args:
|
||||
if args[0] == 'init':
|
||||
init_optparse.print_help()
|
||||
sys.exit(0)
|
||||
else:
|
||||
print >>sys.stderr,\
|
||||
"error: '%s' is not a bootstrap command.\n"\
|
||||
' For access to online help, install repo ("repo init").'\
|
||||
% args[0]
|
||||
else:
|
||||
_Usage()
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def _NotInstalled():
|
||||
print >>sys.stderr,\
|
||||
'error: repo is not installed. Use "repo init" to install it here.'
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def _NoCommands(cmd):
|
||||
print >>sys.stderr,\
|
||||
"""error: command '%s' requires repo to be installed first.
|
||||
Use "repo init" to install it here.""" % cmd
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def _RunSelf(wrapper_path):
|
||||
my_dir = os.path.dirname(wrapper_path)
|
||||
my_main = os.path.join(my_dir, 'main.py')
|
||||
my_git = os.path.join(my_dir, '.git')
|
||||
|
||||
if os.path.isfile(my_main) and os.path.isdir(my_git):
|
||||
for name in ['git_config.py',
|
||||
'project.py',
|
||||
'subcmds']:
|
||||
if not os.path.exists(os.path.join(my_dir, name)):
|
||||
return None, None
|
||||
return my_main, my_git
|
||||
return None, None
|
||||
|
||||
|
||||
def _SetDefaultsTo(gitdir):
|
||||
global REPO_URL
|
||||
global REPO_REV
|
||||
|
||||
REPO_URL = gitdir
|
||||
proc = subprocess.Popen([GIT,
|
||||
'--git-dir=%s' % gitdir,
|
||||
'symbolic-ref',
|
||||
'HEAD'],
|
||||
stdout = subprocess.PIPE,
|
||||
stderr = subprocess.PIPE)
|
||||
REPO_REV = proc.stdout.read().strip()
|
||||
proc.stdout.close()
|
||||
|
||||
proc.stderr.read()
|
||||
proc.stderr.close()
|
||||
|
||||
if proc.wait() != 0:
|
||||
print >>sys.stderr, 'fatal: %s has no current branch' % gitdir
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main(orig_args):
|
||||
main, dir = _FindRepo()
|
||||
cmd, opt, args = _ParseArguments(orig_args)
|
||||
|
||||
wrapper_path = os.path.abspath(__file__)
|
||||
my_main, my_git = _RunSelf(wrapper_path)
|
||||
|
||||
if not main:
|
||||
if opt.help:
|
||||
_Usage()
|
||||
if cmd == 'help':
|
||||
_Help(args)
|
||||
if not cmd:
|
||||
_NotInstalled()
|
||||
if cmd == 'init':
|
||||
if my_git:
|
||||
_SetDefaultsTo(my_git)
|
||||
try:
|
||||
_Init(args)
|
||||
except CloneFailure:
|
||||
for root, dirs, files in os.walk(repodir, topdown=False):
|
||||
for name in files:
|
||||
os.remove(os.path.join(root, name))
|
||||
for name in dirs:
|
||||
os.rmdir(os.path.join(root, name))
|
||||
os.rmdir(repodir)
|
||||
sys.exit(1)
|
||||
main, dir = _FindRepo()
|
||||
else:
|
||||
_NoCommands(cmd)
|
||||
|
||||
if my_main:
|
||||
main = my_main
|
||||
|
||||
ver_str = '.'.join(map(lambda x: str(x), VERSION))
|
||||
me = [main,
|
||||
'--repo-dir=%s' % dir,
|
||||
'--wrapper-version=%s' % ver_str,
|
||||
'--wrapper-path=%s' % wrapper_path,
|
||||
'--']
|
||||
me.extend(orig_args)
|
||||
me.extend(extra_args)
|
||||
try:
|
||||
os.execv(main, me)
|
||||
except OSError, e:
|
||||
print >>sys.stderr, "fatal: unable to start %s" % main
|
||||
print >>sys.stderr, "fatal: %s" % e
|
||||
sys.exit(148)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(sys.argv[1:])
|
||||
|
11
NOVA/usr/local/bin/scrotshooter
Executable file
11
NOVA/usr/local/bin/scrotshooter
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
msg="Image filename:"
|
||||
mydir="$HOME/Desktop/Screenshots"
|
||||
title="ScreenShooter"
|
||||
|
||||
filename=$(zenity --entry --text "$msg" --entry-text FileName)
|
||||
|
||||
scrot $mydir/$filename.png
|
||||
|
||||
exit 0
|
11
NOVA/usr/local/bin/scrotshooter-aprint
Executable file
11
NOVA/usr/local/bin/scrotshooter-aprint
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
msg="Image filename:"
|
||||
mydir="$HOME/Desktop/Screenshots"
|
||||
title="ScreenShooter"
|
||||
|
||||
filename=$(zenity --entry --text "$msg" --entry-text FileName)
|
||||
|
||||
scrot -s -b $mydir/$filename.png
|
||||
|
||||
exit 0
|
Reference in New Issue
Block a user