tide/functions/_tide_detect_os.fish

71 lines
3.4 KiB
Fish
Raw Normal View History

2021-11-16 21:22:41 +03:00
# Outputs icon, color, bg_color
2020-07-27 09:07:34 +03:00
function _tide_detect_os
2021-11-16 21:22:41 +03:00
set -lx defaultColor 080808 CED7CF
2020-07-30 03:30:32 +03:00
switch (uname | string lower)
case darwin
2022-04-07 03:05:59 +03:00
printf %s\n  D6D6D6 333333 # from apple.com header
2020-07-30 03:30:32 +03:00
case freebsd openbsd dragonfly
2021-10-31 07:15:07 +03:00
printf %s\n  FFFFFF AB2B28 # https://freebsdfoundation.org/about-us/about-the-foundation/project/
2020-07-30 03:30:32 +03:00
case linux
if test (uname -o) = Android
# https://developer.android.com/distribute/marketing-tools/brand-guidelines
printf %s\n  3DDC84 3C3F41 # fg is from above link, bg is from Android Studio default dark theme
else
_tide_detect_os_linux_cases /etc/os-release ID ||
_tide_detect_os_linux_cases /etc/os-release ID_LIKE ||
_tide_detect_os_linux_cases /etc/lsb-release DISTRIB_ID ||
printf %s\n$defaultColor
end
2020-07-27 09:07:34 +03:00
case '*'
2021-09-08 20:54:31 +03:00
echo -ns '?'
2020-07-27 09:07:34 +03:00
end
2020-07-30 03:30:32 +03:00
end
2020-09-23 23:48:55 +03:00
function _tide_detect_os_linux_cases -a file key
2021-03-21 04:03:07 +03:00
test -e $file || return
2021-05-12 23:13:51 +03:00
set -l split_file (string split '=' <$file)
set -l key_index (contains --index $key $split_file) || return
set -l value (string trim --chars='"' $split_file[(math $key_index + 1)])
2022-04-07 03:47:14 +03:00
# Anything which would have pure white background has been changed to D4D4D4
# It was just too bright otherwise
2022-04-13 00:33:49 +03:00
switch (string lower $value)
2021-11-16 21:22:41 +03:00
case alpine
printf %s\n  FFFFFF 0D597F # from alpine logo
case arch
printf %s\n  1793D1 4D4D4D # from arch wiki header
case centos
2022-04-07 03:47:14 +03:00
printf %s\n000000 D4D4D4 # https://wiki.centos.org/ArtWork/Brand/Logo, monochromatic
2021-11-16 21:22:41 +03:00
case debian
2022-04-07 03:47:14 +03:00
printf %s\n  C70036 D4D4D4 # from debian logo https://www.debian.org/logos/openlogo-nd-100.png
2021-11-16 21:22:41 +03:00
case devuan
printf %s\n$defaultColor # logo is monochromatic
case elementary
2022-04-07 03:47:14 +03:00
printf %s\n000000 D4D4D4 # https://elementary.io/brand, encouraged to be monochromatic
2021-11-16 21:22:41 +03:00
case fedora
printf %s\n  FFFFFF 294172 # from logo https://fedoraproject.org/w/uploads/2/2d/Logo_fedoralogo.png
case gentoo
printf %s\n  FFFFFF 54487A # https://wiki.gentoo.org/wiki/Project:Artwork/Colors
case mageia
printf %s\n  FFFFFF 262F45 # https://wiki.mageia.org/en/Artwork_guidelines
case manjaro
printf %s\n  FFFFFF 35BF5C # from https://gitlab.manjaro.org/artwork/branding/logo/-/blob/master/logo.svg
case mint
printf %s\n  FFFFFF 69B53F # extracted from https://linuxmint.com/web/img/favicon.ico
case nixos
printf %s\n  FFFFFF 5277C3 # https://github.com/NixOS/nixos-artwork/tree/master/logo
2022-04-13 00:33:49 +03:00
case opensuse-leap opensuse-tumbleweed
2021-11-16 21:22:41 +03:00
printf %s\n  73BA25 173f4f # https://en.opensuse.org/openSUSE:Artwork_brand
case raspbian
printf %s\n  FFFFFF A22846 # https://static.raspberrypi.org/files/Raspberry_Pi_Visual_Guidelines_2020.pdf
case sabayon
printf %s\n$defaultColor # Can't find colors, and they are rebranding anyway
case slackware
printf %s\n$defaultColor # Doesn't really have a logo, and the colors are too close to PWD blue anyway
case ubuntu
2022-04-07 03:47:14 +03:00
printf %s\n  E95420 D4D4D4 # https://design.ubuntu.com/brand/
2021-11-16 21:22:41 +03:00
case '*'
return 1
end
2020-07-30 03:30:32 +03:00
end