Showing posts with label OPEN WITH. Show all posts
Showing posts with label OPEN WITH. Show all posts

Sunday, 10 March 2013

Why should we use Nautilus Actions?

 Nautilus is the default file manager on GNOME desktop. Nautilus-Actions is an extension for Nautilus file manager which allows one to launch arbitrary applications on files. "Actions" brings in the coolness that is missing in Nautilus. Simply put, it allows you to automate some of the daily activities on your desktop like:-
  • Changing Ownership of files.
  • Converting images from png to jpg.
  • Creating desktop shorcuts.
  • Enqueue audio, video files into media players.
  • Invoking "Fortune".
  • Open file as Admin mode.
  • On demand Virus scanning of files.
  • Running a Jar. etc...
  All of the above list of activities can be implemented without referring any bulky manual. Using Nautilus-Actions, we can pack lot of custom functions into the right click (or) context menu.
Install Nautilus Actions on openSUSE 12.2, GNOME 3.4.2
Step1:-
 First we need to configure community repos in YaST. The procedure would be similar to what is described here.
Step 2:-
 After configuring YaST we can install Nautilus-Actions using either YaST or Zypper.
Installation using Zypper
sudo zypper in nautilus-actions
Notes:- sudo switches permissions to super user; zypper is the package manager in openSUSE; in instructs zypper to install packages
Installation using YaST
 It is pretty easy to install packages using YaST. All one needs to do is open YaST installer and locate relevant packages (nautilus-actions) and install them. Here is a video (YaST Installer Video Demo) demonstrating installation of packages using YaST.
Launch Nautilus-Actions Configuration Tool
  After installation you can easily locate Nautilus-Actions in GNOME Shell Activities(Alt+F1)by searching for "Actions" as shown below.
Gnome Shell Activities Nautilus Actions
 Alternatively you can launch it using the command "nautilus-actions-config-tool" from Quick launcher (or) Command launcher (Alt+F2).
Alt+F2 nautilus-actions-config-tool
Using Nautilus-Actions Configuration Tool
 Using the configuration tool is very easy. You can easily figure out various things by reading various Tooltips that are available in the tool. For example, one can find the functionality of each tab by hovering the mouse on top of them as shown below.
Nautilus Actions Tooltip
Creating "Change File Owner" Menu
 Let us start off by creating a simple menu that allows us to create a context menu to change ownership of selected files to that of logged-in user. We use the "chown" command to accomplish this.Click on the create "New Action" icon or press "Ctrl+N" to create a menu item. Then you can provide an appropriate name for the menu entry.
Creating Change File Owner Menu
 Then we open the "Command" tab and configure the relevant commands to change the ownership of selected files. In "Path" textbox you can provide the path to the executable or you can just type in the command alone. In the "Parameters" textbox you can type in the parameters like "user" to whom the file should belong to and %F which represents coma separated list of file names. By clicking the "Legend" button you can get the various parameter options that are available for use.
Change File Owner Command
 If you would like to see output of command in an alert box, then you can configure the same in "Execution" tab and by selecting "Display output" option.
Change File Owner Display Output
Checking whether "Change Owner" works
 I have created a sample text file and made "root" user as it's owner. Now we see a "X" icon on the file indicating that the file is not "owned" by the logged-in user. We now use our newly created context menu and check whether we can change the owner of the file.
Change File Owner Test
 After supplying root password we find the command execution in an alert.
Change File Owner Execution Output
 When we right click on file now and check the file properties, we find that the logged in user or "mantis" is the owner of the file. The context menu works :-)
Change File Owner Successful
On Demand Virus Scanning
 ClamTk(Anti-Virus Scanner) can be installed using "1 Click Install" links from this page. After installing clam you can create a custom "Clam Scan menu" to scan selected files.
On Demand Virus Scan Using ClamTk
Image Conversion using right Click Menu
 Images can be converted from one format to another using a command line tool called "ImageMagick". It can be installed using "1 Click Install" links from here. After installation we can create a custom menu to convert images from one format to another. Assuming that we need to convert "png" files to "jpg" file, we need to implement the command "mogrify -format jpg <source>.png". It can be done as shown below.
File Conversion png to jpeg
 To ensure that the image conversion context menu appears only on "png" files and not on any other file format like "jpg" we need to add "MimeType" data in Nautilus-Actions. To do this, we right click and find Mimetype data in properties of files for which the conversion menu should appear as shown below.
png Nautilus properties Mime
 Then we add the MimeType in the relevant tab as shown below
Nautilus Actions Add png Mimetype
Convert Png To Jpeg menu appears only in "png" type files.
Menu appears only in "png" type files
Convert Png To Jpeg doesn't appear on "jpeg" type files.
Menu doesn't appear on "jpg"  files
Enqueue Music Files in Banshee
 Banshee is a media player which has cool music library management capabilities. It can be installed using "1 Click Install" links from this page. After installing banshee we should find the proper command line command for enqueuing media files to it. The command need to do this happens to be "banshee --play-enqueued %F". We need to use this information to create the custom nautilus action as shown below.
Enqueue Music Files Banshee
 To Ensure that the Enqueue context menu appears only on mp3 files we need to use the same technique as described above to add relevant MimeTypes in Nautilus-Actions.
Nautilus Action Add Mimetype Banshee
Read Fortune in Pop up
 To have some fun, you can try setting up "fortune" in context menu and read it. To do this we can use "zenity" library which can provide alert windows for bash scripts. The command that can be used is " /bin/sh -c 'fortune|zenity --text-info' ". This command can be entered as follows and a custom right click menu can be created as shown below.
zenity fortune nautilus actions
The fortune output will be shown in zenity like this
zenity fortune
Run Jars using Right Click
 The command to run jars is "java -jar <jarname>.jar". You can can configure this command and run jars using Nautilus-Actions as shown below.
Run Java Jar Nautilus Actions
Open folder as Super User
 You can open any folder in Super User or Root User by creating a context menu as shown below.
Open Folder As Root Nautilus Actions
Create Desktop Shortcuts
 In Linux, in order to create desktop shortcut or "link" you can use the command "ln -s /<path-to-file>/<filename> ~/Desktop". The same command be incorporated into Nautilus context menu as shown below.
Nautilus Actions Create Desktop Shortcut ln

Thursday, 14 February 2013

Changing right click options for files on GNOME 3.4.2, openSUSE 12.2

 I had earlier written about forcing programs to appear in open with list. There is one more method of :-
  • Adding file associations / context menu / right click entries.
  • Setting order of programs for opening in context menu.
  • Setting default program for a file type.
on GNOME 3.4.2 / openSUSE 12.2, all in a single shot.
I am taking a Flash video as a sample and i find the file associations as shown below and I set about modifying it.
Context Right Click Menu Nautilus Flash Video
Step 1
 Find the file mimeapps.list on your machine. It will be under the folder path as shown below.
~/.local/share/applications/mimeapps.list
Step 2
 Check the file type or mime type of the file by right clicking and checking properties. Since I am taking a Flash video as a sample, I find that mime type is (video/x-flv).
Nautilus properties Flash Video
Step 3
 Open it in your favourite text editor. I am using gedit to edit the file. Open command launcher (Or) quick launch window (Alt+F2) and type in following commands followed by return or enter key to edit the file.
gnome-text-editor /home/<profileFolder>/.local/share/applications/mimeapps.list
(Or)
gedit /home/<profileFolder>/.local/share/applications/mimeapps.list
Flash Video mimeapps.list
Step 4
 After opening the file we will find some existing entries in the file. Don't remove any existing entries. Just append any new entries at the end. After deciding on the default application for a file we make an entry under "Default Applications". Then we put this default application first under "Added Associations" and then add subsequent entries as shown below. Save and exit the file.
[Added Associations]
video/x-flv=gnome-mplayer.desktop;banshee.desktop;totem.desktop;
(Or)
[Default Applications]
video/x-flv=gnome-mplayer.desktop
When we check the context menu of the Flash video again we will see the changes reflected.
Flash Video revised Context Menu Nautilus

Saturday, 8 December 2012

Nautilus 3.4.2 open as administrator hack

  Nautilus "open as admin" hack is about opening Nautilus in administrator mode to quickly change permissions, ownership of files and folders. This hack will add an "openAsAdmin" menu to the context menu or right click. This hack has been tested on openSUSE 12.2 / GNOME 4.3.2. Here goes the explanation. I have two users on my system, "mantis" and "test". I am logged in as mantis and I see "x" or cross marks on the files in my folder indicating that "mantis" doesn't own this file. The link "series.txt" is being owned by "test".
Nautilus File Properties Permissions
 I open command launcher (ALT+F2) and type in the command "alacarte" and hit return / enter key. This will open GNOME 3.X menu editor. I add an new entry by pressing the "New Item" button as shown below. The Command that needs to be added  is "gnomesu nautilus %U".
Nautilus Open As Administrator Menu Alacarte
 Now when i right click on the any file that I need to change permission I find the "OpenAsAdmin" menu under "Open With" ==> "Other Applications". When i invoke this menu it asks me enter administrator password or passcode.
Nautilus Open As Administrator Context Menu
 After entering the passcode i see a new Nautilus widow running in administrator mode and this will allow me to change the permissions and ownership of various files and folders using the "properties" menu, permission tab as shown below. After finishing things we simply need to close the nautilus window running in administrator mode.
Nautilus File Change Owner Permissions

Sunday, 28 October 2012

Execute Jars on GNOME 3.4.2 openSUSE 12.2


 I had earlier written about a generic way of Running executable jar files on GNOME. I found a much cooler way of executing jar files. It involves adding a menu entry(.desktop file) in GNOME 3.X desktop and then forcing this menu entry to appear in open with list using a "%U" at the end. This will make the jar execution command appear on the context menu or right click menu of the jar. Ensure that you have a JRE or JDK on your system. For installing JRE on your openSUSE 12.2 you can take a look at this post.
 Launch Alacarte through quick launch window(use command "alacarte" after pressing Alt+F2) and add menu entry "java -jar %U" as shown below. A new entry can be created by clicking the "New Item" button. In the pop up window you can give any name like "Jar" against Name entry and provide comments like "Cool way to run jar". The %U ensures that the launcher will appear on "open with" list.
  After making the menu entry right click on any jar and choose the  "Open With Other Application" menu.
 Then choose the menu entry named "Jar" in the dialogue box as shown below.
 Now the "Jar" entry will get permanently added to your context menu and will always be handy when you need to run a Jar
 To set the application's default action on double click you need to right click and choose "Properties". You need to choose "Open With" tab and then choose the relevant application launcher and the "Set as default" button.

Thursday, 16 February 2012

Force programs to appear in open with list GNOME 3.2.1 / openSUSE 12.1

 I have recently started using AbiWord / Gnumeric combination on my system ( GNOME 3.2.1 / openSUSE 12.1) instead of LibreOffice because
==> Every time LibreOffice has some updates I need to download / update about 200 MB worth of packages.
==>I don't have much use for office software at home except for the occasional viewing of an word document or making small calculations in spreadsheet
==> I don't almost never use the database "libreoffice-base" or  drawing "libreoffice-draw" or presentation "libreoffice-impress" software at home.
==>LibreOffice appears to be quite sluggish compared to AbiWord or Gnumeric
How To Get and install AbiWord / Gnumeric ?
==>One can Install the latest available AbiWord on GNOME 3.2.1 / openSUSE 12.1using 1-Click Install.Alternatively you can explore other available versions / download / install from rpms here
==>Similarly , One can Install the latest available Gnumeric on GNOME 3.2.1 / openSUSE 12.1using 1-Click Install . Alternatively you can explore other versions / download / install from rpms here
How To make programs like AbiWord which don't appear in open with context menu (OR) right click menu of your mouse appear on the open with application list ?
The only hiccup I faced in using AbiWord is that  recently I was not able to change the default file association for "docx" document . Hence I had to try and fix the file association to the correct application.GNOME / Nautilus was trying open a "docx" document using File Roller "Archive Manager".
The docx document I was trying to open using AbiWord
Nautilus trying to use File Roller to open docx document
"open with" menu in context menu not showing AbiWord
Even the open with tab in the properties windows of the docx document failed to show AbiWord to set as default application
All I needed to do was to open Alacarte application and add a parameter %U to the program command like "abiword %U" and restart GNOME 3 shell / desktop by pressing "Alt+F2" following by keying in 'r' and hitting return / enter key. Poof !!! the miracle happens.
Alacarte can be located by pressing left "windows" key in keyboard followed by clicking on Applications tab on top left end of the screen and choosing Accessories node in the tree on the left hand side. One can also type in Alacarte after moving the mouse over the hot spot on the top left hand side of the screen to locate the application.
You can also invoke "Alacarte" using "Alt+F2" command launch window
 Command Launch Alt+F2 Alacarte
Add %U after command in Alacarte and hit close button
Screen shots after Fix
AbiWord appears in open with list in right click / context menu
AbiWord appears also in open with list in open with tab when we right click on the document and select properties menu.In this window we can set an application as the default file handler
Right click after fixing the file handler / file association