Lubuntu终端Python桌面快捷方式

Lubuntu终端Python桌面快捷方式,python,linux,ubuntu,terminal,desktop-shortcut,Python,Linux,Ubuntu,Terminal,Desktop Shortcut,因此,我试图为我用python制作的终端mp3player创建一个桌面快捷方式。我在用卢本图 我的程序是这样的 #!/usr/bin/python # -*- coding: utf-8 -*- from __future__ import print_function import os import sys import random from sys import stdout from pygame import mixer # Load the required library

因此,我试图为我用python制作的终端mp3player创建一个桌面快捷方式。我在用卢本图

我的程序是这样的

#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import print_function
import os
import sys
import random
from sys import stdout

from pygame import mixer # Load the required library


class mp3Player(object):
    def __init__(self):
        self.mix = mixer
        self.mix.init()

    def play(self, filelist):
        for root, mp3file in filelist:
            try:
                stdout.write(root + '\n')
                stdout.write("Playing %s\n"%mp3file)

                self.mix.music.load(os.path.join(root, mp3file))
                self.mix.music.play()

                while self.mix.music.get_busy():
                    choice = raw_input("[skip, exit, pause, shuffle]\n")
                    if choice == "skip":
                        break
                    elif choice == "pause":
                        self.mix.music.pause()
                        raw_input("Press enter to continiue.")
                        self.mix.music.unpause()
                    elif choice == "shuffle":
                        random.shuffle(filelist)
                        break
                    elif choice == "exit":
                        raise KeyboardInterrupt
                    else:
                        pass

            except KeyboardInterrupt, e:
                self.mix.music.stop()
                print("User Interrupted")
                sys.exit(0)

            stdout.flush()

class mp3Files(object):
    def __init__(self):
        self.mp3player = mp3Player()
        self.filelist = []

    def search(self):
        for root, dirs, files in os.walk(os.getcwd()):
            for mp3file in files:
                if mp3file.endswith(".mp3"):
                    self.filelist.append((root, mp3file))

        self.mp3player.play(self.filelist)

def main():
    mp3 = mp3Files()
    mp3.search()

if __name__ == "__main__":
    main()
你需要pygame来测试它,我建议在你的音乐文件夹中执行它,因为它会递归地搜索当前目录中的mp3文件,完成后会播放列表。 但是,这是我的.desktop文件

[Desktop Entry]
Version=1.0
Name=mp3playa
Comment=Terminal mp3player
Exec=/media/jan/Volume/Musik/mp3playa
TryExec=/media/jan/Volume/Musik/mp3playa
Terminal=true
Categories=Application
Type=Application
GenericName=Simple terminal mp3player
当我双击它时,它只打开一个终端而不执行脚本。 我做错了什么?哦

提前谢谢

编辑:

文件是可执行的,我执行了

 sudo update-desktop-database
并且得到了警告

Warning in file "/usr/share/applications/gnumeric.desktop": usage of
MIME type "zz-application/zz-winassoc-xls" is discouraged ("zz-
application/zz-winassoc-xls" should be replaced with 
"application/vnd.ms-excel")

终于找到了我丢失的东西

必须首先以脚本作为命令参数启动lxterminal

Exec=lxterminal --command="/home/jan/Schreibtisch/mp3playa/mp3playa"

您是否尝试过在命令行上运行“Exec”条目?换句话说:你确定你的脚本实际上是可执行的吗;当你试着运行它(在把它变成发射器之前)时,正确的事情发生了吗?!当然,在对启动器进行更改之后,您确实运行了“sudo update desktop database”;要确保在更改后触发启动器之前反映任何更新?是的,它可以从命令行执行。如果我在终端中键入./mp3playa,它将执行。我尝试了“sudo更新桌面数据库”,但在文件“/usr/share/applications/gnumeric.desktop”中得到了警告:不鼓励使用MIME类型“zz application/zz winassoc xls”(“zz application/zz winassoc xls”应替换为“application/vnd.ms excel”)。出现此警告是因为我的.desktop文件吗?:/好的,警告非常明确,指向gnumeric.desktop文件;所以这很可能与您的脚本无关;您也可以尝试“Exec=python/bla/script”,我也尝试过,但Lubuntu的lxterminal似乎明确希望执行命令是这样的。