LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to start associated app in KDE (https://www.linuxquestions.org/questions/linux-software-2/how-to-start-associated-app-in-kde-296524/)

redss 03-01-2005 09:34 PM

How to start associated app in KDE
 
In my Debian Linux, if you go to a bash prompt and type "picture.jpg", you get an error message. However in KDE, you can hit

Alt-F2 and type "picture.jpg" and KDE will launch the associated application for picture.jpg.

In windows 9x, you can start the associated application from the command prompt with the "start" command ("start

picture.jpg"). (Even easier in windows 2000/XP, where you can just type "picture.jpg")

Is there a linux command where I can kick off the associated app from a bash prompt, like the windows "start" command?

bulliver 03-01-2005 10:17 PM

Uh, not that I know of...

You do realize that you can usually pass the name of a file to the program you want to open it with right?

ie:
$ xmms foobar.mp3
$ gqview foobar.jpg
etc etc...

Not what you are asking for I know, but I think that is as close as you are going to get.

heema 03-02-2005 02:15 AM

its just a thought , but why dont you make a script so that it could read the extension and launch the desired app

e.g: if the name of the script is ifile then you will type : ifile picture.jpg

i wrote a similar script but to exctract compressed file , mount iso images and install RPM and DEB files , you could look at it and change it to your need

Code:

#!/bin/bash

##############################################
# ifile v0.3
#
# Usage : ifile filename
#
# Created by : Heema
##############################################

FILENAME=$1

echo ""

echo -e "Checking filename extension ................ " "[" "\033[0;32mDone\033[0m" "]"

EXTENSION=$(file $FILENAME | awk '{ print $2 }')

echo ""

##############################################
# Uncompress files
##############################################

case "$EXTENSION" in

##############################################
# zip
##############################################

Zip)
        echo -e "This is a" "\033[0;31m$EXTENSION\033[0m" "file"
        echo ""
        unzip "$FILENAME"
        echo ""
        echo -e "\033[0;32mDone\033[0m"
        echo ""
;; 

# bz2

#if [ "$EXTENSION" == "bz2" ];then
#        echo -e "This is a" "\033[0;31m$EXTENSION\033[0m" "file"
#        echo ""
#        bunzip2 "$FILENAME"
#        echo ""
#fi

# gz

#if [ "$EXTENSION" == "gz" ];then
#        echo -e "This is a" "\033[0;31m$EXTENSION\033[0m" "file"
#        echo ""
#        gunzip "$FILENAME"
#        echo ""
#fi

##############################################
# tar
##############################################

POSIX)
        echo -e "This is a" "\033[0;31m$EXTENSION\033[0m" "file"
        echo ""
        tar xvf "$FILENAME"
        echo ""
        echo -e "\033[0;32mDone\033[0m"
        echo ""
;;

##############################################
# tar.gz
##############################################

gzip)
        echo -e "This is a" "\033[0;31m$EXTENSION\033[0m" "file"
        echo ""
        tar xvzf "$FILENAME"
        echo ""
        echo -e "\033[0;32mDone\033[0m"
        echo ""
;;

##############################################
# tar.bz2
##############################################

bzip2)
        echo -e "This is a" "\033[0;31m$EXTENSION\033[0m" "file"
        echo ""
        tar xvjf "$FILENAME"
        echo ""
        echo -e "\033[0;32mDone\033[0m"
        echo ""
;;

##############################################
# rar
##############################################

RAR)
        echo -e "This is a" "\033[0;31m$EXTENSION\033[0m" "file"
        echo ""
        unrar x "$FILENAME"
        echo ""
        echo -e "\033[0;32mDone\033[0m"
        echo ""
;;

##############################################
# Install packages
##############################################

##############################################
# Rpm
##############################################

RPM)
        echo -e "This is a" "\033[0;31m$EXTENSION\033[0m" "file"
        echo ""
        sudo rpm -Uvh "$FILENAME"
        echo ""
        echo -e "\033[0;32mDone\033[0m"
        echo ""
;;

##############################################
# Deb
##############################################

Debian)
        echo -e "This is a" "\033[0;31m$EXTENSION\033[0m" "file"
        echo ""
        sudo dpkg -i "$FILENAME"
        echo ""
        echo -e "\033[0;32mDone\033[0m"
        echo ""
;;

##############################################
# Iso
# Mount and unmount iso file
##############################################

ISO)
      echo -e "This is a" "\033[0;31m$EXTENSION\033[0m" "file"
      echo ""
      if [ ! -d /mnt/iso ];then
              sudo mkdir /mnt/iso
              sudo mount -o loop -t iso9660 "$FILENAME" /mnt/iso
              echo -e "Making mount directory and mounting......  " "[""\033[0;32mDone\033[0m" "]"
              echo ""
              echo -e "\033[0;32mDone\033[0m"
              echo ""
              exit
      fi

      if [ -d /mnt/iso ];then
              sudo umount -d /mnt/iso
              sudo rmdir /mnt/iso
              echo -e "File unmounted and directory removed...... " "[""\033[0;32mDone\033[0m" "]"
              echo ""
              echo -e "\033[0;32mDone\033[0m"
              echo ""
              exit
      fi

;;

##############################################
# Add plugins here
##############################################


##############################################
# End
##############################################

# Not supported

*)
        echo -e "\033[0;31mThis format is not supported\033[0m"
        echo ""
;;

esac



All times are GMT -5. The time now is 10:19 PM.