New Fastfetch prompt with weather script and fancy title
This commit is contained in:
parent
bb80bd064d
commit
4b938f89f7
4 changed files with 224 additions and 40 deletions
|
@ -9,6 +9,8 @@
|
|||
let
|
||||
hostname = config.hostSpec.hostName;
|
||||
logoFile = ./. + "/host/${hostname}.txt";
|
||||
weather = import ./scripts/weather.nix { inherit pkgs; };
|
||||
title = import ./scripts/title.nix { inherit pkgs; };
|
||||
in
|
||||
{
|
||||
enable = true;
|
||||
|
@ -24,71 +26,146 @@
|
|||
};
|
||||
};
|
||||
display = {
|
||||
separator = " ";
|
||||
bar = {
|
||||
borderLeft = "⦉";
|
||||
borderRight = "⦊";
|
||||
charElapsed = "⏹";
|
||||
charTotal = "⬝";
|
||||
width = 10;
|
||||
};
|
||||
percent = {
|
||||
type = 2;
|
||||
};
|
||||
separator = "";
|
||||
};
|
||||
# modules = [
|
||||
# {
|
||||
# type = "colors";
|
||||
# symbol = "square";
|
||||
# }
|
||||
# "break"
|
||||
# {
|
||||
# key = "{#31} ┤ user »{#keys}";
|
||||
# type = "title";
|
||||
# format = "{user-name}";
|
||||
# }
|
||||
# {
|
||||
# key = "{#32} ┤ host »{#keys}";
|
||||
# type = "title";
|
||||
# format = "{host-name}";
|
||||
# }
|
||||
# {
|
||||
# key = "{#33} ┤ uptime »{#keys}";
|
||||
# type = "uptime";
|
||||
# }
|
||||
# {
|
||||
# key = "{#34} ┤ distro »{#keys}";
|
||||
# type = "os";
|
||||
# }
|
||||
# {
|
||||
# key = "{#36} ┤ desktop »{#keys}";
|
||||
# type = "de";
|
||||
# }
|
||||
# {
|
||||
# key = "{#32} ┤ shell »{#keys}";
|
||||
# type = "shell";
|
||||
# }
|
||||
# {
|
||||
# key = "{#33} ┤ cpu »{#keys}";
|
||||
# type = "cpu";
|
||||
# showPeCoreCount = true;
|
||||
# }
|
||||
# {
|
||||
# key = "{#34} ┤ disk »{#keys}";
|
||||
# type = "disk";
|
||||
# folders = "/";
|
||||
# }
|
||||
# {
|
||||
# key = "{#35} ┤ memory »{#keys}";
|
||||
# type = "memory";
|
||||
# }
|
||||
# {
|
||||
# key = "{#36} ┤ network »{#keys}";
|
||||
# type = "localip";
|
||||
# format = "{ipv4} ({ifname})";
|
||||
# }
|
||||
# "break"
|
||||
# {
|
||||
# type = "colors";
|
||||
# symbol = "square";
|
||||
# }
|
||||
# ];
|
||||
modules = [
|
||||
"break"
|
||||
{
|
||||
key = "╭───────────╮";
|
||||
type = "custom";
|
||||
key = " ";
|
||||
shell = "fish";
|
||||
text = "fish ${title}";
|
||||
type = "command";
|
||||
}
|
||||
"break"
|
||||
{
|
||||
key = "weather » {#keys}";
|
||||
keyColor = "1;97";
|
||||
shell = "${pkgs.fish}/bin/fish";
|
||||
text = "fish ${weather} 'Richmond'";
|
||||
type = "command";
|
||||
}
|
||||
{
|
||||
key = "│ {#31} user {#keys}│";
|
||||
type = "title";
|
||||
format = "{user-name}";
|
||||
key = "cpu » {#keys}";
|
||||
keyColor = "1;31";
|
||||
showPeCoreCount = true;
|
||||
type = "cpu";
|
||||
}
|
||||
{
|
||||
key = "│ {#32} host {#keys}│";
|
||||
type = "title";
|
||||
format = "{host-name}";
|
||||
format = "{0} ({#3;32}{3}{#})";
|
||||
key = "wm » {#keys}";
|
||||
keyColor = "1;32";
|
||||
type = "wm";
|
||||
}
|
||||
{
|
||||
key = "│ {#33} uptime {#keys}│";
|
||||
text = "printf '%s%s' (string upper (string sub -l 1 $SHELL)) (string lower (string sub -s 2 $SHELL))";
|
||||
key = "shell » {#keys}";
|
||||
keyColor = "1;33";
|
||||
type = "command";
|
||||
shell = "${pkgs.fish}/bin/fish";
|
||||
}
|
||||
{
|
||||
key = "uptime » {#keys}";
|
||||
keyColor = "1;34";
|
||||
type = "uptime";
|
||||
}
|
||||
{
|
||||
key = "│ {#34}{icon} distro {#keys}│";
|
||||
type = "os";
|
||||
}
|
||||
{
|
||||
key = "│ {#36} desktop {#keys}│";
|
||||
type = "de";
|
||||
}
|
||||
{
|
||||
key = "│ {#32} shell {#keys}│";
|
||||
type = "shell";
|
||||
}
|
||||
{
|
||||
key = "│ {#33} cpu {#keys}│";
|
||||
type = "cpu";
|
||||
showPeCoreCount = true;
|
||||
}
|
||||
{
|
||||
key = "│ {#34} disk {#keys}│";
|
||||
type = "disk";
|
||||
folders = "/";
|
||||
format = "{0~0,-4} / {2} {13}";
|
||||
key = "disk » {#keys}";
|
||||
keyColor = "1;35";
|
||||
type = "disk";
|
||||
}
|
||||
{
|
||||
key = "│ {#35} memory {#keys}│";
|
||||
format = "{0~0,-4} / {2} {4}";
|
||||
key = "memory » {#keys}";
|
||||
keyColor = "1;36";
|
||||
type = "memory";
|
||||
}
|
||||
{
|
||||
key = "│ {#36} network {#keys}│";
|
||||
format = "{ipv4~0,-3} ({#3;32}{ifname}{#})";
|
||||
key = "network » {#keys}";
|
||||
keyColor = "1;37";
|
||||
type = "localip";
|
||||
format = "{ipv4} ({ifname})";
|
||||
}
|
||||
{
|
||||
key = "├───────────┤";
|
||||
type = "custom";
|
||||
format = "{artist} - {title} ({#3;32}{6}{#})";
|
||||
key = "media » {#keys}";
|
||||
keyColor = "5;92";
|
||||
type = "media";
|
||||
}
|
||||
"break"
|
||||
{
|
||||
key = "│ {#39} colors {#keys}│";
|
||||
symbol = "square";
|
||||
type = "colors";
|
||||
symbol = "circle";
|
||||
}
|
||||
{
|
||||
key = "╰───────────╯";
|
||||
type = "custom";
|
||||
}
|
||||
"break"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
|
39
home/toph/common/core/fastfetch/scripts/title.nix
Normal file
39
home/toph/common/core/fastfetch/scripts/title.nix
Normal file
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
pkgs.writeScript "title" ''
|
||||
#!/usr/bin/env fish
|
||||
|
||||
# Customize these color commands as you like
|
||||
set colorUser (set_color --bold cyan)
|
||||
set colorHost (set_color --bold blue)
|
||||
set colorOS (set_color --bold magenta)
|
||||
set colorVersion (set_color --bold magenta)
|
||||
set colorCodename (set_color --bold --italic magenta)
|
||||
set colorBang (set_color --bold white)
|
||||
set colorReset (set_color normal)
|
||||
|
||||
# Get uppercase user, host, OS name
|
||||
set u (whoami)
|
||||
set user (printf '%s%s' (string upper (string sub -l 1 $u)) (string lower (string sub -s 2 $u)))
|
||||
|
||||
set h (hostname)
|
||||
set host (printf '%s%s' (string upper (string sub -l 1 $h)) (string lower (string sub -s 2 $h)))
|
||||
|
||||
set osN (grep '^NAME=' /etc/os-release | cut -d= -f2 | tr -d '"')
|
||||
set osName (printf '%s%s' (string upper (string sub -l 1 $osN)) (string lower (string sub -s 2 $osN)))
|
||||
|
||||
set osVersion (grep '^VERSION_ID=' /etc/os-release | cut -d= -f2 | tr -d '"')
|
||||
|
||||
set osCN (grep '^VERSION_CODENAME=' /etc/os-release | cut -d= -f2 | tr -d '"')
|
||||
set osCodeName (printf '%s%s' (string upper (string sub -l 1 $osCN)) (string lower (string sub -s 2 $osCN)))
|
||||
|
||||
# Print each part as you like
|
||||
echo -n $colorUser$user$colorReset
|
||||
echo -n $colorBang" ⸘ "
|
||||
echo -n $colorHost$host$colorReset
|
||||
echo -n $colorBang" ‽ "
|
||||
echo -n $colorOS$osName" "$colorVersion$osVersion$colorReset" "
|
||||
echo $colorOS'('$colorCodename$osCodeName$colorReset$colorOS')'
|
||||
''
|
68
home/toph/common/core/fastfetch/scripts/weather.nix
Normal file
68
home/toph/common/core/fastfetch/scripts/weather.nix
Normal file
|
@ -0,0 +1,68 @@
|
|||
{
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
# INFO: Based on https://github.com/fcambus/ansiweather
|
||||
pkgs.writeScript "weather" ''
|
||||
#!/usr/bin/env fish
|
||||
|
||||
# Usage: ./weather.fish "Richmond,US"
|
||||
|
||||
if not set -q argv[1]
|
||||
echo "Usage: ./weather <city>"
|
||||
exit 1
|
||||
end
|
||||
|
||||
# URL-encode spaces in city name
|
||||
set CITY (echo $argv[1] | sed 's/ /%20/g')
|
||||
set API_KEY 85a4e3c55b73909f42c6a23ec35b7147
|
||||
|
||||
if test -z "$API_KEY"
|
||||
echo "Please set the environment variable API_KEY"
|
||||
exit 1
|
||||
end
|
||||
|
||||
set WEATHER_API_URL "https://api.openweathermap.org/data/2.5/weather?q=$CITY&units=metric&appid=$API_KEY"
|
||||
|
||||
# Fetch current weather data
|
||||
set weather_data (curl -s "$WEATHER_API_URL")
|
||||
|
||||
# Parse needed fields
|
||||
set city_name (set_color -i green)(echo $weather_data | jq -r '.name')(set_color reset)
|
||||
set temperature (echo $weather_data | jq -r '.main.temp' | xargs printf "%.0f")
|
||||
set humidity (echo $weather_data | jq -r '.main.humidity')
|
||||
set weather_main (echo $weather_data | jq -r '.weather[0].main')
|
||||
set lon (echo $weather_data | jq -r '.coord.lon')
|
||||
set lat (echo $weather_data | jq -r '.coord.lat')
|
||||
|
||||
# Fetch UVI data
|
||||
set UVI_API_URL "https://api.openweathermap.org/data/2.5/uvi?lat=$lat&lon=$lon&appid=$API_KEY"
|
||||
set uvi_data (curl -s "$UVI_API_URL")
|
||||
set uvi (echo $uvi_data | jq -r '.value')
|
||||
|
||||
# Helper function for weather icon
|
||||
function weather_icon
|
||||
switch $argv[1]
|
||||
case "Clouds"
|
||||
echo "☁"
|
||||
case "Clear"
|
||||
echo "☀"
|
||||
case "Rain"
|
||||
echo "🌧"
|
||||
case "Snow"
|
||||
echo "❄"
|
||||
case "Thunderstorm"
|
||||
echo "⛈"
|
||||
case "Drizzle"
|
||||
echo "🌦"
|
||||
case "Mist" "Haze" "Fog" "Smoke" "Dust" "Sand" "Ash" "Squall" "Tornado"
|
||||
echo "🌫"
|
||||
case "*"
|
||||
echo "🌈"
|
||||
end
|
||||
end
|
||||
|
||||
set icon (weather_icon $weather_main)
|
||||
|
||||
printf "%s %s°C ⸗ %s ⸗ %s%% (%s)\n" $icon $temperature $uvi $humidity $city_name
|
||||
''
|
Loading…
Add table
Reference in a new issue