ubuntu12.04设置grub背景图片

本贴最后更新于 4077 天前,其中的信息可能已经物是人非

ubuntu12.04设置grub背景图片,灰常简单.

将要做为grub背景的图片放到 /boot/grub 下,然后执行

sudo update-grub

grub会自动查找该路径下的各种图片格式的文件

具体看/etc/grub.d/05_debian_theme

#!/bin/sh
set -e

grub-mkconfig helper script.

GRUB 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.

GRUB 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 GRUB. If not, see http://www.gnu.org/licenses/.

Include the GRUB helper library for grub-mkconfig.

. /usr/lib/grub/grub-mkconfig_lib

We want to work in /boot/grub/ only.

test -d "{GRUB_PREFIX}"; cd "{GRUB_PREFIX}"

Set the location of a possibly necessary cache file for the background image.

NOTE: This MUST BE A DOTFILE to avoid confusing it with user-defined images.

BACKGROUND_CACHE=".background_cache"

set_default_theme(){
# Set a monochromatic theme for Ubuntu.
echo "${1}set menu_color_normal=white/black"
echo "${1}set menu_color_highlight=black/light-gray"

if [ -e /lib/plymouth/themes/default.grub ]; then
	sed "s/^/${1}/" /lib/plymouth/themes/default.grub
fi

}

set_background_image(){
# Step #1: Search all available output modes ...
local output
for output in ${GRUB_TERMINAL_OUTPUT}; do
if [ "x$output" = "xgfxterm" ]; then
break
fi
done

# ... and check if we are able to display a background image at all.
if ! [ "x${output}" = "xgfxterm" ]; then
	return 1
fi

# Step #2: Check if the specified background image exists.
if ! [ -f "${1}" ]; then
	return 2
fi

# Step #3: Search the correct GRUB module for our background image.
local reader
case "${1}" in
	*.jpg|*.JPG|*.jpeg|*.JPEG) reader="jpeg";;
	*.png|*.PNG) reader="png";;
	*.tga|*.TGA) reader="tga";;
	*) return 3;; # Unknown image type.
esac

# Step #4: Check if the necessary GRUB module is available.
if ! [ -f "${reader}.mod" ]; then
	return 4
fi

# Step #5: Check if GRUB can read the background image directly.
# If so, we can remove the cache file (if any). Otherwise the backgound
# image needs to be cached under /boot/grub/.
if is_path_readable_by_grub "${1}"; then
	rm --force "${BACKGROUND_CACHE}.jpeg" \
		"${BACKGROUND_CACHE}.png" "${BACKGROUND_CACHE}.tga"
elif cp "${1}" "${BACKGROUND_CACHE}.${reader}"; then
	set -- "${BACKGROUND_CACHE}.${reader}" "${2}" "${3}"
else
	return 5
fi

# Step #6: Prepare GRUB to read the background image.
if ! prepare_grub_to_access_device "`${grub_probe} --target=device "${1}"`"; then
	return 6
fi

# Step #7: Everything went fine, print out a message to stderr ...
echo "Found background image: ${1}" >&2

# ... and write our configuration snippet to stdout. Use the colors
# desktop-base specified. If we're using a user-defined background, use
# the default colors since we've got no idea how the image looks like.
# If loading the background image fails, use the default theme.
echo "insmod ${reader}"
echo "if background_image `make_system_path_relative_to_its_root "${1}"`; then"
if [ -n "${2}" ]; then
	echo "  set color_normal=${2}"
fi
if [ -n "${3}" ]; then
	echo "  set color_highlight=${3}"
fi
if [ -z "${2}" ] && [ -z "${3}" ]; then
	echo "  true"
fi
echo "else"
set_default_theme "  "
echo "fi"

}

Earlier versions of grub-pc copied the default background image to /boot/grub

during postinst. Remove those obsolete images if they haven't been touched by

the user. They are still available under /usr/share/images/desktop-base/ if

desktop-base is installed.

while read checksum background; do
if [ -f "{background}" ] && [ "x`sha1sum "{background}"`" = "x{checksum} {background}" ]; then
echo "Removing old background image: ${background}" >&2
rm "${background}"
fi
done <<EOF
648ee65dd0c157a69b019a5372cbcfea4fc754a5 debian-blueish-wallpaper-640x480.png
0431e97a6c661084c59676c4baeeb8c2f602edb8 debian-blueish-wallpaper-640x480.png
968ecf6696c5638cfe80e8e70aba239526270864 debian-blueish-wallpaper-640x480.tga
11143e8c92a073401de0b0fd42d0c052af4ccd9b moreblue-orbit-grub.png
d00d5e505ab63f2d53fa880bfac447e2d3bb197c moreblue-orbit-grub.png
f5b12c1009ec0a3b029185f6b66cd0d7e5611019 moreblue-orbit-grub.png
EOF

Include the configuration of desktop-base if available.

if [ -f "/usr/share/desktop-base/grub_background.sh" ]; then
. "/usr/share/desktop-base/grub_background.sh"
fi

First check whether the user has specified a background image explicitly.

If so, try to use it. Don't try the other possibilities in that case

(#608263).

if [ -n "${GRUB_BACKGROUND+x}" ]; then
set_background_image "${GRUB_BACKGROUND}" || set_default_theme
exit 0
fi

Next search for pictures the user put into /boot/grub/ and use the first one.

for background in *.jpg *.JPG *.jpeg *.JPEG *.png *.PNG *.tga *.TGA; do
if set_background_image "${background}"; then
exit 0
fi
done

Next try to use the background image and colors specified by desktop-base.

if set_background_image "{WALLPAPER}" "{COLOR_NORMAL}" "${COLOR_HIGHLIGHT}"; then
exit 0
fi

If we haven't found a background image yet, use the default from desktop-base.

if set_background_image "/usr/share/images/desktop-base/desktop-grub.png"; then
exit 0
fi

Finally, if all of the above fails, use the default theme.

set_default_theme

  • Ubuntu

    Ubuntu(友帮拓、优般图、乌班图)是一个以桌面应用为主的 Linux 操作系统,其名称来自非洲南部祖鲁语或豪萨语的“ubuntu”一词,意思是“人性”、“我的存在是因为大家的存在”,是非洲传统的一种价值观,类似华人社会的“仁爱”思想。Ubuntu 的目标在于为一般用户提供一个最新的、同时又相当稳定的主要由自由软件构建而成的操作系统。

    123 引用 • 168 回帖
  • grub
    5 引用

相关帖子

欢迎来到这里!

我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。

注册 关于
请输入回帖内容 ...

推荐标签 标签

  • 笔记

    好记性不如烂笔头。

    304 引用 • 777 回帖
  • 倾城之链
    23 引用 • 66 回帖 • 102 关注
  • 程序员

    程序员是从事程序开发、程序维护的专业人员。

    534 引用 • 3528 回帖 • 1 关注
  • Git

    Git 是 Linux Torvalds 为了帮助管理 Linux 内核开发而开发的一个开放源码的版本控制软件。

    205 引用 • 357 回帖
  • Spring

    Spring 是一个开源框架,是于 2003 年兴起的一个轻量级的 Java 开发框架,由 Rod Johnson 在其著作《Expert One-On-One J2EE Development and Design》中阐述的部分理念和原型衍生而来。它是为了解决企业应用开发的复杂性而创建的。框架的主要优势之一就是其分层架构,分层架构允许使用者选择使用哪一个组件,同时为 JavaEE 应用程序开发提供集成的框架。

    941 引用 • 1458 回帖 • 153 关注
  • InfluxDB

    InfluxDB 是一个开源的没有外部依赖的时间序列数据库。适用于记录度量,事件及实时分析。

    2 引用 • 55 关注
  • WebClipper

    Web Clipper 是一款浏览器剪藏扩展,它可以帮助你把网页内容剪藏到本地。

    3 引用 • 9 回帖 • 5 关注
  • Sublime

    Sublime Text 是一款可以用来写代码、写文章的文本编辑器。支持代码高亮、自动完成,还支持通过插件进行扩展。

    10 引用 • 5 回帖
  • 互联网

    互联网(Internet),又称网际网络,或音译因特网、英特网。互联网始于 1969 年美国的阿帕网,是网络与网络之间所串连成的庞大网络,这些网络以一组通用的协议相连,形成逻辑上的单一巨大国际网络。

    96 引用 • 330 回帖
  • OAuth

    OAuth 协议为用户资源的授权提供了一个安全的、开放而又简易的标准。与以往的授权方式不同之处是 oAuth 的授权不会使第三方触及到用户的帐号信息(如用户名与密码),即第三方无需使用用户的用户名与密码就可以申请获得该用户资源的授权,因此 oAuth 是安全的。oAuth 是 Open Authorization 的简写。

    36 引用 • 103 回帖 • 8 关注
  • 开源中国

    开源中国是目前中国最大的开源技术社区。传播开源的理念,推广开源项目,为 IT 开发者提供了一个发现、使用、并交流开源技术的平台。目前开源中国社区已收录超过两万款开源软件。

    7 引用 • 86 回帖 • 1 关注
  • LaTeX

    LaTeX(音译“拉泰赫”)是一种基于 ΤΕΧ 的排版系统,由美国计算机学家莱斯利·兰伯特(Leslie Lamport)在 20 世纪 80 年代初期开发,利用这种格式,即使使用者没有排版和程序设计的知识也可以充分发挥由 TeX 所提供的强大功能,能在几天,甚至几小时内生成很多具有书籍质量的印刷品。对于生成复杂表格和数学公式,这一点表现得尤为突出。因此它非常适用于生成高印刷质量的科技和数学类文档。

    9 引用 • 32 回帖 • 165 关注
  • 爬虫

    网络爬虫(Spider、Crawler),是一种按照一定的规则,自动地抓取万维网信息的程序。

    106 引用 • 275 回帖
  • gRpc
    10 引用 • 8 回帖 • 56 关注
  • 宕机

    宕机,多指一些网站、游戏、网络应用等服务器一种区别于正常运行的状态,也叫“Down 机”、“当机”或“死机”。宕机状态不仅仅是指服务器“挂掉了”、“死机了”状态,也包括服务器假死、停用、关闭等一些原因而导致出现的不能够正常运行的状态。

    13 引用 • 82 回帖 • 38 关注
  • 链书

    链书(Chainbook)是 B3log 开源社区提供的区块链纸质书交易平台,通过 B3T 实现共享激励与价值链。可将你的闲置书籍上架到链书,我们共同构建这个全新的交易平台,让闲置书籍继续发挥它的价值。

    链书社

    链书目前已经下线,也许以后还有计划重制上线。

    14 引用 • 257 回帖 • 5 关注
  • 持续集成

    持续集成(Continuous Integration)是一种软件开发实践,即团队开发成员经常集成他们的工作,通过每个成员每天至少集成一次,也就意味着每天可能会发生多次集成。每次集成都通过自动化的构建(包括编译,发布,自动化测试)来验证,从而尽早地发现集成错误。

    14 引用 • 7 回帖 • 2 关注
  • SVN

    SVN 是 Subversion 的简称,是一个开放源代码的版本控制系统,相较于 RCS、CVS,它采用了分支管理系统,它的设计目标就是取代 CVS。

    29 引用 • 98 回帖 • 692 关注
  • Postman

    Postman 是一款简单好用的 HTTP API 调试工具。

    4 引用 • 3 回帖 • 1 关注
  • IDEA

    IDEA 全称 IntelliJ IDEA,是一款 Java 语言开发的集成环境,在业界被公认为最好的 Java 开发工具之一。IDEA 是 JetBrains 公司的产品,这家公司总部位于捷克共和国的首都布拉格,开发人员以严谨著称的东欧程序员为主。

    180 引用 • 400 回帖
  • 百度

    百度(Nasdaq:BIDU)是全球最大的中文搜索引擎、最大的中文网站。2000 年 1 月由李彦宏创立于北京中关村,致力于向人们提供“简单,可依赖”的信息获取方式。“百度”二字源于中国宋朝词人辛弃疾的《青玉案·元夕》词句“众里寻他千百度”,象征着百度对中文信息检索技术的执著追求。

    63 引用 • 785 回帖 • 251 关注
  • sts
    2 引用 • 2 回帖 • 149 关注
  • Logseq

    Logseq 是一个隐私优先、开源的知识库工具。

    Logseq is a joyful, open-source outliner that works on top of local plain-text Markdown and Org-mode files. Use it to write, organize and share your thoughts, keep your to-do list, and build your own digital garden.

    4 引用 • 55 回帖 • 8 关注
  • NetBeans

    NetBeans 是一个始于 1997 年的 Xelfi 计划,本身是捷克布拉格查理大学的数学及物理学院的学生计划。此计划延伸而成立了一家公司进而发展这个商用版本的 NetBeans IDE,直到 1999 年 Sun 买下此公司。Sun 于次年(2000 年)六月将 NetBeans IDE 开源,直到现在 NetBeans 的社群依然持续增长。

    78 引用 • 102 回帖 • 643 关注
  • JSON

    JSON (JavaScript Object Notation)是一种轻量级的数据交换格式。易于人类阅读和编写。同时也易于机器解析和生成。

    51 引用 • 190 回帖
  • HTML

    HTML5 是 HTML 下一个的主要修订版本,现在仍处于发展阶段。广义论及 HTML5 时,实际指的是包括 HTML、CSS 和 JavaScript 在内的一套技术组合。

    103 引用 • 294 回帖
  • Solo

    Solo 是一款小而美的开源博客系统,专为程序员设计。Solo 有着非常活跃的社区,可将文章作为帖子推送到社区,来自社区的回帖将作为博客评论进行联动(具体细节请浏览 B3log 构思 - 分布式社区网络)。

    这是一种全新的网络社区体验,让热爱记录和分享的你不再感到孤单!

    1425 引用 • 10043 回帖 • 470 关注