怎么让*.sh文件免提示运行?
Tofloor
poster avatar
liuguangjingshang
deepin
2018-04-30 18:40
Author
如图

我在桌面上创建了个快捷方式,怎么让其双击后不显示窗口直接运行?
Reply Favorite View the author
All Replies
avatar
joeng4
deepin
2018-04-30 18:55
#1
提示一下更安全
Reply View the author
avatar
liuguangjingshang
deepin
2018-04-30 19:47
#2
可是这个文件是自己建立的,安不安全我都会点开它,有什么方式可以绕过询问呢?
Reply View the author
avatar
sz******iy@vip.qq.com
deepin
2018-04-30 20:26
#3
https://bbs.deepin.org/post/155864
可是这个文件是自己建立的,安不安全我都会点开它,有什么方式可以绕过询问呢? ...

你不会把它当启动快捷键吧  。。。我的天
Reply View the author
avatar
海天鹰
deepin
2018-04-30 20:30
#4
这个弹窗真是烦死我了!
Reply View the author
avatar
liuguangjingshang
deepin
2018-04-30 21:08
#5
https://bbs.deepin.org/post/155864
你不会把它当启动快捷键吧  。。。我的天

一个快捷方式,指向了pycharm.sh源文件,有什么问题吗?本来就是一个具有图形界面的程序,难道还要跑终端里切到对应目录下
敲:
  1. ms@ms-PC /u/l/p/bin> ./pycharm.sh
Copy the Code
这不是麻烦吗?
Reply View the author
avatar
Lyvnee
deepin
2018-04-30 21:21
#6
新建个.desktop文件
  1. [Desktop Entry]
  2. Exec=安装后程序的路径
  3. Name=程序名
  4. Comment=程序描述
  5. Icon=安装后程序图标的路径
  6. Terminal=false
  7. Type=Application
  8. Categories=程序类别
Copy the Code

Reply View the author
avatar
leixiaozeng
deepin
2018-04-30 21:27
#7
亲爱的就是加一个桌面快捷键就好了
Reply View the author
avatar
liuguangjingshang
deepin
2018-04-30 21:44
#8
https://bbs.deepin.org/post/155864
新建个.desktop文件

这个啊,我试试
Reply View the author
avatar
liuguangjingshang
deepin
2018-04-30 21:50
#9
搞定了,早该想到的,是我唐突了
Reply View the author
avatar
要讲武德
deepin
2018-04-30 22:24
#10
不做desktop有方法绕过吗,我也被弹的烦!
Reply View the author
avatar
sz******iy@vip.qq.com
deepin
2018-04-30 22:57
#11
https://bbs.deepin.org/post/155864
一个快捷方式,指向了pycharm.sh源文件,有什么问题吗?本来就是一个具有图形界面的程序,难道还要跑终端 ...

这个.sh文件算是安装程序了 7楼的方式正解呀
Reply View the author
avatar
窄口牛
deepin
2018-04-30 23:31
#12
这一点就不如win下的批处理了。
Reply View the author
avatar
liuguangjingshang
deepin
2018-05-01 07:49
#13
本帖最后由 liuguangjingshang 于 2018-5-1 10:57 编辑



一款pdf软件里自带的启动器及桌面快捷方式生成程序
随上desktop里的代码
  1. #!/bin/bash

  2. # Спасибо Vitally_D за этот скрипт

  3. # Vars
  4. script="$(readlink -f "${BASH_SOURCE[0]}")"
  5. cdir="$(dirname "$script")"
  6. appName="PDF Studio 11"

  7. if [ "$1" == "-d" ]
  8. then rm -f "$HOME/.local/share/applications/$appName.desktop"
  9.         rm -f "$HOME/Desktop/$appName.desktop"
  10.         rm -f "$HOME/Рабочий стол/$appName.desktop"
  11.         exit
  12. fi

  13. cd "$cdir"

  14. desk_file="$HOME/.local/share/applications/$appName.desktop"
  15. if [ -f "$desk_file" ]; then
  16.   rm "$desk_file";
  17. fi
  18. if [ ! -d "$HOME/.local/share/applications/" ]; then
  19.   mkdir -p "$HOME/.local/share/applications" ];
  20. fi
  21. touch "$desk_file"

  22. desk_cont="[Desktop Entry]\nEncoding=UTF-8\nVersion=1.0\nName=$appName\nGenericName=$appName\nExec=\"$cdir/start\"\nTerminal=false\nIcon=$cdir/icon.png\nType=Application\nCategories=Office;\nStartupNotify=true\nComment=Запустить $appName";

  23. echo -e $desk_cont >> "$desk_file"
  24. chmod +x "$desk_file"

  25. # Try find Desktop folder
  26. deskVars=("Рабочий стол" "Desktop");
  27. for desk in "${deskVars[@]}"; do
  28.   deskDir="$HOME/$desk";
  29.   if [ -d "$deskDir" ]; then
  30.     desk_file="$deskDir/$appName.desktop";
  31.     if [ -f "$desk_file" ]; then
  32.       rm "$desk_file";
  33.     fi
  34.     touch "$desk_file";
  35.     #Put desktop file to Desktop directory
  36.     echo -e $desk_cont >> "$desk_file";
  37.     chmod +x "$desk_file";
  38.   fi
  39. done;
Copy the Code


Reply View the author