ubuntu12.04设置grub背景图片

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

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 引用

相关帖子

欢迎来到这里!

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

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

推荐标签 标签

  • Kotlin

    Kotlin 是一种在 Java 虚拟机上运行的静态类型编程语言,由 JetBrains 设计开发并开源。Kotlin 可以编译成 Java 字节码,也可以编译成 JavaScript,方便在没有 JVM 的设备上运行。在 Google I/O 2017 中,Google 宣布 Kotlin 成为 Android 官方开发语言。

    19 引用 • 33 回帖 • 51 关注
  • GAE

    Google App Engine(GAE)是 Google 管理的数据中心中用于 WEB 应用程序的开发和托管的平台。2008 年 4 月 发布第一个测试版本。目前支持 Python、Java 和 Go 开发部署。全球已有数十万的开发者在其上开发了众多的应用。

    14 引用 • 42 回帖 • 705 关注
  • MySQL

    MySQL 是一个关系型数据库管理系统,由瑞典 MySQL AB 公司开发,目前属于 Oracle 公司。MySQL 是最流行的关系型数据库管理系统之一。

    675 引用 • 535 回帖
  • Vim

    Vim 是类 UNIX 系统文本编辑器 Vi 的加强版本,加入了更多特性来帮助编辑源代码。Vim 的部分增强功能包括文件比较(vimdiff)、语法高亮、全面的帮助系统、本地脚本(Vimscript)和便于选择的可视化模式。

    28 引用 • 66 回帖 • 7 关注
  • Rust

    Rust 是一门赋予每个人构建可靠且高效软件能力的语言。Rust 由 Mozilla 开发,最早发布于 2014 年 9 月。

    58 引用 • 22 回帖
  • 以太坊

    以太坊(Ethereum)并不是一个机构,而是一款能够在区块链上实现智能合约、开源的底层系统。以太坊是一个平台和一种编程语言 Solidity,使开发人员能够建立和发布下一代去中心化应用。 以太坊可以用来编程、分散、担保和交易任何事物:投票、域名、金融交易所、众筹、公司管理、合同和知识产权等等。

    34 引用 • 367 回帖 • 2 关注
  • Gitea

    Gitea 是一个开源社区驱动的轻量级代码托管解决方案,后端采用 Go 编写,采用 MIT 许可证。

    4 引用 • 16 回帖 • 1 关注
  • 博客

    记录并分享人生的经历。

    272 引用 • 2386 回帖
  • 负能量

    上帝为你关上了一扇门,然后就去睡觉了....努力不一定能成功,但不努力一定很轻松 (° ー °〃)

    88 引用 • 1234 回帖 • 442 关注
  • Shell

    Shell 脚本与 Windows/Dos 下的批处理相似,也就是用各类命令预先放入到一个文件中,方便一次性执行的一个程序文件,主要是方便管理员进行设置或者管理用的。但是它比 Windows 下的批处理更强大,比用其他编程程序编辑的程序效率更高,因为它使用了 Linux/Unix 下的命令。

    122 引用 • 73 回帖
  • Hadoop

    Hadoop 是由 Apache 基金会所开发的一个分布式系统基础架构。用户可以在不了解分布式底层细节的情况下,开发分布式程序。充分利用集群的威力进行高速运算和存储。

    85 引用 • 122 回帖 • 617 关注
  • AngularJS

    AngularJS 诞生于 2009 年,由 Misko Hevery 等人创建,后为 Google 所收购。是一款优秀的前端 JS 框架,已经被用于 Google 的多款产品当中。AngularJS 有着诸多特性,最为核心的是:MVC、模块化、自动化双向数据绑定、语义化标签、依赖注入等。2.0 版本后已经改名为 Angular。

    12 引用 • 50 回帖 • 442 关注
  • RabbitMQ

    RabbitMQ 是一个开源的 AMQP 实现,服务器端用 Erlang 语言编写,支持多种语言客户端,如:Python、Ruby、.NET、Java、C、PHP、ActionScript 等。用于在分布式系统中存储转发消息,在易用性、扩展性、高可用性等方面表现不俗。

    49 引用 • 60 回帖 • 396 关注
  • SOHO

    为成为自由职业者在家办公而努力吧!

    7 引用 • 55 回帖 • 65 关注
  • 链滴

    链滴是一个记录生活的地方。

    记录生活,连接点滴

    143 引用 • 3752 回帖
  • GitLab

    GitLab 是利用 Ruby 一个开源的版本管理系统,实现一个自托管的 Git 项目仓库,可通过 Web 界面操作公开或私有项目。

    46 引用 • 72 回帖
  • 生活

    生活是指人类生存过程中的各项活动的总和,范畴较广,一般指为幸福的意义而存在。生活实际上是对人生的一种诠释。生活包括人类在社会中与自己息息相关的日常活动和心理影射。

    230 引用 • 1454 回帖
  • Flutter

    Flutter 是谷歌的移动 UI 框架,可以快速在 iOS 和 Android 上构建高质量的原生用户界面。 Flutter 可以与现有的代码一起工作,它正在被越来越多的开发者和组织使用,并且 Flutter 是完全免费、开源的。

    39 引用 • 92 回帖
  • RIP

    愿逝者安息!

    8 引用 • 92 回帖 • 322 关注
  • 国际化

    i18n(其来源是英文单词 internationalization 的首末字符 i 和 n,18 为中间的字符数)是“国际化”的简称。对程序来说,国际化是指在不修改代码的情况下,能根据不同语言及地区显示相应的界面。

    7 引用 • 26 回帖
  • 数据库

    据说 99% 的性能瓶颈都在数据库。

    333 引用 • 619 回帖
  • Java

    Java 是一种可以撰写跨平台应用软件的面向对象的程序设计语言,是由 Sun Microsystems 公司于 1995 年 5 月推出的。Java 技术具有卓越的通用性、高效性、平台移植性和安全性。

    3169 引用 • 8208 回帖
  • OkHttp

    OkHttp 是一款 HTTP & HTTP/2 客户端库,专为 Android 和 Java 应用打造。

    16 引用 • 6 回帖 • 48 关注
  • FreeMarker

    FreeMarker 是一款好用且功能强大的 Java 模版引擎。

    23 引用 • 20 回帖 • 429 关注
  • 互联网

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

    96 引用 • 330 回帖
  • Solo

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

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

    1427 引用 • 10046 回帖 • 472 关注
  • 强迫症

    强迫症(OCD)属于焦虑障碍的一种类型,是一组以强迫思维和强迫行为为主要临床表现的神经精神疾病,其特点为有意识的强迫和反强迫并存,一些毫无意义、甚至违背自己意愿的想法或冲动反反复复侵入患者的日常生活。

    15 引用 • 161 回帖