From 486fef7fd68e8c5dd0764bc880e120351f636745 Mon Sep 17 00:00:00 2001 From: Gen Li Date: Mon, 23 Jan 2017 14:50:51 +0800 Subject: [PATCH] Misc improvement --- boot/grub/fm/FileList.cfg | 90 ++++------- boot/grub/fm/FileOP.cfg | 70 +++++---- boot/grub/fm/GFXMode.cfg | 67 +++++++++ boot/grub/fm/LinuxISOBoot.cfg | 43 ++++-- boot/grub/fm/Tools.cfg | 216 --------------------------- boot/grub/fm/Type.cfg | 63 ++++++++ boot/grub/themes/slack/icons/img.png | Bin 0 -> 452 bytes mods.lst | 2 +- 8 files changed, 222 insertions(+), 329 deletions(-) create mode 100644 boot/grub/fm/GFXMode.cfg delete mode 100755 boot/grub/fm/Tools.cfg create mode 100644 boot/grub/fm/Type.cfg create mode 100644 boot/grub/themes/slack/icons/img.png diff --git a/boot/grub/fm/FileList.cfg b/boot/grub/fm/FileList.cfg index 422c28d4..d09dddbf 100755 --- a/boot/grub/fm/FileList.cfg +++ b/boot/grub/fm/FileList.cfg @@ -1,41 +1,40 @@ -#显示文件列表 -#--根据变量$list_dir目录列出所有子项菜单 -#--选择子项时,判断是目录/文件。 -#----目录:设置$list_dir变量,显示新子项菜单。 -#----文件:弹出操作菜单 -#变量: -#--$list_dir_this 本层菜单地址 -#--$list_dir 公用,传递参数 -#--$wildcard 使用的通配符,为了避免枚举盘符避免冲突 +# Grub2-FileManager +# Copyright (C) 2016,2017 A1ive. +# +# Grub2-FileManager is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Grub2-FileManager is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Grub2-FileManager. If not, see . + +source ${prefix}/fm/Type.cfg; -insmod regexp; -insmod probe; -source "${prefix}/fm/Tools.cfg"; set file_list_src="${prefix}/fm/FileList.cfg"; set file_op_src="${prefix}/fm/FileOP.cfg"; -#为了避免太长if结构,封装为函数 function funcListFile { - #检测参数合法并设置通配符变量$wildcard if test -z "${list_dir}"; then - #参数空则从盘符开始枚举 set list_dir=""; set wildcard="(*)"; elif test -e "${list_dir}"; then - #盘符(hd0,1)合法,(hd0)不合法 set wildcard="/*"; else - echo; - echo; - funcErrorNoFindOrCanNotRead "${list_dir}"; + echo "错误! 无法读取 [${list_dir}] !"; + echo -n "按[ESC]继续..."; + sleep --interruptible 999; return 1; fi; - #保存本层目录地址并设置list_dir可传递 export list_dir; set list_dir_this="${list_dir}"; if ! regexp '^$' "${list_dir_this}"; then - #生成当前目录项,防止空目录自动跳回 menuentry "返回上一级" --class go-previous{ set list_dir=""; regexp --set=list_dir '(^.*)/.*$' "${list_dir_this}"; @@ -45,15 +44,8 @@ function funcListFile { configfile ${prefix}/fm/FileList.cfg; } fi - #枚举子项 for obj in "${list_dir_this}"${wildcard}; do - #去掉路径中的“msdos” - funcRemoveCharMSDOS "${obj}"; - set obj="$str"; - unset str; - #检查目录/文件 if test -d "${obj}"; then - #目录 set icon="dir"; if regexp '^\([c][d].*+\)$' "${obj}"; then set icon="iso"; @@ -61,11 +53,10 @@ function funcListFile { set icon="hdd"; fi if regexp '^\(proc\)$' "${obj}"; then - echo "忽略/proc目录"; + echo "ignore proc"; elif regexp '^\(memdisk\)$' "${obj}"; then - echo "忽略memdisk"; + echo "ignore memdisk"; elif regexp '^$' "${list_dir_this}"; then - #根目录 probe --set=devlbl -l $obj; probe --set=devfs -f $obj; menuentry "${obj} [$devfs] $devlbl" "${obj}" --class ${icon}{ @@ -81,31 +72,7 @@ function funcListFile { } fi elif test -f "${obj}"; then - #文件 - set icon="txt" - funcGetFileExtName "${obj}"; - if regexp '^[iI][sS][oO]$' "${str}"; then - set icon="iso"; - elif regexp '^[zZ][iI][pP]$' "${str}"; then - set icon="7z"; - elif regexp '^[xXgGlL7][zZ]$' "${str}"; then - set icon="7z"; - elif regexp '^[wW][iI][mM]$' "${str}"; then - set icon="wim"; - elif regexp '^[pP][nN][gG]$' "${str}"; then - set icon="png"; - elif regexp '^[jJ][pP][gG]$' "${str}"; then - set icon="png"; - elif regexp '^[bB][mM][pP]$' "${str}"; then - set icon="png"; - elif regexp '^[lL][uU][aA]$' "${str}"; then - set icon="lua"; - elif regexp '^[eE][fF][iI]$' "${str}"; then - set icon="uefi"; - elif regexp '^[eE][xX][eE]$' "${str}"; then - set icon="exe" - fi - unset str; + funcGetFileType "${obj}"; menuentry "${obj}" "${obj}" --class ${icon} --class os{ set list_dir="$2"; configfile "${file_op_src}"; @@ -115,8 +82,10 @@ function funcListFile { fi; done; if regexp '^$' "${list_dir_this}"; then - #根目录 funcBootDisk; + hiddenentry "分辨率设置: $gfxmode" --class settings --hotkey=r{ + configfile ${prefix}/fm/GFXMode.cfg + } menuentry "重启计算机" --class reboot{ reboot; } @@ -124,7 +93,6 @@ function funcListFile { halt; } fi - #清理环境 unset obj; unset wildcard; echo "done!"; @@ -132,16 +100,13 @@ function funcListFile { function funcBootDisk{ for dev in (*); do - #是否可读 test -e ${dev}; if test "$?" = "1"; then continue; fi; - #去除括号 regexp --set=device '\((.*)\)' $dev; - #枚举 if test -f ($device)/efi/microsoft/boot/bootmgfw.efi -a -f ($device)/efi/microsoft/boot/bcd; then - menuentry "启动 Windows 操作系统 位于 $device" $device --class wim{ + menuentry "启动位于${device}的 Windows 操作系统 " $device --class wim{ set root=$2 chainloader ($root)/efi/microsoft/boot/bootmgfw.efi; boot; @@ -151,5 +116,4 @@ function funcBootDisk{ done; } -#调用主体函数 funcListFile; diff --git a/boot/grub/fm/FileOP.cfg b/boot/grub/fm/FileOP.cfg index dfa137c9..5db06923 100755 --- a/boot/grub/fm/FileOP.cfg +++ b/boot/grub/fm/FileOP.cfg @@ -1,12 +1,24 @@ -insmod regexp; -source ${prefix}/fm/Tools.cfg; +# Grub2-FileManager +# Copyright (C) 2016,2017 A1ive. +# +# Grub2-FileManager is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Grub2-FileManager is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Grub2-FileManager. If not, see . + +source ${prefix}/fm/Type.cfg; source "${prefix}/fm/LinuxISOBoot.cfg"; -#文件操作菜单 -#挂载为光盘 function funcAddCD { set added_menu="${added_menu} funcAddCD"; - echo "挂载 ${list_dir}"; loopback loop "${list_dir}"; menuentry "查看ISO内容" --class iso{ set list_dir="(loop)"; @@ -15,32 +27,37 @@ function funcAddCD { } funcCheckType; if test -f (loop)/efi/boot/bootx64.efi; then - menuentry "启动 bootx64.efi" --class iso{ + menuentry "启动 bootx64.efi" --class iso{ chainloader (loop)/efi/boot/bootx64.efi; } fi } -#当作[Grub2菜单文件]载入 + function funcAddCFG { set added_menu="${added_menu} funcAddCFG"; menuentry "作为Grub2菜单文件载入" --class cfg{ - funcGetDevName "${list_dir}"; + regexp --set=str '^\(([0-9a-zA-Z,]+)\).*$' "${list_dir}" set root="${str}"; configfile "${list_dir}"; } + menuentry "作为Syslinux菜单文件载入" --class cfg{ + regexp --set=str '^\(([0-9a-zA-Z,]+)\).*$' "${list_dir}" + set root="${str}"; + syslinuxcfg "${list_dir}"; + } } -#当作[Lua脚本]运行 + function funcAddLUA { set added_menu="${added_menu} funcAddLUA"; menuentry "作为Lua脚本运行" --class lua{ - funcGetDevName "${list_dir}"; + regexp --set=str '^\(([0-9a-zA-Z,]+)\).*$' "${list_dir}" set root="${str}"; lua "${list_dir}"; echo -n "按 [ESC] 键返回..."; sleep --interruptible 999; } } -#当作[EFI文件]运行 + function funcAddEFI { set added_menu="${added_menu} funcAddEFI"; menuentry "作为EFI可执行文件运行" --class uefi{ @@ -48,7 +65,7 @@ function funcAddEFI { boot; } } -#显示图片 + function funcAddPNG { set added_menu="${added_menu} funcAddPNG"; submenu "查看图片 (PNG)" --class png{ @@ -58,7 +75,7 @@ function funcAddPNG { background_image ${prefix}/themes/slack/black.png } } -#适用于所有文件的操作 + function funcAddAll { set added_menu="${added_menu} funcAddAll"; menuentry "显示文本内容" --class txt{ @@ -80,10 +97,6 @@ function funcAddAll { } } -#检查文件格式 -funcGetFileExtName "${list_dir}"; - - menuentry "返回" --class go-previous{ regexp --set=list_dir '(.*)\/.*$' "${list_dir}"; unset devnum; @@ -93,29 +106,20 @@ menuentry "返回" --class go-previous{ configfile ${prefix}/fm/FileList.cfg; } -if regexp '^[iI][sS][oO]$' "${str}"; then - #iso - funcAddCD; -elif regexp '^[cC][fF][gG]$' "${str}"; then - #cfg +funcGetFileType "${list_dir}"; +if regexp 'cfg' "$type"; then funcAddCFG; -elif regexp '^[lL][uU][aA]$' "${str}"; then - #lua +elif regexp 'lua' "$type"; then funcAddLUA; -elif regexp '^[eE][fF][iI]$' "${str}"; then - #efi +elif regexp 'efi' "$type"; then funcAddEFI; -elif regexp '^[pP][nN][gG]$' "${str}"; then - #png - funcAddPNG; -elif regexp '^[jJ][pP][gG]$' "${str}"; then - #jpg +elif regexp 'image' "$type"; then funcAddPNG; +elif regexp 'iso' "$type"; then + funcAddCD; fi - funcAddAll; -#清理环境 unset devnum; unset str; unset sequence; diff --git a/boot/grub/fm/GFXMode.cfg b/boot/grub/fm/GFXMode.cfg new file mode 100644 index 00000000..e30af1bc --- /dev/null +++ b/boot/grub/fm/GFXMode.cfg @@ -0,0 +1,67 @@ +# Grub2-FileManager +# Copyright (C) 2016,2017 A1ive. +# +# Grub2-FileManager is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Grub2-FileManager is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Grub2-FileManager. If not, see . + +terminal_output console + menuentry "[0] AUTO DETECT" --hotkey=0{ + set gfxmode=auto + terminal_output gfxterm + configfile ${prefix}/fm/FileList.cfg + } + menuentry "[1] 640x480" --hotkey=1{ + set gfxmode=640x480 + terminal_output gfxterm + configfile ${prefix}/fm/FileList.cfg + } + menuentry "[2] 800x600" --hotkey=2{ + set gfxmode=800x600 + terminal_output gfxterm + configfile ${prefix}/fm/FileList.cfg + } + menuentry "[3] 1024x768" --hotkey=3{ + set gfxmode=1024x768 + terminal_output gfxterm + configfile ${prefix}/fm/FileList.cfg + } + menuentry "[4] 1280x1024" --hotkey=4{ + set gfxmode=1280x1024 + terminal_output gfxterm + configfile ${prefix}/fm/FileList.cfg + } + menuentry "[5] 1366x768" --hotkey=5{ + set gfxmode=1366x768 + terminal_output gfxterm + configfile ${prefix}/fm/FileList.cfg + } + menuentry "[6] 1600x1200" --hotkey=6{ + set gfxmode=1600x1200 + terminal_output gfxterm + configfile ${prefix}/fm/FileList.cfg + } + menuentry "[7] 1920x1080" --hotkey=7{ + set gfxmode=1920x1080 + terminal_output gfxterm + configfile ${prefix}/fm/FileList.cfg + } + menuentry "[8] 1920x1440" --hotkey=8{ + set gfxmode=1920x1440 + terminal_output gfxterm + configfile ${prefix}/fm/FileList.cfg + } + menuentry "[9] 2160x1440" --hotkey=9{ + set gfxmode=2160x1440 + terminal_output gfxterm + configfile ${prefix}/fm/FileList.cfg + } \ No newline at end of file diff --git a/boot/grub/fm/LinuxISOBoot.cfg b/boot/grub/fm/LinuxISOBoot.cfg index 3f5f2f41..1fad5f08 100755 --- a/boot/grub/fm/LinuxISOBoot.cfg +++ b/boot/grub/fm/LinuxISOBoot.cfg @@ -1,22 +1,29 @@ -insmod regexp; -insmod loopback; -insmod probe; +# Grub2-FileManager +# Copyright (C) 2016,2017 A1ive. +# +# Grub2-FileManager is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Grub2-FileManager is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Grub2-FileManager. If not, see . -#ISO已被挂载于 loop -#iso路径为 ${list_dir} - -#ISO整体启动 function funcISOBoot { menuentry "作为 $distro LiveCD 启动" --class ${icon}{ set gfxpayload=keep; - echo ${list_dir}; echo ${isofile}; + echo ${list_dir}; linux $vmlinuz_img $kcmdline $loopiso; initrd $initrd_img; } } -#检测Linux LiveCD的类型 function funcCheckType { set icon="iso"; set distro="Linux"; @@ -60,7 +67,6 @@ function funcCheckType { set loopiso="root=live:CDLABEL=$devlbl iso-scan/filename=$isofile"; funcISOBoot; if test -f (loop)/images/pxeboot/vmlinuz*; then - #Fedora 或 CentOS 的网络安装镜像 menuentry "作为 $distro 安装光盘 启动" --class ${icon}{ set gfxpayload=keep; echo ${list_dir}; @@ -71,7 +77,6 @@ function funcCheckType { } fi elif test -f (loop)/live/vmlinuz*; then - #debian live 注意:非Live镜像不可启动 set icon="debian"; set distro="Debian"; set vmlinuz_img="(loop)/live/vmlinuz*"; @@ -80,7 +85,6 @@ function funcCheckType { set loopiso="findiso=${isofile}"; funcISOBoot; elif test -f (loop)/boot/x86_64/loader/linux; then - #SUSE 注意:镜像大于4G set icon="opensuse" set distro="OpenSUSE" set vmlinuz_img="(loop)/boot/x86_64/loader/linux"; @@ -94,16 +98,23 @@ function funcCheckType { elif test -d (loop)/porteus; then set icon="porteus"; set distro="Porteus"; - set kcmdline="norootcopy nomagic"; + set kcmdline="norootcopy"; set loopiso="from=${isofile}"; set vmlinuz_img="(loop)/boot/syslinux/vmlinuz"; set initrd_img="(loop)/boot/syslinux/initrd*"; if test -f (loop)/porteus/vmlinuz; then - #中文版 set vmlinuz_img="(loop)/porteus/vmlinuz*"; set initrd_img="(loop)/porteus/initrd*"; fi funcISOBoot; + elif test -d (loop)/slax; then + set icon="slax"; + set distro="Slax"; + set kcmdline="load_ramdisk=1 prompt_ramdisk=0 rw printk.time=0 slax.flags=xmode"; + set loopiso="from=${isofile}"; + set vmlinuz_img="(loop)/boot/vmlinuz"; + set initrd_img="(loop)/boot/initrd*"; + funcISOBoot; elif test -d (loop)/wifislax; then set icon="wifislax"; set distro="Wifislax"; @@ -145,7 +156,7 @@ function funcCheckType { set kcmdline="misobasedir=manjaro nouveau.modeset=1 i915.modeset=1 radeon.modeset=1 logo.nologo overlay=free showopts"; set loopiso="img_dev=$imgdevpath img_loop=$isofile misolabel=$devlbl"; funcISOBoot; - elif test -f (loop)/pmagic/bzImage; then + elif test -f (loop)/pmagic/bzImage -a -f (loop)/initramfs; then set icon="slackware" set distro="Parted Magic" set vmlinuz_img="(loop)/pmagic/bzImage"; @@ -153,7 +164,7 @@ function funcCheckType { set kcmdline="eject=no load_ramdisk=1"; set loopiso="iso_filename=$isofile"; funcISOBoot; - elif test -f (loop)/boot/initramfs_*.img; then + elif test -f (loop)/boot/initramfs_*.img -a -f (loop)/boot/vmlinuz_*; then set icon="archlinux" set distro="Arch Linux" set vmlinuz_img="(loop)/boot/vmlinuz_*"; diff --git a/boot/grub/fm/Tools.cfg b/boot/grub/fm/Tools.cfg deleted file mode 100755 index 9a234a7f..00000000 --- a/boot/grub/fm/Tools.cfg +++ /dev/null @@ -1,216 +0,0 @@ -insmod regexp; - -#一些自定义函数 - -#显示no_find错误信息 -function funcErrorNoFind { - echo "错误!"; - echo "找不到 [$1] !"; - echo -n "按[ESC]继续..... "; - if test -z "$2"; then - sleep --verbose --interruptible $2; - else - sleep --interruptible 999; - fi; - return 1; -} - -#显示no_find or can_no_read错误信息 -function funcErrorNoFindOrCanNotRead { - echo "错误!"; - echo "找不到 或 无法读取 [$1] !"; - echo -n "按[ESC]继续..... "; - if test -z "$2"; then - sleep --verbose --interruptible $2; - else - sleep --interruptible 999; - fi; - return 1; -} - -#生成1-9a-z字符序列 -#循环生成,在sequence中返回 -#参数0 或者 unset sequence ,关闭队列。 -function funcGetSequence { - #关闭序列 - if test "$1" = "0"; then - unset sequence; - return 1; - fi - #生成备选序列 - setparams "1" "2" "3" "4" "5" "6" "7" "8" "9"\ - "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M"\ - "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z"; - #移动到当前序列位置 - while test "$sequence" != "$1" -a "$#" -gt "1"; do - shift; - done; - #判断序列结束 - if test "$#" -le "1"; then - set sequence=1; - return 0; - fi; - #设置sequence到下一序列 - shift; - set sequence=$1; - return 0; -} - -#去掉路径中的“msdos”,输入参数1返回到$str中 -function funcRemoveCharMSDOS { - if regexp '^\([[:alpha:]]+[[:digit:]]+,[mM][sS][dD][oO][sS][[:digit:]]+\)' "$1"; then - set str_1=; - set str_2=; - regexp --set=str_1 '(^\([[:alpha:]]+[[:digit:]]+,)[mM][sS][dD][oO][sS][[:digit:]]+\).*$' "$1"; - regexp --set=str_2 '^\([[:alpha:]]+[[:digit:]]+,[mM][sS][dD][oO][sS]([[:digit:]]+\).*$)' "$1"; - set str="${str_1}${str_2}"; - unset str_1; - unset str_2; - return 0; - else - set str="$1"; - return 1; - fi; -} - -#获取文件扩展名,输入参数1返回到$str中 -function funcGetFileExtName { - if regexp --set=str '^.*\.(.*$)' "$1"; then - return 0; - else - unset str; - return 1; - fi -} - -#获取不带括号的驱动器和分区名,输入参数1返回到$str中 -function funcGetDevName { - if regexp --set=str '^\(([0-9a-zA-Z,]+)\).*$' "$1"; then - return 0; - else - unset str; - return 1; - fi -} - -#字母转换小写,输入参数1返回到$letter中 -function funcToLowerCaseLetter { - #处理变量 - set letter="$1"; - #生成备选序列 - setparams "A" "a" "B" "b" "C" "c" "D" "d" "E" "e" "F" "f"\ - "G" "g" "H" "h" "I" "i" "J" "j" "K" "k" "L" "l"\ - "M" "m" "N" "n" "O" "o" "P" "p" "Q" "q" "R" "r"\ - "S" "s" "T" "t" "U" "u" "V" "v" "W" "w" "X" "x"\ - "Y" "y" "Z" "z"; - #查找大写字母 - while test "${letter}" != "$1" -a "$#" -gt "2"; do - shift 2; - done; - #检查是否找到 - if test "$#" -lt "2"; then - unset letter; - return 1; - fi - #获得对应到小写字母 - shift; - set letter="$1"; - return 0; -} - -#字符串转换小写,输入参数1返回到$str中(使用$letter $str_1 $str_2 $str_3) -function funcToLowerCase { - #处理变量 - set str="$1"; - set str_1=""; - set str_2=""; - set str_3=""; - set letter=""; - #转换到小写 - while regexp --set=2:str_2 '(^.*)([A-Z])(.*$)' "${str}"; do - regexp --set=1:str_1 '(^.*)([A-Z])(.*$)' "${str}"; - regexp --set=3:str_3 '(^.*)([A-Z])(.*$)' "${str}"; - #单个字母转小写 - funcToLowerCaseLetter "${str_2}"; - if test "$?" = "1"; then - set ${str}=""; - fi - set str_2="${letter}"; - #合并字符串 - set str="${str_1}${str_2}${str_3}"; - #清空临时变量 - set str_1=""; - set str_2=""; - set str_3=""; - set letter=""; - done; - #清理并返回成功 - unset str_1; - unset str_2; - unset str_3; - unset letter; - if test -z ${str}; then - unset str; - return 1; - fi - return 0; -} - -#减1,输入参数1返回$str。使用$fag $str_final $str_end -function funcDec { - #初始化变量 - set str="$1"; - set fag="1"; - set str_final=""; - set str_end=""; - #循环处理,直到借位标志$fag不为1 - while test "${fag}" = "1" ; do - #生成序列 - setparams "9" "8" "7" "6" "5" "4" "3" "2" "1" "0"; - #提取最后一位 - regexp --set=str_end '^.*(.$)' "${str}"; - if test "$?" != "0"; then - #字符串为空 - set fag="-1"; - break; - fi - #去掉$str最后一位 - regexp --set=str '(^.*).$' "${str}"; - #查找所在序列位置 - until test "${str_end}" = "$1" -o "$#" -le "0"; do - shift; - done; - #检查非法字符 - if test "$#" -le "0"; then - set fag="-1"; - break; - fi - #检查是否借位并保持当前位 - if test "$1" = "0"; then - #需要借位 - set str_final="9${str_final}"; - else - #不需借位 - set fag="0"; - shift; - set str_final="$1${str_final}"; - fi - done; - #合拼字符串到$str - set str="${str}${str_final}"; - #去除首位到“0” - regexp --set=str '^0*([^0].*$)' "${str}"; - #清理环境变量 - unset str_final; - unset str_end; - #检查错误并输出结果 - if test "${fag}" = "-1"; then - unset str; - unset fag; - return 1; - else - unset fag; - return 0; - fi -} - diff --git a/boot/grub/fm/Type.cfg b/boot/grub/fm/Type.cfg new file mode 100644 index 00000000..7d636a45 --- /dev/null +++ b/boot/grub/fm/Type.cfg @@ -0,0 +1,63 @@ +# Grub2-FileManager +# Copyright (C) 2017 A1ive. +# +# Grub2-FileManager is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Grub2-FileManager is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Grub2-FileManager. If not, see . + +function funcGetFileExtName { + if regexp --set=str '^.*\.(.*$)' "$1"; then + return 0; + else + unset str; + return 1; + fi +} + +function funcGetFileType { + set icon="txt"; set type="unknown"; + if funcGetFileExtName "$1"; then + if regexp '^[iI][sS][oO]$' "${str}"; then + set icon="iso"; set type="iso"; + elif regexp '^[iI][mM][gGaA]$' "${str}"; then + set icon="img"; set type="disk"; + elif regexp '^[vV][hH][dD]$' "${str}"; then + set icon="img"; set type="disk"; + elif regexp '^[zZ][iI][pP]$' "${str}" ; then + set icon="7z"; + elif regexp '^[xXgGlL7][zZ]$' "${str}"; then + set icon="7z"; + elif regexp '^[wW][iI][mM]$' "${str}"; then + set icon="wim"; + elif regexp '^[pP][nN][gG]$' "${str}"; then + set icon="png"; set type="image"; + elif regexp '^[jJ][pP][gG]$' "${str}"; then + set icon="png"; set type="image"; + elif regexp '^[tT][gG][aA]$' "${str}"; then + set icon="png"; set type="image"; + elif regexp '^[bB][mM][pP]$' "${str}"; then + set icon="png"; + elif regexp '^[lL][uU][aA]$' "${str}"; then + set icon="lua"; set type="lua"; + elif regexp '^[eE][fF][iI]$' "${str}"; then + set icon="uefi"; + if file --is-x86_64-efi $1; then + set type="efi"; + fi + elif regexp '^[eE][xX][eE]$' "${str}"; then + set icon="exe"; + elif regexp '^[cC][fF][gG]$' "${str}"; then + set type="cfg"; + fi + unset str; + fi +} diff --git a/boot/grub/themes/slack/icons/img.png b/boot/grub/themes/slack/icons/img.png new file mode 100644 index 0000000000000000000000000000000000000000..b818c134760531ae6e142c9f6b4b9084f3efe836 GIT binary patch literal 452 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzmSQK*5Dp-y;YjHK@;M7UB8wRq zxP?KOkzv*x2?hqnG*1`Dkcif|*AIFz1&Xje`0vxlw{$|TO49;Y{R^vnXCH7ExW!`Y zV0~S3tKR&Dq52Qhm~QX5V9vpH%R})|%3{lxXTHu0>pUYXF~=nO&gR|E<=*|*ea|>8 zMkL3;*!GH)`lJc!1x0>}b~E1b^MA|l=ve+<=-|VwwRMgz>25pTn|CeFTDy;VfyrI7 zrs6XtR{O8K*e=?TsIXhZ;l^#Q2kX6=O&nn8!GA`Z`|%Mo)URw8by%J4ylGDLj|i_V zIngh*?-!N-Xq|ptP3JVz(I3;S@A5A_u4DMAc1_x)iwq0`L60t%rt`5koU3M!o~d?8 zGyPKa>s)7vofj%u6^=-B9`Rc9Vg9Y#ISJ*D3yap-h+mL-qR`U8_NDqGaD>uciOXSH^8m^Hl>z1B0ilpUXO@geCxQZn%{I literal 0 HcmV?d00001 diff --git a/mods.lst b/mods.lst index 7ec6a994..cab13e63 100644 --- a/mods.lst +++ b/mods.lst @@ -1 +1 @@ -affs afs all_video android appleldr bfs bitmap bitmap_scale blocklist boot btrfs cat chain cmp configfile cpio crc date datehook datetime dd disk echo efi_gop efi_uga efifwsetup elf eval exfat exfctest ext2 extcmd f2fs fat fbinst file font fshelp gettext gfxmenu gfxterm gfxterm_background gfxterm_menu gptsync gzio halt hashsum help hexdump hfs hfsplus hfspluscomp iso9660 jfs jpeg linux loadbios loadenv loopback ls lsacpi lsefi lsefimmap lsefisystab lsmmap lspci lua lvm lzopio memdisk minicmd multiboot multiboot2 newc normal ntfs part_apple part_bsd part_gpt part_msdos parttool png probe procfs random read reboot regexp reiserfs search search_fs_file search_fs_uuid search_label sleep squash4 tar terminal terminfo test tga time true udf video video_bochs video_cirrus video_colors video_fb videoinfo xfs xnu xzio zfs \ No newline at end of file +affs afs all_video android appleldr bfs bitmap bitmap_scale blocklist boot btrfs cat chain cmp configfile cpio crc date datehook datetime dd disk echo efi_gop efi_uga efifwsetup elf eval exfat exfctest ext2 extcmd f2fs fat fbinst file font fshelp gettext gfxmenu gfxterm gfxterm_background gfxterm_menu gptsync gzio halt hashsum help hexdump hfs hfsplus hfspluscomp iso9660 jfs jpeg linux loadbios loadenv loopback ls lsacpi lsefi lsefimmap lsefisystab lsmmap lspci lua lvm lzopio memdisk minicmd multiboot multiboot2 newc normal ntfs part_apple part_bsd part_gpt part_msdos parttool png probe procfs random read reboot regexp reiserfs search search_fs_file search_fs_uuid search_label sleep squash4 syslinuxcfg tar terminal terminfo test tga time true udf video video_bochs video_cirrus video_colors video_fb videoinfo xfs xnu xzio zfs \ No newline at end of file