請問怎麼在圖形介面用script開啟檔案 - Linux

By Zenobia
at 2015-06-03T16:51
at 2015-06-03T16:51
Table of Contents
(這個問題已經解決,新問題在下方)
最近有在用MPV player,想要自己寫一套規則來開啟影片
幀率60or30fps的用設定A
幀率24fps的用設定B
亂七八糟的就設定C
-----------------------------------------------------------------------------------------
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#用mediainfo取得影片幀率
FrameRate=$(mediainfo --Inform="Video;%FrameRate%" $1)
#把幀率取整數
intFPS=${FrameRate%.*}
if [ $intFPS == 59 ] || [ $intFPS == 60 ] || [ $intFPS == 29 ] || [ $intFPS == 30 ]; then
#A設定
mpv --profile=pseudo-gui --vo=opengl-hq:icc-profile-auto --sub-auto=fuzzy $1
echo "60"
elif [ $intFPS == 23 ] || [ $intFPS == 24 ] || [ $intFPS == 25 ]; then
#B設定
mpv --profile=pseudo-gui --vo=opengl-hq:interpolation:icc-profile-auto --sub-auto=fuzzy $1
echo "24"
else
#C設定
mpv --profile=pseudo-gui
echo "nothing"
fi
exit 0
-----------------------------------------------------------------------------------------
這個script在終端機裏面可以正常執行,我是打$bash MPV.sh 影片路徑
為了要能夠從圖形介面打開影片直接使用這設定,
我在/usr/share/applications/mpv.desktop裏面把Exec後面的指令改成
Exec=/home/使用者名稱/bin/MPV.sh -- %U
但不管我開了哪個檔案都沒辦法帶入A跟B的設定,
請問要怎麼像指令一樣把檔名帶入到 $1 這個變數裏面呢?
--
最近有在用MPV player,想要自己寫一套規則來開啟影片
幀率60or30fps的用設定A
幀率24fps的用設定B
亂七八糟的就設定C
-----------------------------------------------------------------------------------------
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#用mediainfo取得影片幀率
FrameRate=$(mediainfo --Inform="Video;%FrameRate%" $1)
#把幀率取整數
intFPS=${FrameRate%.*}
if [ $intFPS == 59 ] || [ $intFPS == 60 ] || [ $intFPS == 29 ] || [ $intFPS == 30 ]; then
#A設定
mpv --profile=pseudo-gui --vo=opengl-hq:icc-profile-auto --sub-auto=fuzzy $1
echo "60"
elif [ $intFPS == 23 ] || [ $intFPS == 24 ] || [ $intFPS == 25 ]; then
#B設定
mpv --profile=pseudo-gui --vo=opengl-hq:interpolation:icc-profile-auto --sub-auto=fuzzy $1
echo "24"
else
#C設定
mpv --profile=pseudo-gui
echo "nothing"
fi
exit 0
-----------------------------------------------------------------------------------------
這個script在終端機裏面可以正常執行,我是打$bash MPV.sh 影片路徑
為了要能夠從圖形介面打開影片直接使用這設定,
我在/usr/share/applications/mpv.desktop裏面把Exec後面的指令改成
Exec=/home/使用者名稱/bin/MPV.sh -- %U
但不管我開了哪個檔案都沒辦法帶入A跟B的設定,
請問要怎麼像指令一樣把檔名帶入到 $1 這個變數裏面呢?
--
Tags:
Linux
All Comments

By Margaret
at 2015-06-05T02:31
at 2015-06-05T02:31

By Blanche
at 2015-06-05T21:56
at 2015-06-05T21:56

By Kelly
at 2015-06-10T06:17
at 2015-06-10T06:17

By Irma
at 2015-06-12T19:54
at 2015-06-12T19:54
Related Posts
xterm 開啟新視窗並自動執行指定 shell

By Bethany
at 2015-06-03T10:39
at 2015-06-03T10:39
Centos 6.x 使用 OpenLDAP 驗證登入

By Mary
at 2015-06-03T10:22
at 2015-06-03T10:22
Debian 套件打包工作坊

By Caitlin
at 2015-06-02T20:17
at 2015-06-02T20:17
Fedora 22 Released

By Megan
at 2015-06-02T06:51
at 2015-06-02T06:51
Centos 6.x 使用 OpenLDAP 驗證登入

By Elizabeth
at 2015-06-01T22:29
at 2015-06-01T22:29