ubuntu12.04设置grub背景图片

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

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 的目标在于为一般用户提供一个最新的、同时又相当稳定的主要由自由软件构建而成的操作系统。

    127 引用 • 169 回帖
  • grub
    5 引用

相关帖子

欢迎来到这里!

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

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

推荐标签 标签

  • NetBeans

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

    78 引用 • 102 回帖 • 701 关注
  • Mobi.css

    Mobi.css is a lightweight, flexible CSS framework that focus on mobile.

    1 引用 • 6 回帖 • 762 关注
  • Maven

    Maven 是基于项目对象模型(POM)、通过一小段描述信息来管理项目的构建、报告和文档的软件项目管理工具。

    188 引用 • 319 回帖 • 251 关注
  • CAP

    CAP 指的是在一个分布式系统中, Consistency(一致性)、 Availability(可用性)、Partition tolerance(分区容错性),三者不可兼得。

    12 引用 • 5 回帖 • 635 关注
  • 正则表达式

    正则表达式(Regular Expression)使用单个字符串来描述、匹配一系列遵循某个句法规则的字符串。

    31 引用 • 94 回帖
  • 服务器

    服务器,也称伺服器,是提供计算服务的设备。由于服务器需要响应服务请求,并进行处理,因此一般来说服务器应具备承担服务并且保障服务的能力。

    125 引用 • 585 回帖 • 3 关注
  • Ngui

    Ngui 是一个 GUI 的排版显示引擎和跨平台的 GUI 应用程序开发框架,基于
    Node.js / OpenGL。目标是在此基础上开发 GUI 应用程序可拥有开发 WEB 应用般简单与速度同时兼顾 Native 应用程序的性能与体验。

    7 引用 • 9 回帖 • 400 关注
  • Gzip

    gzip (GNU zip)是 GNU 自由软件的文件压缩程序。我们在 Linux 中经常会用到后缀为 .gz 的文件,它们就是 Gzip 格式的。现今已经成为互联网上使用非常普遍的一种数据压缩格式,或者说一种文件格式。

    9 引用 • 12 回帖 • 170 关注
  • flomo

    flomo 是新一代 「卡片笔记」 ,专注在碎片化时代,促进你的记录,帮你积累更多知识资产。

    6 引用 • 143 回帖
  • Hprose

    Hprose 是一款先进的轻量级、跨语言、跨平台、无侵入式、高性能动态远程对象调用引擎库。它不仅简单易用,而且功能强大。你无需专门学习,只需看上几眼,就能用它轻松构建分布式应用系统。

    9 引用 • 17 回帖 • 635 关注
  • Follow
    4 引用 • 12 回帖 • 9 关注
  • 安全

    安全永远都不是一个小问题。

    203 引用 • 818 回帖 • 1 关注
  • 单点登录

    单点登录(Single Sign On)是目前比较流行的企业业务整合的解决方案之一。SSO 的定义是在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用系统。

    9 引用 • 25 回帖 • 2 关注
  • RYMCU

    RYMCU 致力于打造一个即严谨又活泼、专业又不失有趣,为数百万人服务的开源嵌入式知识学习交流平台。

    4 引用 • 6 回帖 • 58 关注
  • InfluxDB

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

    2 引用 • 93 关注
  • abitmean

    有点意思就行了

    35 关注
  • 强迫症

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

    15 引用 • 161 回帖
  • OpenCV
    15 引用 • 36 回帖 • 7 关注
  • 职场

    找到自己的位置,萌新烦恼少。

    127 引用 • 1708 回帖 • 1 关注
  • HTML

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

    108 引用 • 295 回帖
  • Solidity

    Solidity 是一种智能合约高级语言,运行在 [以太坊] 虚拟机(EVM)之上。它的语法接近于 JavaScript,是一种面向对象的语言。

    3 引用 • 18 回帖 • 433 关注
  • C++

    C++ 是在 C 语言的基础上开发的一种通用编程语言,应用广泛。C++ 支持多种编程范式,面向对象编程、泛型编程和过程化编程。

    107 引用 • 153 回帖 • 1 关注
  • 程序员

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

    588 引用 • 3528 回帖
  • Firefox

    Mozilla Firefox 中文俗称“火狐”(正式缩写为 Fx 或 fx,非正式缩写为 FF),是一个开源的网页浏览器,使用 Gecko 排版引擎,支持多种操作系统,如 Windows、OSX 及 Linux 等。

    7 引用 • 30 回帖 • 388 关注
  • 自由行
    3 关注
  • PWL

    组织简介

    用爱发电 (Programming With Love) 是一个以开源精神为核心的民间开源爱好者技术组织,“用爱发电”象征开源与贡献精神,加入组织,代表你将遵守组织的“个人开源爱好者”的各项条款。申请加入:用爱发电组织邀请帖
    用爱发电组织官网:https://programmingwithlove.stackoverflow.wiki/

    用爱发电组织的核心驱动力:

    • 遵守开源守则,体现开源&贡献精神:以分享为目的,拒绝非法牟利。
    • 自我保护:使用适当的 License 保护自己的原创作品。
    • 尊重他人:不以各种理由、各种漏洞进行未经允许的抄袭、散播、洩露;以礼相待,尊重所有对社区做出贡献的开发者;通过他人的分享习得知识,要留下足迹,表示感谢。
    • 热爱编程、热爱学习:加入组织,热爱编程是首当其要的。我们欢迎热爱讨论、分享、提问的朋友,也同样欢迎默默成就的朋友。
    • 倾听:正确并恳切对待、处理问题与建议,及时修复开源项目的 Bug ,及时与反馈者沟通。不抬杠、不无视、不辱骂。
    • 平视:不诋毁、轻视、嘲讽其他开发者,主动提出建议、施以帮助,以和谐为本。只要他人肯努力,你也可能会被昔日小看的人所超越,所以请保持谦虚。
    • 乐观且活跃:你的努力决定了你的高度。不要放弃,多年后回头俯瞰,才会发现自己已经成就往日所仰望的水平。积极地将项目开源,帮助他人学习、改进,自己也会获得相应的提升、成就与成就感。
    1 引用 • 487 回帖 • 4 关注
  • 分享

    有什么新发现就分享给大家吧!

    248 引用 • 1794 回帖 • 3 关注