Thursday, April 25, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 795  / 2 Years ago, wed, april 20, 2022, 1:18:13

I am trying to find a way to create a shortcut for opening a pdf file with a particular application. This is what i do currently(manually):


Step 1. I have a pdf file say MyBook.pdf. I right click on this pdf so that a popup window appears with many options like:


Cut


Paste


Copy


Open with other application


Move to trash


Step 2. I chose/click Open with other application from the above menu and a new popup menu opens up with different options like:


Document Viewer


Google Chrome


Text Editor


Sublime Text


Okular


Step 3. I chose Okular from the above menu and the pdf opens up using Okular.


What i want is that these 3 manual steps should be encapsulated in keyboard shortcut like Ctrl + O + P


Is this possible in Ubuntu 18.04 ?


PS:
I am using nautilus-folder-handler.desktop on Ubuntu 18.04


Summary


I want to be able to select any arbitrary pdf by single left click and then press a custom shortcut key that will open that selected pdf using a particular application such as okular.


I noticed that there is options like Ctrl+C for copying Ctrl+X for moving, Ctrl+I for checking the properties of a file just by a single left click and then pressing the corresponding shortcut. I want to do exactly this. That is the user left clicks one time on a file and then press the shortcut which will open the file with a given application.


More From » 18.04

 Answers
6

This is a two step process.


Step 1
This is exactly the same as answered by @Jacob Vlijm. That is



  1. Create (if necessary) the directory ~/.local/share/nautilus/scripts

  2. Create a file with executable permission and name it whatever you like. For example, create a file named openwithokular and put the following content inside it:


#!/bin/bash
okular "$1"

The result of step 1 is that if you right click on any file now then a script menu option will appear which will contain the option openwithokular and when you click on the openwithokular option the file will open with okular.


Step 2



  1. Create the file(if required) ~/.config/nautilus/scripts-accels



  2. Add the following content inside it and save it:




F4 openwithokular

Note: Make sure to restart your pc otherwise it won't work.


The result of step 2 is that now there will be a keyboard shortcut associated with the menu option openwithokular inside the scripts menu option obtained from step 1. And this is what we wanted. Now you can just left-click on any file and press the shortcut you have set and the file will open with okular(or any app that you have set). This method is tested to work on Ubuntu 18.04 and Ubuntu 20.04.


[#1145] Thursday, April 21, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
uxuriousrnal

Total Points: 279
Total Questions: 106
Total Answers: 96

Location: Fiji
Member since Wed, Mar 29, 2023
1 Year ago
uxuriousrnal questions
Wed, Mar 9, 22, 09:04, 2 Years ago
Mon, Jul 18, 22, 01:48, 2 Years ago
Wed, Apr 13, 22, 01:15, 2 Years ago
Thu, Aug 26, 21, 22:01, 3 Years ago
;