在一台 Debian 10 w/LXDE 的电脑上,在浏览器以外的地方,如果点击被识别出来的超链接,则最后在调起浏览器进行网址访问时,URL 之前都会被冠以用户 Home 目录的全路径,导致打开失败。单纯打开页面失败可能还不是最糟糕的,有的时候是一个下载链接,会直接报告下载失败,而且含有 URL 的信息并不会留在浏览器中,也就失去了手动修正重新下载的机会。
一直没有精力排查,昨天在网络上找到一个 shell 脚本(https://github.com/LinuxCrafts/Custom-Protocol-handler-creator/blob/master/ProtocolCreator.sh),宣称可以创建协议处理器,有时间要对照分析一下,看是不是本地的类似设置里有问题。从一瞥中看到的 kdialog 字样上,感觉是依赖 KDE 的。
脚本全文抄录于此,以备万全。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
#!/bin/bash ########################### # # # ProtocolCreator # # By TStudios # # Version: 1.1.0 # # # ########################### kdialog --msgbox "THIS PROGRAM IS A DANGEROUS PROGRAM AND THE PROGRAMER WILL NOT BE RESPONSIBLE FOR ANY DAMAGE DONE!\n\nCopyleft (c) 2018 SPS All Rights Reserved." cd ~/.local/share/applications Protocol=`kdialog --inputbox "Type your protocol name(example: http, https, file)[WARNING! DO NOT INCLUDE :// INSIDE OF THE PROTOCOL NAME ELSE THE PROGRAM MIGHT BREAK]:"` ProgramName=`kdialog --inputbox "Type your Program's name:"` Description=`kdialog --inputbox "Type your Program's Description:"` Programcode=`kdialog --textinputbox "Type your program's code:" "#!/bin/bash\n#Replace this with your program's code"` Categories=`kdialog --inputbox "Type your categories, syntax: Categorie;Subcategorie;Subsubcategorie; ,Must include semicolone at end, Can be 0 or more SUBcategories, There must be a MAIN categorie"` Terminal=`kdialog --radiolist "Choose if you want your program to be executed in a terminal when executed via Protocol:" true "yes" true false "no" false ` First=`kdialog --radiolist "Have you used a program that has created a custom protocol on this instalation of linux yet?" true "yes" true false "no" false `` if [[ "$First" = "true" ]]; then echo "[Added Associations]" >> mimeapps.list fi echo " x-scheme-handler/$Protocol=$Protocol.desktop" >> mimeapps.list echo "[Desktop Entry] Version=1.0 Type=Application Exec=sh -c \"~/$ProgramName/Start.sh %u\" Icon=/usr/share/icons/hicolor/256x256/apps/org.gnome.Nautilus.png StartupNotify=true Terminal=$Terminal Categories=$Categories MimeType=x-scheme-handler/$Protocol Name=$ProgramName Comment=$Description GenericName=This program was created using ProtocolCreator by TStudios " > $Protocol.desktop cd ~ mkdir $ProgramName cd $ProgramName echo " #!/bin/bash $Programcode echo \"Starting $ProgramName\" " > Start.sh chmod 770 Start.sh chmod 770 Install.sh echo "cd ~/.local/share/applications echo \" x-scheme-handler/$Protocol=$Protocol.desktop\" >> mimeapps.list echo -e \"[Desktop Entry] Version=1.0 Type=Application Exec=sh -c \\\"~/$ProgramName/Start.sh %u\\\" Icon=/usr/share/icons/hicolor/256x256/apps/org.gnome.Nautilus.png StartupNotify=true Terminal=$Terminal Categories=$Categories MimeType=x-scheme-handler/$Protocol Name=$ProgramName Comment=$Description GenericName=This program was created using ProtocolCreator by TStudios \" > $Protocol.desktop cd ~ mkdir $ProgramName cd $ProgramName echo -e \" #!/bin/bash $Programcode \" > Start.sh chmod 770 Start.sh " > Install.sh kdialog --textinputbox "Here is a simple installer that can be put into a shell script file and than executed to get the protocol handler you just created: file location: ${HOME}/${ProgramName}/Install.sh\n\nalso there should be a copy/pasteable and editable version right below this text:" "cd ~/.local/share/applications echo \" x-scheme-handler/$Protocol=$Protocol.desktop\" >> mimeapps.list echo -e \"[Desktop Entry] Version=1.0 Type=Application Exec=sh -c \\\"~/$ProgramName/Start.sh %u\\\" Icon=/usr/share/icons/hicolor/256x256/apps/org.gnome.Nautilus.png StartupNotify=true Terminal=$Terminal Categories=$Categories MimeType=x-scheme-handler/$Protocol Name=$ProgramName Comment=$Description GenericName=This program was created using ProtocolCreator by TStudios \" > $Protocol.desktop cd ~ mkdir $ProgramName cd $ProgramName echo -e \" #!/bin/bash $Programcode \" > Start.sh chmod 770 Start.sh" echo "[Desktop Entry] Version=1.0 Type=Application Exec=sh -c \"~/$ProgramName/Start.sh %u\" Icon=/usr/share/icons/hicolor/256x256/apps/org.gnome.Nautilus.png StartupNotify=true Terminal=$Terminal Categories=$Categories MimeType=x-scheme-handler/$Protocol Name=$ProgramName Comment=$Description GenericName=This program was created using ProtocolCreator by TStudios " > $Protocol.desktop cd ~ mkdir $ProgramName cd $ProgramName echo -e " $Programcode echo \"Starting $ProgramName\" " > Start.sh chmod 770 Start.sh chmod 770 Install.sh echo "cd ~/.local/share/applications echo \" x-scheme-handler/$Protocol=$Protocol.desktop\" >> mimeapps.list echo -e \"[Desktop Entry] Version=1.0 Type=Application Exec=sh -c \\\"~/$ProgramName/Start.sh %u\\\" Icon=/usr/share/icons/hicolor/256x256/apps/org.gnome.Nautilus.png StartupNotify=true Terminal=$Terminal Categories=$Categories MimeType=x-scheme-handler/$Protocol Name=$ProgramName Comment=$Description GenericName=This program was created using ProtocolCreator by TStudios \" > $Protocol.desktop cd ~ mkdir $ProgramName cd $ProgramName echo -e \" #!/bin/bash $Programcode \" > Start.sh chmod 770 Start.sh" kdialog --textinputbox " Credits & co " " Start of developement for this program: 24.5.18 Release Date: 6.5.18 Lines of Code: 173 ProtocolCreator By: TStudios Version: 1.1 Pre-1 Copyright (c) 2018 TStudios All Rights Reserved. " ######################################################## # # # Copyright (c) 2018 TStudios All Rights Reserved. # # # ######################################################## |