summaryrefslogtreecommitdiff
path: root/home-config/fish/functions/_tide_detect_os.fish
diff options
context:
space:
mode:
authorRyan Schanzenbacher <ryan@rschanz.org>2024-04-05 11:57:45 -0400
committerRyan Schanzenbacher <ryan@rschanz.org>2024-04-05 11:57:45 -0400
commitb88d77fb2d0d5028a6f5670695dee6bec129501f (patch)
tree2536b0461d297e647cf07157641c9b1223339adf /home-config/fish/functions/_tide_detect_os.fish
parent776a7ca55d2d2c3f396de91db1c6c3c5065012cd (diff)
ahhh sloppy fish, still needs fixing, esp with the vars
Diffstat (limited to 'home-config/fish/functions/_tide_detect_os.fish')
-rw-r--r--home-config/fish/functions/_tide_detect_os.fish77
1 files changed, 77 insertions, 0 deletions
diff --git a/home-config/fish/functions/_tide_detect_os.fish b/home-config/fish/functions/_tide_detect_os.fish
new file mode 100644
index 0000000..cf38388
--- /dev/null
+++ b/home-config/fish/functions/_tide_detect_os.fish
@@ -0,0 +1,77 @@
1# Outputs icon, color, bg_color
2function _tide_detect_os
3 set -lx defaultColor 080808 CED7CF
4 switch (uname | string lower)
5 case darwin
6 printf %s\n  D6D6D6 333333 # from apple.com header
7 case freebsd openbsd dragonfly
8 printf %s\n  FFFFFF AB2B28 # https://freebsdfoundation.org/about-us/about-the-foundation/project/
9 case 'cygwin*' 'mingw*_nt*' 'msys_nt*'
10 printf %s\n  FFFFFF 00CCFF # https://answers.microsoft.com/en-us/windows/forum/all/what-is-the-official-windows-8-blue-rgb-or-hex/fd57144b-f69b-42d8-8c21-6ca911646e44
11 case linux
12 if test (uname -o) = Android
13 echo ﲎ # This character is evil and messes up code display, so it's put on its own line
14 # https://developer.android.com/distribute/marketing-tools/brand-guidelines
15 printf %s\n 3DDC84 3C3F41 # fg is from above link, bg is from Android Studio default dark theme
16 else
17 _tide_detect_os_linux_cases /etc/os-release ID ||
18 _tide_detect_os_linux_cases /etc/os-release ID_LIKE ||
19 _tide_detect_os_linux_cases /etc/lsb-release DISTRIB_ID ||
20 printf %s\n  $defaultColor
21 end
22 case '*'
23 echo -ns '?'
24 end
25end
26
27function _tide_detect_os_linux_cases -a file key
28 test -e $file || return
29 set -l split_file (string split '=' <$file)
30 set -l key_index (contains --index $key $split_file) || return
31 set -l value (string trim --chars='"' $split_file[(math $key_index + 1)])
32
33 # Anything which would have pure white background has been changed to D4D4D4
34 # It was just too bright otherwise
35 switch (string lower $value)
36 case alpine
37 printf %s\n  FFFFFF 0D597F # from alpine logo
38 case arch
39 printf %s\n  1793D1 4D4D4D # from arch wiki header
40 case centos
41 printf %s\n  000000 D4D4D4 # https://wiki.centos.org/ArtWork/Brand/Logo, monochromatic
42 case debian
43 printf %s\n  C70036 D4D4D4 # from debian logo https://www.debian.org/logos/openlogo-nd-100.png
44 case devuan
45 printf %s\n  $defaultColor # logo is monochromatic
46 case elementary
47 printf %s\n  000000 D4D4D4 # https://elementary.io/brand, encouraged to be monochromatic
48 case fedora
49 printf %s\n  FFFFFF 294172 # from logo https://fedoraproject.org/w/uploads/2/2d/Logo_fedoralogo.png
50 case gentoo
51 printf %s\n  FFFFFF 54487A # https://wiki.gentoo.org/wiki/Project:Artwork/Colors
52 case mageia
53 printf %s\n  FFFFFF 262F45 # https://wiki.mageia.org/en/Artwork_guidelines
54 case manjaro
55 printf %s\n  FFFFFF 35BF5C # from https://gitlab.manjaro.org/artwork/branding/logo/-/blob/master/logo.svg
56 case mint linuxmint
57 printf %s\n  FFFFFF 69B53F # extracted from https://linuxmint.com/web/img/favicon.ico
58 case nixos
59 printf %s\n  FFFFFF 5277C3 # https://github.com/NixOS/nixos-artwork/tree/master/logo
60 case opensuse-leap opensuse-tumbleweed opensuse-microos
61 printf %s\n  73BA25 173f4f # https://en.opensuse.org/openSUSE:Artwork_brand
62 case raspbian
63 printf %s\n  FFFFFF A22846 # https://static.raspberrypi.org/files/Raspberry_Pi_Visual_Guidelines_2020.pdf
64 case rhel
65 printf %s\n  EE0000 000000 # https://www.redhat.com/en/about/brand/standards/color
66 case sabayon
67 printf %s\n  $defaultColor # Can't find colors, and they are rebranding anyway
68 case slackware
69 printf %s\n  $defaultColor # Doesn't really have a logo, and the colors are too close to PWD blue anyway
70 case ubuntu
71 printf %s\n  E95420 D4D4D4 # https://design.ubuntu.com/brand/
72 case void
73 printf %s\n  FFFFFF 478061 # from https://alpha.de.repo.voidlinux.org/logos/void.svg
74 case '*'
75 return 1
76 end
77end