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

2017. április 6.

How to make .sh files run on double click?

In Ubuntu 16.04 LTS unlike in previous LTSs executable shell script files when double clicked open automatically for editing instead of seeing a popup asking what to do with them.

To restore the confirmation popup do as it is said in this askubuntu post: make sure your file manager supports executing files:
$ gsettings set org.gnome.nautilus.preferences executable-text-activation ask
Alternatively:
  1. Open dconf Editor
  2. Navigate to org.gnome.nautilus.preferences
    1. Set the 'executable-text-activation' to 'ask'

2015. április 8.

Command Line alternative to Safely Remove Drive

Recently my external USB drives (HDD, Pendrive, Kindle, mobile phone) stopped detaching itself after unmount.
Obviously I would not plug out a HDD with 750GB data that is still spinning. But it does not want to stop at all. I can mount and umount it and it is still spinning. (Or whatever these new drives does instead of spinning)

So the solution is to do the command line equivalent of safely remove in two steps:
1. unmount
2. detach

The solution I found on askubuntu:

For a practical example, if I have the partition /dev/sdb1 mounted, I would run this to unmount and detach it:
udisks --unmount /dev/sdb1
udisks --detach /dev/sdb

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 8.

Gnome Flashback Services personalization on Ubuntu 14.04 LTS

 Here are the settings and adjustments I made on Gnome Flashback Services (with Metacity) to meet my needs:

Setting up HP Compaq TC4400's native features

Pen features
  • Pen, eraser and button are recognized out of the box.
  • Pressure sensitivity has to be set specifically for the software you use.
  • Gimp setup for pen usage (pressure sensitivity and differentiation between the pen and the eraser:
    Gimp > Edit > Input devices > Serial Wacom Tablet eraser/stylus > set Mode "screen"
Screen rotation
On-screen buttons
  • Ctrl-alt-del button is recognized out of the box.
  •  Jog dial for scrolling: the code in my previously published solution works fine.
  • Pen activated buttons: not working. Linked solution have not been tested.
  • Fingerprint Sensor: not working. No possible solution have been tested.
  • Ambient Light Sensor: not working. No possible solution have been tested.

Setting up everything else

Terminal:

Terminal usage
  • works as usual. 
  • keyboard shortcut (native) to open: Ctrl+Alt+T
Bash scripts


Desktop:
 
 Workspaces:
  • works as usual (although only in Metacity version of Gnome2 Flashback)
  • to configure: right click on the workspaces icon in the bottom right corner of the screen > Preferences
  • keyboard shortcut (native) to navigate between workspaces: Ctrl+Alt + arrow keys
Menu panel (top and bottom) customization:
  • works as usual (except for how to reach the right click menu)
  • Alt+ right click to reach the panel menu


Synaptic Package Manager
  • install from Software Center
  • works as usual


File manager 

Nautilus
Nautilus went through major changes since Lucid Lynx, so let's see what remains of it:
  • Nautilus was renamed to "Files"
  • Compact View --> removed
  • File or folder selection by simply typing --> still exists
  • New Document > Empty Document --> still exists
  • Menu bar --> removed.
  • Menu button --> added. It's a gear wheel icon in the top right corner
  • ‘Go’ menu --> removed
  • Enter Location... --> added
  • F3 split screen --> removed (this is most annoying!)
  • Tabs --> still exists.
  • ‘tree’ view --> not default for List view, but you can set it in Preferences
  • Bookmark menu --> still exists. Only shown if there are items in it. 
  • Locations' default bookmarks --> added. Cannot be removed and icon cannot be changed, but name and location can be edited.
  • Backspace shortcut to return to parent folder --> still exists.
Nautilus scripts
  • Scripts folder was moved from /home/user/.gnome2/nautilus-scripts to /home/user/.local/share/nautilus/scripts
  • Right clicking to reach Scripts menu only works when you click on a file or folder.
  • Otherwise works as usual.
  • A graphical user interface to manage nautilus scripts now exists.
 Nemo
 Nemo is an alternative to "Files" (Nautilus).

  • can be installed from Software Center ("Files (nemo)")
  • works just like the good old Nautilus, with F3 dual pane and every other feature.
Nemo scripts
  • works just like Nautilus scripts.
  • scripts folder is /home/user/.gnome2/nemo-scripts
I chose Nemo as my default Ubuntu 14.04 File manager.
To set Nemo to be the default file manager, you have to follow these steps:
  1. To make Nemo the default file manager run in terminal:
    xdg-mime default nemo.desktop inode/directory application/x-gnome-saved-search
  2. To make Nemo handle the desktop run in terminal:
    gsettings set org.gnome.desktop.background show-desktop-icons false
    gsettings set org.nemo.desktop show-desktop-icons true
    
  3. (Optionally) To remove desktop shortcuts created by Nemo run in terminal:
    gsettings set org.nemo.desktop home-icon-visible false; gsettings set org.nemo.desktop trash-icon-visible false; gsettings set org.nemo.desktop computer-icon-visible false; gsettings set org.nemo.desktop volumes-visible false
    
More information on Nemo can be found here and here.

2013. június 26.

Nautilus Open-in-terminal

Beside of using Nautilus script to open a specific nautilus folder in terminal,
it is possible to use the nautilus-open-terminal software.

Download it with
sudo apt-get install nautilus-open-terminal
Then restart nautilus with logging out and in again, or with
nautilus -q
This should do the trick.
&& Have fun using it!

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.