使用gnome中的bash脚本打开文件

Leetwanker

我写了一个处理视频文件的bash脚本,我想将视频打开到其中,而不必在终端中导航到它们。

$ ~/script.sh video.mp4 它是如何从终端运行的。

我尝试用打开视频,gnome-terminal -e ~/home/user/script.sh但似乎没有捕获文件名/路径。我正在使用Nemo文件管理器。

在寻找解决方案时,我还无法提出任何建议。

如果相关,这就是我将filename参数传递给脚本的方式。(可能不是最好的方法)

#!/bin/bash
args=("$@")
in_file=${args[0]}

更新:我已经创建了这个.desktop文件。

[Desktop Entry]
Comment=
Terminal=true
Name=fixvideo
Exec=/home/user/fixvideo.sh %f
Type=Application
Icon=/usr/share/icons/gnome/48x48/apps/gnome-settings-theme.png
Encoding=UTF-8

如果我将视频文件放在桌面图标上,它将正常工作。但是,在Nemo(或Nautilus)中使用“打开方式”无效。

汤姆·颜

我认为您可能想为bash脚本编写一个.desktop文件,该文件可以与视频文件关联(“以...打开”):https : //specifications.freedesktop.org/desktop-entry-spec/ desktop-entry-spec-latest.html

https://developer.gnome.org/integration-guide/stable/desktop-files.html.en

将此文件放在/ usr / share / applications目录中,以便每个人都可以访问;如果只希望单个用户可以访问,则在〜/ .local / share / applications中。

leetwanker编辑:这是我最终制作的.desktop文件。我宁愿将其保留在自己的帖子中,但显然,这里的mod对此并不满意。

我已经在以下位置创建了这个fixvideo.desktop文件 ~/.local/share/applications/

[Desktop Entry]
Comment=
Terminal=true
Name=fixvideo
Exec=/home/user/fixvideo.sh %f
Type=Application
Icon=/usr/share/icons/gnome/48x48/apps/gnome-settings-theme.png
Encoding=UTF-8
Hidden=false
NoDisplay=false
Categories=AudioVideo;Player;Recorder;
MimeType=video/dv;video/mpeg;video/x-mpeg;video/msvideo;video/quicktime;video/x-anim;video/x-avi;video/x-ms-asf;video/x-ms-wmv;video/x-msvideo;video/x-nsv;video/x-flc;video/x-fli;video/x-flv;video/vnd.rn-realvideo;video/mp4;application/mp4;video/mp4v-es;video/mp2t;application/ogg;application/x-ogg;video/x-ogm+ogg;audio/x-vorbis+ogg;audio/ogg;video/ogg;application/x-matroska;audio/x-matroska;video/x-matroska;video/webm;audio/webm;audio/x-mp3;audio/x-mpeg;audio/mpeg;audio/x-wav;audio/x-mpegurl;audio/x-scpls;audio/x-m4a;audio/x-ms-asf;audio/x-ms-asx;audio/x-ms-wax;application/vnd.rn-realmedia;audio/x-real-audio;audio/x-pn-realaudio;application/x-flac;audio/x-flac;application/x-shockwave-flash;misc/ultravox;audio/vnd.rn-realaudio;audio/x-pn-aiff;audio/x-pn-au;audio/x-pn-wav;audio/x-pn-windows-acm;image/vnd.rn-realpix;audio/x-pn-realaudio-plugin;application/x-extension-mp4;audio/mp4;audio/amr;audio/amr-wb;x-content/video-vcd;x-content/video-svcd;x-content/video-dvd;x-content/audio-cdda;x-content/audio-player;application/xspf+xml;x-scheme-handler/mms;x-scheme-handler/rtmp;x-scheme-handler/rtsp;

为了将其添加到.mp4文件的“推荐应用程序”列表中,我必须“重置为系统默认值”。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章