A következő címkéjű bejegyzések mutatása: script. Összes bejegyzés megjelenítése
A következő címkéjű bejegyzések mutatása: script. Összes bejegyzés megjelenítése

2019. augusztus 3.

Display settings lost on reboot

As described here, this problem is affecting others as well:
Here are the steps I tool to assemble the little script below:

How many displays do you have right now?
xrandr | grep -w connected | wc -l
How to position your displays?
xrandr --output PRIMARY-SCREEN-ID --below SECONDARY-SCREEN-ID
How to rotate a display?
xrandr --output SCREEN-ID --rotate [normal|left|right|inverted]
How to get your display IDs?
primary display:
xrandr | grep -w connected | grep primary | cut -d' ' -f1
secondary display:
xrandr | grep -w connected | grep -v primary | cut -d' ' -f1
How to position your gnome-panels?
Apparently there is no easy way, but for the note, here's where to find these setting:
org.gnome.gnome-panel.layout.toplevels.bottom-panel monitor 0
org.gnome.gnome-panel.layout.toplevels.top-panel monitor 1

Here's the script I put into my .bashrc (.profile would be also a good place for it) to restore the positions of my displays (I have the laptop below the monitor).

# set dual display positions
# because they are forgotten after logout
function reset_displays {
 display_count=`xrandr | grep -w connected | wc -l`
 if [ "$display_count" -eq "2" ]; then
  id1=`xrandr | grep -w connected | grep primary | cut -d' ' -f1`
  id2=`xrandr | grep -w connected | grep -v primary | cut -d' ' -f1`
  xrandr --output $id2 --rotate normal
  xrandr --output $id1 --below $id2
 fi
}
reset_displays

2015. október 1.

Plex Plugin Installer

So, since I found plex plugin manual installation painfully boring, I wrote a nautilus script to do the job for me.
Instead of copy-pasting, you can also download this script form github.

I wasted a couple hours finding out that  if I use "double quotes" instead of 'single quotes' when assigning the plugin folder path to the PLUGIN_FOLDER variable, then 1.) the path will break on spaces and won't work; 2.) if I surround the call with '"'-s (a double quote between two single quotes) or just another "-s the program will fail not finding the files/directories. This was the tricky part because if instead of running I echoed the lines, they looked perfectly okay, and if I copy-pasted them to the command line they would even run properly... only not within a script.

#!/bin/bash
# nautilus script
# install PLEX plugin on Ubuntu 12.04.

# run this script by right clicking on the directory you want to install
install_plugin () {
 # standard feature: install by copying folder
 # future enhancement: install from ZIP file

 PARAMETERS=( "$@" )               ## array containing all params passed to the script

 PLUGIN_FOLDER='/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/'

 # read folder paths into TO_BE_INSTALLED
 IFS=$'\n' read -d '' -r -a TO_BE_INSTALLED < <(printf '%s\n' $PARAMETERS); unset $IFS

 need_to_restart_server=false

 for package in "${TO_BE_INSTALLED[@]}"; do
  package_name="${package##*/}" # Strip longest match of substring (*/) from front of string

 # sanity check: is the path correct? it should be a directory and end with ".bundle".
  if  [[ -d "$package" ]]; then # if selected path IS a directory
   if [[ "${package_name##*.}" == "bundle" ]]; then
    installed_package=$PLUGIN_FOLDER$package_name
   # check if plugin already exists
    if [[ -d "$installed_package" ]]; then 
     # if yes, ask to delete it 
     echo -n "A package with the same name is already installed. Would you like to overwrite it? (yes/no): "; read overwrite 
     if [[ $overwrite == [Yy][Ee][Ss] || $overwrite == [Yy] ]]; then 
      sudo rm -R "$installed_package"
     else
      echo "You chose not to overwrite $package_name so it will not be processed."
      continue
     fi
    fi
   # install plugin
    #copy the downloaded plugin to the plex plug-in directory
    sudo cp -R "$package" "$PLUGIN_FOLDER"

    #change the permissions to be like the existing plug-ins 
    #(this is not needed in 14.04 anymore)
    sudo chmod ugoa+rx "$installed_package"

    #change the owner of the files to be like the existing plug-ins
    sudo chown -R plex:plex "$installed_package"

    need_to_restart_server=true

   else # if not "bundle"
    echo "Package name should end with '.bundle'. $package_name will not be processed."
    continue # process next package instead
   fi

  else # if not directory
   echo "Package should be a directory. $package_name will not be processed."
   continue # process next package instead
  fi

 done
# when finished with all packages, restart plex server.
if [[ $need_to_restart_server = true ]]; then 
 sudo service plexmediaserver stop
 sleep 5
 sudo service plexmediaserver start
 
 echo "Installation complete. Your new plug-in should show up now in PLEX."
fi
}

export -f install_plugin

gnome-terminal --execute bash -c 'install_plugin "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"; bash'

2015. február 25.

PDF smart rename and split based on content


I was planning to do these scripts for some time to ease my work with pdf files.

The original idea was to grep some text from the pdf file and do a file manipulation based on the text.

This StackExchange post suggests the following methods to find a piece of text in a pdf:
  • pdftotext + grep
  • pdfgrep
  • strings + grep
  • pdftohtml + grep
I used pdftotext in the following examples.

I also needed to learn some more Bash scripting:
1st Quest
I have a monthly employee data sheet (payroll), which I get in one big multipage pdf file, having a single page for each employee. The content for each page is: 1st line: title, 2nd line: month, 3rd line: employee name.
I wanted to burst this pdf file into single pages and rename it to title month and employee name.
My solution is:
#!/bin/bash
# NAUTILUS SCRIPT
# automatically splits pdf file to single pages while renaming the output files using the first three of lines of the pdf

# read files
IFS=$'\n' read -d '' -r -a filelist < <(printf '%s\n' "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"); unset $IFS

pagecount=1
datestamp=1

# burst and rename pages to separate files
for file in "${filelist[@]}"; do
 pagecount=`pdfinfo $file | grep "Pages" | awk '{ print $2 }'`
 for (( pageindex=1; pageindex<=$pagecount; pageindex+=1 )); do
  newname=`pdftotext -f $pageindex -l $pageindex $file - | head -n 3 | tr '\n' ' ' | cut -f1 -d"("`
  let "datestamp =`date +%s%N`" # to avoid overwriting with same new name
  pdftk $file cat $pageindex output "$newname"$datestamp.pdf
 done
done

2nd Quest
I have files I would like to rename based on the content of the file. Each file is some kind of employee data file, and has the employee name in the content, but not necessary in the file name.
I wanted to rename the file based on the employee name and the page title (first line of the file).
My solution is:
#!/bin/bash
# NAUTILUS SCRIPT
# automatically renames pdf file based on content maching a list of names

# read files
IFS=$'\n' read -d '' -r -a filelist < <(printf '%s\n' "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"); unset $IFS

names=( "Aaa Aaa" "Bbb Bbb" "Ccc Ccc") # names to match in the files

# process files
for file in "${filelist[@]}"; do
 # find name from names in the file
 foundname=''
 for name in "${names[@]}"; do
  testname=`pdftotext "$file" - | grep $name`
  if [[ $testname != "" ]]; then
   foundname=$name
   break
  fi
 done

 # rename file based on found name
 title=`pdftotext -f 1 -l 1 "$file" - | head -n 1`
 let "datestamp =`date +%s%N`"
 mv "$file" "${file%/*}/$foundname $title $datestamp.pdf"
done

3rd Quest
I have a yearly employee data sheet (personal tax data), which I get in one big multipage pdf file, having a multiple pages for each employee. This year it is three pages per employee, but the tax ID number is the only common point in the three pages (it it a 10 digit long number beginning with number 8). The first line of each page is a header, and it is different for each page for a single employee.
I wanted to split the pdf to employees and rename it with the header of the pages.
My solution is:
#!/bin/bash
# NAUTILUS SCRIPT
# automatically splits pdf file to multiple pages based on search criteria while renaming the output files using the search criteria and some of the pdf text.

# read files
IFS=$'\n' read -d '' -r -a filelist < <(printf '%s\n' "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"); unset $IFS

# process files
for file in "${filelist[@]}"; do
 pagecount=`pdfinfo $file | grep "Pages" | awk '{ print $2 }'`
 # MY SEARCH CRITERIA is a 10 digit long ID number that begins with number 8: 
 storedid=`pdftotext -f 1 -l 1 $file - | egrep '8?[0-9]{9}'`
 pattern=''
 pagetitle=''
 datestamp=''

 for (( pageindex=1; pageindex<=$pagecount; pageindex+=1 )); do

  header=`pdftotext -f $pageindex -l $pageindex $file - | head -n 1`
  pageid=`pdftotext -f $pageindex -l $pageindex $file - | egrep '8?[0-9]{9}'`
  let "datestamp =`date +%s%N`" # to avoid overwriting with same new name

  # match ID found on the page to the stored ID
  if [[ $pageid == $storedid ]]; then
   pattern+="$pageindex " # adds number as text to variable separated by spaces
   pagetitle+="$header+"

   if [[ $pageindex == $pagecount ]]; then #process last output of the file 
    pdftk $file cat $pattern output "$storedid $pagetitle $datestamp.pdf"
    storedid=0
    pattern=''
    pagetitle=''
   fi
  else 
   #process previous set of pages to output
   pdftk $file cat $pattern output "$storedid $pagetitle $datestamp.pdf"
   storedid=$pageid
   pattern="$pageindex "
   pagetitle="$header+"
  fi
 done
done

4th Quest
I wanted to have an alternate version of the 3rd Quest in case I have to split in equal sets of pages any other type of file, not having the tax ID as a common point in them.
So I wanted to split this multipage pdf based on a manually set block size, i.e. 3 pages / set.
My solution is:
#!/bin/bash
# NAUTILUS SCRIPT
# automatically splits pdf file to multiple pages based on given block size, and renames the files using the original filename plus datestamp

# read files
IFS=$'\n' read -d '' -r -a filelist < <(printf '%s\n' "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"); unset $IFS

# process files
for file in "${filelist[@]}"; do

 # variables
 blocksize=3 # ADD BLOCK SIZE MANUALLY HERE
 blocks=()
 filename=${file%.pdf} # remove extension from filename

 # calculate page range blocks
 pagecount=`pdfinfo $file | grep "Pages" | awk '{ print $2 }'` 
 let setcount=$pagecount/$blocksize 
 for (( setindex=1; setindex<=$setcount; setindex+=1 )); do

  if [[ $setindex -lt $setcount ]]; then
   let lastpage=$setindex*$blocksize
   let firstpage=$lastpage-$blocksize+1

  elif [[ $setindex -eq $setcount ]]; then # handle last page
   let lastpage=$pagecount
   let firstpage=$setindex*$blocksize-$blocksize+1

  fi
  blocks+=("$firstpage-$lastpage")
 done

 # process ranges to output
 for block in "${blocks[@]}"; do
  let "datestamp =`date +%s%N`" # to avoid overwriting with same new name
  pdftk $file cat $block output "$filename $datestamp.pdf"
 done
done

That's it. Could be better, but is functioning all right.

2015. január 25.

Nautilus Scripts for Tablet screen rotation

After some workaround in the past, I started using nautilus scripts to rotate my Tablet display together with the stylus and eraser.
(I moved this topic now to a separate post, because the original post is outdated)

#!/bin/sh
# for Lucid Lynx to rotate the display 180 degree
xrandr -o inverted
xsetwacom set 'Serial Wacom Tablet' Rotate HALF


#!/bin/sh
# for Lucid Lynx to rotate the display 90 degree to the left
xrandr -o left
xsetwacom set 'Serial Wacom Tablet' Rotate CCW


#!/bin/sh
# for Lucid Lynx to rotate the display back to normal
xrandr -o normal
xsetwacom set 'Serial Wacom Tablet' Rotate NONE


#!/bin/sh
# for Lucid Lynx to rotate the display 90 degree to the right (to take notes)
xrandr -o right
xsetwacom set 'Serial Wacom Tablet' Rotate CW

Nautilus scripting in bash: processing multiple files / handle space in filenames

Where do I put the scripts? 

Nautilus scripts folder is in your user home directory:
in Ubuntu 12.04 and before: .gnome2/nautilus-scripts/
from Ubuntu 14.04: .local/share/nautilus/scripts/

You'll have to make all script files executable in order to be able to run them.
chmod +x

What does a nautilus script do? 

All executable files in this folder will appear in the Scripts menu. Choosing a script from the menu will run that script.

When executed from a local folder, scripts will be passed the selected file names. When executed from a remote folder (e.g. a folder showing web or ftp content), scripts will be passed no parameters.

What nautilus script specific variables can I use?

In all cases, the following environment variables will be set by Nautilus, which the scripts may use:

  • NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
    # newline-delimited paths for selected files (only if local)
  • NAUTILUS_SCRIPT_SELECTED_URIS
    # newline-delimited URIs for selected files
  • NAUTILUS_SCRIPT_CURRENT_URI
    # URI for current location
  • NAUTILUS_SCRIPT_WINDOW_GEOMETRY
    # position and size of current window
# from Ubuntu 14.04 Nautilus does not have split view (extra pane), so these variables (most likely) will not work:
  • NAUTILUS_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS
    # newline-delimited paths for selected files in the inactive pane of a split-view window (only if local)
  • NAUTILUS_SCRIPT_NEXT_PANE_SELECTED_URIS
    # newline-delimited URIs for selected files in the inactive pane of a split-view window
  • NAUTILUS_SCRIPT_NEXT_PANE_CURRENT_URI
    # URI for current location in the inactive pane of a split-view window
How do these variables work? 

To test what these variables do you might use this nautilus script:
#!/bin/bash
# test your nautilus variables
touch $HOME/nautilustesting.txt
echo "SELECTED_FILE_PATHS: " "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" >> $HOME/nautilustesting.txt
echo "SELECTED_URIS: " "$NAUTILUS_SCRIPT_SELECTED_URIS"  >> $HOME/nautilustesting.txt
echo "CURRENT_URI: " "$NAUTILUS_SCRIPT_CURRENT_URI" >> $HOME/nautilustesting.txt
echo "WINDOW_GEOMETRY: " "$NAUTILUS_SCRIPT_WINDOW_GEOMETRY" >> $HOME/nautilustesting.txt
echo " " >> $HOME/nautilustesting.txt

How to use these variables?

The variables you get will look something like this (in case of selecting 4 files with spaces in the names):
SELECTED_FILE_PATHS:  /home/username/.gnome2/nautilus-scripts/Screen rotate/Set screen inverted
/home/username/.gnome2/nautilus-scripts/Screen rotate/Set screen left
/home/username/.gnome2/nautilus-scripts/Screen rotate/Set screen normal
/home/username/.gnome2/nautilus-scripts/Screen rotate/Set screen right (notes)
SELECTED_URIS:  file:///home/username/.gnome2/nautilus-scripts/Screen%20rotate/Set%20screen%20inverted
file:///home/username/.gnome2/nautilus-scripts/Screen%20rotate/Set%20screen%20left
file:///home/username/.gnome2/nautilus-scripts/Screen%20rotate/Set%20screen%20normal
file:///home/username/.gnome2/nautilus-scripts/Screen%20rotate/Set%20screen%20right%20(notes)
CURRENT_URI:  file:///home/username/.gnome2/nautilus-scripts
WINDOW_GEOMETRY:  1022x690+0+1024

How to read nautilus selected file paths with spaces into a bash array?

To have a use of them as input file path for example imagemagick, I'll have to deal with the spaces, because these command line programs usually take "file path" as input and do not take "file URI" as input, and file path may contain spaces.

The FAQ of the G-Scripts site suggests some ways to handle this:
  1. protect your variable with double quotes: instead of $1 use "$1"
  2. process the filenames with SED:
    files=`echo "$1" | sed 's/ /\\ /g'`
  3. process the filenames with AWK and SED:
    quoted=$(echo -e "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | awk 'BEGIN {FS = "\n" } { printf "\"%s\" ", $1 }' | sed -e s#\"\"##); eval "your-program $quoted"
Actually, for me NONE of the above worked.
I found my solution in a stackoverflow post. It uses the IFS value to deal with the filenames. I read somewhere that using the IFS is an inelegant way to deal with field separators, and one should use AWK FS variable instead.

My solution: 

This is to use with nautilus scripts:
IFS=$'\n' read -d '' -r -a filelist < <(printf '%s\n' "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"); unset $IFS
This is to use with my image manipulation scripts (where the script file is located in the same folder as the to-b-manipulated files):
IFS=$'\n' read -d "" -r -a filelist < <(find -iname "*.jpg" | sort); unset $IFS
When you want to call the elements of the array, you'll have to put them in double quotes, like
for i in "${filelist[@]}" 
do echo "$i"
done
Google search keywords to find the solution:

  • escape space in bash script
  • awk fs line break
  • sed change space to newline
  • escape space in bash script with sed
  • internal field separator
  • bash read file names into array
  • bash read space file names into array
  • echo into array bash
  • while read output array bash


2015. január 10.

Aero snap for Ubuntu 14.04 Flashback with Metacity

In this AskUbuntu post, a solution is described to have the Aero snap to left and right in Metacity Ubuntu. This AskUbuntu post, from the same user, is aiming to develop the solution further. I'll just cover the info from the first post here:

EDIT: I changed the code a little bit to fit my screen better.

You'll need to install two packages for this thing to work:
sudo apt-get install wmctrl xbindkeys

Than you'll need to create two scripts: one for snap left and one for snap right:
Create the files in terminal and give them right to execute by:
sudo touch /bin/snapleft.sh
sudo chmod ugoa+rx /bin/snapleft.sh
sudo touch /bin/snapright.sh
sudo chmod ugoa+rx /bin/snapright.sh 

Open the snapleft.sh by
sudo gedit /bin/snapleft.sh

Copy this text into it:
#!/bin/bash
sleep 0.1 && wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -e 0,0,0,`xwininfo -root | grep Width | awk '{ print (($2/2)-2)}'`,`xwininfo -root | grep Height | awk '{ print $2 }'`

than save and close it.
Open the snapright.sh by
sudo gedit /bin/snapright.sh

Copy this text into it:
#!/bin/bash
sleep 0.1 && wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -e 0,`xwininfo -root | grep Width | awk '{ print (($2/2))}'`,0,`xwininfo -root | grep Width | awk '{ print (($2/2))}'`,`xwininfo -root | grep Height | awk '{ print $2 }'`
than save and close it.

Now set the keyboard shortcuts with xbinkeys (to the left-side "super"/windows key and the left and right arrow keys) by
printf '"bash /bin/snapleft.sh"\n Mod4 + Super_L + Left\n' > ~/.xbindkeysrc 
printf '"bash /bin/snapright.sh"\n Mod4 + Super_L + Right\n' >> ~/.xbindkeysrc

You can check the name of a key (if something is amiss) with
xbindkeys -k


NEW STUFF:

To have a snap up and snap down function use the above guide with the following changes:

script name: snapup.sh
script content:
#!/bin/bash
sleep 0.1 && wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -e 0,0,0,`xwininfo -root | grep Width | awk '{ print $2 }'`,`xwininfo -root | grep Height | awk '{ print (($2/2)-40)}'`
binding key: Mod4 + Super_L + Up

script name: snapdown.sh
script content:
#!/bin/bash
sleep 0.1 && wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -e 0,0,`xwininfo -root | grep Height | awk '{ print (($2/2))}'`,`xwininfo -root | grep Width | awk '{ print $2 }'`,`xwininfo -root | grep Height | awk '{ print (($2/2)-40)}'`
binding key: Mod4 + Super_L + Down

2014. május 26.

Mplayer for music

I would like to have something like this:

1.) nautilus script
right click on file/dir to copy full path of file/dir
2.) text file
to paste the full paths of to be played items or dirs
3.) utility to handle the text file as a playlist

Description of the utility:
- uses mplayer to play audio/video files
- reads the first line of the text file, starts to play it, than deletes it so the second line becomes the new first line (alternately it moves the line to another text file's end, so the user can go backward in the playlist)
- user can edit the text file on-the-fly between tracks (edit playlist while playing)
- utility should be fool-proof (in case of wrong input it should pause and wait for user to correct error in playlist)


2014. március 16.

DJVU extract images

A useful link:
http://askubuntu.com/questions/46233/converting-djvu-to-pdf

Another useful link: http://unix.stackexchange.com/questions/20592/extract-several-pages-from-a-djvu-file
http://kheyali.blogspot.hu/2011/08/in-order-to-convert-djvu-file-into.html

And another: http://en.wikisource.org/wiki/Help:DjVu_files#DjVu_to_Images


Extract images from DJVU:
DDJVU
The easiest way to do this is probably by extracting to multipage tiff
Than split tiff file with tiffsplit: http://manpages.ubuntu.com/manpages/hardy/man1/tiffsplit.1.html
Than convert to anything useful.
Except that did not work for the file I had...

Okay, so the second way is the script way. Copy the script, paste it to an empty text file. Give it the extension .sh and give it permission to execute as program. Put it in a directory with all the djvu-s you want to extract and run in terminal.

#!/bin/bash
#Ubuntu 10.04 Lucid Lynx

#Put this script file in a directory with all the djvu-s you want to extract and run it in terminal.
#All the DJVU-s in this folder will be extracted to PNM-s.

### Select files to process
#defining the filelist
filelist=(`find -iname '*.djvu' | sort`)
#counting the files in the filelist
element_count=${#filelist[*]}
echo "alltogether $element_count djvu will be processed"

#process only 1 file at a time:
counter=1
echo "processing file:"
for i in "${filelist[@]}"
do
echo -ne "$element_count/$counter"\\r

#Get the number of pages from input file
pagecount=`djvused -e n $i`
#Set a filelist for the pages
 for (( filelist=1; filelist<=$pagecount; filelist+=1 ))
 do
 #Extract with DDJVU
 ddjvu -format=pnm -page=$filelist $i file_$counter.page_$filelist.pnm
 #Or use DjvuPs to extract PS from DJVU the same way:
 #djvups -page=$filelist $i file_$counter.page_$filelist.ps
 done
let "counter = $counter + 1"
done

echo DONE.

2012. december 31.

Scanning script for SCANIMAGE

As I wrote before, the program called scanimage cannot scan to numbered files repeatedly.
Well, not anymore.

I wrote a little script to automate the scanning.
I did this because I dislike gscan2pdf scanning to temp. I find it too risky not having the file in a safe place after scanning.

#!/bin/bash
#Ubuntu 10.04 Lucid Lynx

#Automatization of "scanimage" to create sequentially numbered output.

#START
echo "WELCOME TO AUTOMATED SCANIMAGE"
echo ""

echo "Please give me the size of scan area in mm"
echo -n "width: "; read x
echo -n "height: "; read y
#make it failsafe:
if [[ $x>213.8 || $x = "" ]]; then x="213.8"; fi
if [[ $y>300 || $y = "" ]]; then y="300"; fi

echo "Scan area will be: $x x $y mm"
echo ""

echo "Please choose scan mode: L for Lineart, G for Gray. Press enter for Color."; read mode
#make it failsafe:
if [[ $mode == [Ll] ]]; then mode="Lineart" && ext="pbm"
elif [[ $mode == [Gg] ]]; then mode="Gray" && ext="pnm"
else  mode="Color" && ext="pnm"
fi

echo "Scan mode will be $mode"

#print "to start printing press enter to quit press escape"
#scan and save
#go back to enter or escape
date=1
while true; do
 echo -n "Press 'enter' to scan; anything else to quit' "; read scan;
 if [[ $scan = "" ]]; then
  let "date =`date +%Y%m%d%H%M%S`"
  echo "Scanning will progress with the following parameters:"
  echo "size: $x x $y, mode $mode, filename: $date.$ext"
  scanimage -x $x -y $y --mode $mode > $date.$ext
 else break
 fi
done

echo "Finished scanning. Thank you for using this script :-*"

2010. május 23.

Screen rotation through Nautilus scripts.

Here is how you make nautilus scripts work.

This is a script for rotating right (note-taking side):
#!/bin/sh
xrandr -o right
xsetwacom set 'Serial Wacom Tablet' Rotate CW
This is to set back to normal:
#!/bin/sh
xrandr -o normal
xsetwacom set 'Serial Wacom Tablet' Rotate NONE
I also use the following two, so I can rotate in any direction:
#!/bin/sh
xrandr -o left
xsetwacom set 'Serial Wacom Tablet' Rotate CCW
and
#!/bin/sh
xrandr -o inverted
xsetwacom set 'Serial Wacom Tablet' Rotate 3

2010. március 7.

Image rotation nautilus script in the right click menu

create folder:
/home/user/.gnome2/nautilus-script

create files:
"Rotate CW"
"Rotate CCW"
"Rotate 180"

edit these in gedit, and than make them executable.

This is the script for Rotate CW:
#!/bin/bash
mogrify -rotate 90 $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
for CCW use 270 and for 180 use 180 instead of 90.

2008. június 15.

Updating to Gutsy

After some time the pen just crashed: after using the pen none of the pointing devices would do a click.
So I updated to Gutsy.
...
Ta-damm:
- the scroll joystick on the edge of the monitor works out os the box.
- the 3 tablet button just don't work with the previous script.
- I had to reinstall linuxwacom to fix the pen buttons.
- Firefox works with Flash :-)
- I had to change the rotate script to this:
#!/bin/sh
if [ -n "$(xrandr | grep "768x1024+0+0 right")" ]; then
 xrandr -o inverted
 xsetwacom set "stylus" Rotate 3
else
 if [ -n "$(xrandr | grep "1024x768+0+0 inverted")" ]; then
 xrandr -o normal
 xsetwacom set "stylus" Rotate NONE
else
 if [ -n "$(xrandr | grep "1024x768+0+0")" ]; then
 xrandr -o right
 xsetwacom set "stylus" Rotate CW
fi
fi
fi