grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] 30_os-prober: derive --class from os-prober generated label
@ 2015-12-26  7:09 Andrey Borzenkov
  2015-12-30 12:13 ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 1 reply; 2+ messages in thread
From: Andrey Borzenkov @ 2015-12-26  7:09 UTC (permalink / raw)
  To: grub-devel

Currently only Windows gets distinguished icons, everything else is displayed
using the same generic one. Add additional --class based on os-prober returned
label, which usually is expected to match primary distribution name.

Also use it for Windows as well - chainloader prober nay actually return
different strings (Windows, MS-DOS, Windows9xME).

---
 util/grub.d/30_os-prober.in | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in
index 5fc4f0c..5604ce2 100644
--- a/util/grub.d/30_os-prober.in
+++ b/util/grub.d/30_os-prober.in
@@ -135,6 +135,9 @@ for OS in ${OSPROBED} ; do
     LONGNAME="${LABEL}"
   fi
 
+  # os-prober returns text string followed by optional counter
+  CLASS="--class $(echo "${LABEL}" | LC_ALL=C sed 's,[[:digit:]]*$,,' | cut -d' ' -f1 | tr 'A-Z' 'a-z' | LC_ALL=C sed 's,[^[:alnum:]_],_,g')"
+
   gettext_printf "Found %s on %s\n" "${LONGNAME}" "${DEVICE}" >&2
 
   case ${BOOT} in
@@ -142,7 +145,7 @@ for OS in ${OSPROBED} ; do
 
 	  onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
       cat << EOF
-menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class windows --class os \$menuentry_id_option 'osprober-chain-$(grub_get_device_id "${DEVICE}")' {
+menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' $CLASS --class os \$menuentry_id_option 'osprober-chain-$(grub_get_device_id "${DEVICE}")' {
 EOF
       save_default_entry | grub_add_tab
       prepare_grub_to_access_device ${DEVICE} | grub_add_tab
@@ -174,7 +177,7 @@ EOF
 	DEVICE=${DEVICE%@*}
 	onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
       cat << EOF
-menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class windows --class os \$menuentry_id_option 'osprober-efi-$(grub_get_device_id "${DEVICE}")' {
+menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' $CLASS --class os \$menuentry_id_option 'osprober-efi-$(grub_get_device_id "${DEVICE}")' {
 EOF
       save_default_entry | sed -e "s/^/\t/"
       prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
@@ -230,7 +233,7 @@ EOF
 
 	if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then
             cat << EOF
-menuentry '$(echo "$OS $onstr" | grub_quote)' --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-simple-$boot_device_id' {
+menuentry '$(echo "$OS $onstr" | grub_quote)' $CLASS --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-simple-$boot_device_id' {
 EOF
 	    save_default_entry | grub_add_tab
 	    printf '%s\n' "${prepare_boot_cache}"
-- 
tg: (a9399f2..) u/os-prober-class (depends on: master)


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] 30_os-prober: derive --class from os-prober generated label
  2015-12-26  7:09 [PATCH] 30_os-prober: derive --class from os-prober generated label Andrey Borzenkov
@ 2015-12-30 12:13 ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 0 replies; 2+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2015-12-30 12:13 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 2813 bytes --]

Go ahead
On 26.12.2015 08:09, Andrey Borzenkov wrote:
> Currently only Windows gets distinguished icons, everything else is displayed
> using the same generic one. Add additional --class based on os-prober returned
> label, which usually is expected to match primary distribution name.
> 
> Also use it for Windows as well - chainloader prober nay actually return
> different strings (Windows, MS-DOS, Windows9xME).
> 
> ---
>  util/grub.d/30_os-prober.in | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in
> index 5fc4f0c..5604ce2 100644
> --- a/util/grub.d/30_os-prober.in
> +++ b/util/grub.d/30_os-prober.in
> @@ -135,6 +135,9 @@ for OS in ${OSPROBED} ; do
>      LONGNAME="${LABEL}"
>    fi
>  
> +  # os-prober returns text string followed by optional counter
> +  CLASS="--class $(echo "${LABEL}" | LC_ALL=C sed 's,[[:digit:]]*$,,' | cut -d' ' -f1 | tr 'A-Z' 'a-z' | LC_ALL=C sed 's,[^[:alnum:]_],_,g')"
> +
>    gettext_printf "Found %s on %s\n" "${LONGNAME}" "${DEVICE}" >&2
>  
>    case ${BOOT} in
> @@ -142,7 +145,7 @@ for OS in ${OSPROBED} ; do
>  
>  	  onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
>        cat << EOF
> -menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class windows --class os \$menuentry_id_option 'osprober-chain-$(grub_get_device_id "${DEVICE}")' {
> +menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' $CLASS --class os \$menuentry_id_option 'osprober-chain-$(grub_get_device_id "${DEVICE}")' {
>  EOF
>        save_default_entry | grub_add_tab
>        prepare_grub_to_access_device ${DEVICE} | grub_add_tab
> @@ -174,7 +177,7 @@ EOF
>  	DEVICE=${DEVICE%@*}
>  	onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
>        cat << EOF
> -menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class windows --class os \$menuentry_id_option 'osprober-efi-$(grub_get_device_id "${DEVICE}")' {
> +menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' $CLASS --class os \$menuentry_id_option 'osprober-efi-$(grub_get_device_id "${DEVICE}")' {
>  EOF
>        save_default_entry | sed -e "s/^/\t/"
>        prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
> @@ -230,7 +233,7 @@ EOF
>  
>  	if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then
>              cat << EOF
> -menuentry '$(echo "$OS $onstr" | grub_quote)' --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-simple-$boot_device_id' {
> +menuentry '$(echo "$OS $onstr" | grub_quote)' $CLASS --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-simple-$boot_device_id' {
>  EOF
>  	    save_default_entry | grub_add_tab
>  	    printf '%s\n' "${prepare_boot_cache}"
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-12-30 12:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-26  7:09 [PATCH] 30_os-prober: derive --class from os-prober generated label Andrey Borzenkov
2015-12-30 12:13 ` Vladimir 'φ-coder/phcoder' Serbinenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).