this repo has no description

Use sun or moon icon based on local time

rwxroot 263a3c82 e40277a4

+8 -16
Cargo.lock
··· 774 774 source = "git+https://github.com/pop-os/window_clipboard.git?tag=pop-0.13-2#6b9faab87bea9cebec6ae036906fd67fed254f5f" 775 775 dependencies = [ 776 776 "dnd", 777 - "mime 0.1.0", 777 + "mime", 778 778 "smithay-clipboard", 779 779 ] 780 780 ··· 976 976 name = "cosmic-ext-applet-weather" 977 977 version = "0.1.0" 978 978 dependencies = [ 979 + "chrono", 979 980 "libcosmic", 980 981 "reqwest", 981 982 "serde", ··· 1325 1326 source = "git+https://github.com/pop-os/window_clipboard.git?tag=pop-0.13-2#6b9faab87bea9cebec6ae036906fd67fed254f5f" 1326 1327 dependencies = [ 1327 1328 "bitflags 2.9.1", 1328 - "mime 0.1.0", 1329 + "mime", 1329 1330 "raw-window-handle", 1330 1331 "smithay-client-toolkit 0.19.2 (registry+https://github.com/rust-lang/crates.io-index)", 1331 1332 "smithay-clipboard", ··· 2151 2152 "iced_widget", 2152 2153 "iced_winit", 2153 2154 "image", 2154 - "mime 0.1.0", 2155 + "mime", 2155 2156 "thiserror 1.0.69", 2156 2157 "window_clipboard", 2157 2158 ] ··· 2176 2177 "dnd", 2177 2178 "glam", 2178 2179 "log", 2179 - "mime 0.1.0", 2180 + "mime", 2180 2181 "num-traits", 2181 2182 "once_cell", 2182 2183 "palette", ··· 2985 2986 ] 2986 2987 2987 2988 [[package]] 2988 - name = "mime" 2989 - version = "0.3.17" 2990 - source = "registry+https://github.com/rust-lang/crates.io-index" 2991 - checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" 2992 - 2993 - [[package]] 2994 2989 name = "miniz_oxide" 2995 2990 version = "0.8.8" 2996 2991 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 4109 4104 4110 4105 [[package]] 4111 4106 name = "reqwest" 4112 - version = "0.12.19" 4107 + version = "0.12.20" 4113 4108 source = "registry+https://github.com/rust-lang/crates.io-index" 4114 - checksum = "a2f8e5513d63f2e5b386eb5106dc67eaf3f84e95258e210489136b8b92ad6119" 4109 + checksum = "eabf4c97d9130e2bf606614eb937e86edac8292eaa6f422f995d7e8de1eb1813" 4115 4110 dependencies = [ 4116 4111 "base64 0.22.1", 4117 4112 "bytes", ··· 4122 4117 "hyper", 4123 4118 "hyper-rustls", 4124 4119 "hyper-util", 4125 - "ipnet", 4126 4120 "js-sys", 4127 4121 "log", 4128 - "mime 0.3.17", 4129 - "once_cell", 4130 4122 "percent-encoding", 4131 4123 "pin-project-lite", 4132 4124 "quinn", ··· 5732 5724 "clipboard_wayland", 5733 5725 "clipboard_x11", 5734 5726 "dnd", 5735 - "mime 0.1.0", 5727 + "mime", 5736 5728 "raw-window-handle", 5737 5729 "thiserror 1.0.69", 5738 5730 ]
+2 -1
Cargo.toml
··· 11 11 lto = "fat" 12 12 13 13 [dependencies] 14 + chrono = { version = "0.4.41",default-features = false } 14 15 libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false, features = [ 15 16 "applet", 16 17 ] } 17 - reqwest = { version = "0.12.19", default-features = false, features = [ 18 + reqwest = { version = "0.12.20", default-features = false, features = [ 18 19 "json", 19 20 "rustls-tls", 20 21 ] }
+2
data/cosmic-ext-applet-weather-moon.svg
··· 1 + <?xml version="1.0" encoding="UTF-8"?> 2 + <svg xmlns="http://www.w3.org/2000/svg" height="16px" viewBox="0 0 16 16" width="16px"><path d="m 0.917969 8.003906 c 0 3.910156 3.167969 7.078125 7.078125 7.078125 c 3.597656 -0.007812 6.621094 -2.710937 7.023437 -6.285156 c 0.042969 -0.378906 -0.136719 -0.75 -0.457031 -0.957031 c -0.324219 -0.203125 -0.738281 -0.207032 -1.0625 -0.003906 c -0.609375 0.375 -1.316406 0.578124 -2.03125 0.578124 c -2.15625 0 -3.882812 -1.726562 -3.882812 -3.882812 c 0 -0.714844 0.203124 -1.421875 0.578124 -2.03125 c 0.203126 -0.324219 0.199219 -0.738281 -0.003906 -1.0625 c -0.207031 -0.320312 -0.578125 -0.5 -0.957031 -0.457031 c -3.574219 0.402343 -6.277344 3.425781 -6.285156 7.023437 z m 4.667969 -3.472656 c 0 3.25 2.632812 5.882812 5.886718 5.882812 c 1.085938 0 2.152344 -0.304687 3.078125 -0.878906 l -1.519531 -0.960937 c -0.289062 2.570312 -2.449219 4.503906 -5.035156 4.507812 c -2.816406 0 -5.078125 -2.261719 -5.078125 -5.078125 c 0.003906 -2.585937 1.9375 -4.746094 4.507812 -5.035156 l -0.960937 -1.519531 c -0.574219 0.925781 -0.878906 1.992187 -0.878906 3.082031 z m 0 0" fill="#222222"/></svg>
+1 -6
data/cosmic-ext-applet-weather-sun.svg
··· 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 - <svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg"> 3 - <g fill="#222222"> 4 - <path d="m 15 7 h -1 c -0.550781 0 -1 0.449219 -1 1 s 0.449219 1 1 1 h 1 c 0.550781 0 1 -0.449219 1 -1 s -0.449219 -1 -1 -1 z m -2.753906 -4.660156 l -0.707032 0.707031 c -0.390624 0.390625 -0.390624 1.023437 0 1.414063 c 0.390626 0.390624 1.023438 0.390624 1.414063 0 l 0.707031 -0.707032 c 0.390625 -0.390625 0.390625 -1.023437 0 -1.414062 s -1.023437 -0.390625 -1.414062 0 z m -5.242188 -1.347656 v 1 c 0 0.550781 0.449219 1 1 1 c 0.550782 0 1 -0.449219 1 -1 v -1 c 0 -0.554688 -0.449218 -1.0000005 -1 -1.0000005 c -0.550781 0 -1 0.4453125 -1 1.0000005 z m -4.660156 2.75 l 0.707031 0.707031 c 0.253907 0.253906 0.621094 0.355469 0.964844 0.261719 c 0.347656 -0.09375 0.617187 -0.363282 0.710937 -0.707032 c 0.089844 -0.347656 -0.007812 -0.714844 -0.261718 -0.96875 l -0.707032 -0.707031 c -0.253906 -0.253906 -0.621093 -0.351563 -0.96875 -0.257813 c -0.34375 0.089844 -0.613281 0.359376 -0.707031 0.707032 c -0.089843 0.34375 0.007813 0.714844 0.261719 0.964844 z m -1.347656 5.242187 h 1 c 0.550781 0 1 -0.445313 1 -1 c 0 -0.550781 -0.449219 -1 -1 -1 h -1 c -0.554688 0 -1.00000025 0.449219 -1.00000025 1 c 0 0.554687 0.44531225 1 1.00000025 1 z m 2.75 4.664063 l 0.707031 -0.707032 c 0.390625 -0.390625 0.390625 -1.027344 0 -1.414062 c -0.386719 -0.390625 -1.023437 -0.390625 -1.414063 0 l -0.707031 0.707031 c -0.390625 0.390625 -0.390625 1.023437 0 1.414063 c 0.390625 0.390624 1.023438 0.390624 1.414063 0 z m 5.246094 1.347656 v -1 c 0 -0.554688 -0.449219 -1 -1 -1 c -0.554688 0 -1 0.445312 -1 1 v 1 c 0 0.550781 0.445312 1 1 1 c 0.550781 0 1 -0.449219 1 -1 z m 4.660156 -2.753906 l -0.707032 -0.707032 c -0.253906 -0.253906 -0.621093 -0.351562 -0.96875 -0.261718 c -0.34375 0.09375 -0.613281 0.363281 -0.707031 0.710937 c -0.09375 0.34375 0.007813 0.710937 0.261719 0.964844 l 0.707031 0.707031 c 0.25 0.253906 0.621094 0.351562 0.964844 0.261719 c 0.347656 -0.09375 0.617187 -0.363281 0.707031 -0.707031 c 0.09375 -0.347657 -0.003906 -0.714844 -0.257812 -0.96875 z m 0 0"/> 5 - <path d="m 8 10 c -1.117188 0 -2 -0.882812 -2 -2 s 0.882812 -2 2 -2 s 2 0.882812 2 2 s -0.882812 2 -2 2 z m 0 -6 c -2.207031 0 -4 1.792969 -4 4 s 1.792969 4 4 4 s 4 -1.792969 4 -4 s -1.792969 -4 -4 -4 z m 0 0"/> 6 - </g> 7 - </svg> 2 + <svg xmlns="http://www.w3.org/2000/svg" height="16px" viewBox="0 0 16 16" width="16px"><g fill="#222222"><path d="m 15 7 h -1 c -0.550781 0 -1 0.449219 -1 1 s 0.449219 1 1 1 h 1 c 0.550781 0 1 -0.449219 1 -1 s -0.449219 -1 -1 -1 z m -2.753906 -4.660156 l -0.707032 0.707031 c -0.390624 0.390625 -0.390624 1.023437 0 1.414063 c 0.390626 0.390624 1.023438 0.390624 1.414063 0 l 0.707031 -0.707032 c 0.390625 -0.390625 0.390625 -1.023437 0 -1.414062 s -1.023437 -0.390625 -1.414062 0 z m -5.242188 -1.347656 v 1 c 0 0.550781 0.449219 1 1 1 c 0.550782 0 1 -0.449219 1 -1 v -1 c 0 -0.554688 -0.449218 -1.0000005 -1 -1.0000005 c -0.550781 0 -1 0.4453125 -1 1.0000005 z m -4.660156 2.75 l 0.707031 0.707031 c 0.253907 0.253906 0.621094 0.355469 0.964844 0.261719 c 0.347656 -0.09375 0.617187 -0.363282 0.710937 -0.707032 c 0.089844 -0.347656 -0.007812 -0.714844 -0.261718 -0.96875 l -0.707032 -0.707031 c -0.253906 -0.253906 -0.621093 -0.351563 -0.96875 -0.257813 c -0.34375 0.089844 -0.613281 0.359376 -0.707031 0.707032 c -0.089843 0.34375 0.007813 0.714844 0.261719 0.964844 z m -1.347656 5.242187 h 1 c 0.550781 0 1 -0.445313 1 -1 c 0 -0.550781 -0.449219 -1 -1 -1 h -1 c -0.554688 0 -1.00000025 0.449219 -1.00000025 1 c 0 0.554687 0.44531225 1 1.00000025 1 z m 2.75 4.664063 l 0.707031 -0.707032 c 0.390625 -0.390625 0.390625 -1.027344 0 -1.414062 c -0.386719 -0.390625 -1.023437 -0.390625 -1.414063 0 l -0.707031 0.707031 c -0.390625 0.390625 -0.390625 1.023437 0 1.414063 c 0.390625 0.390624 1.023438 0.390624 1.414063 0 z m 5.246094 1.347656 v -1 c 0 -0.554688 -0.449219 -1 -1 -1 c -0.554688 0 -1 0.445312 -1 1 v 1 c 0 0.550781 0.445312 1 1 1 c 0.550781 0 1 -0.449219 1 -1 z m 4.660156 -2.753906 l -0.707032 -0.707032 c -0.253906 -0.253906 -0.621093 -0.351562 -0.96875 -0.261718 c -0.34375 0.09375 -0.613281 0.363281 -0.707031 0.710937 c -0.09375 0.34375 0.007813 0.710937 0.261719 0.964844 l 0.707031 0.707031 c 0.25 0.253906 0.621094 0.351562 0.964844 0.261719 c 0.347656 -0.09375 0.617187 -0.363281 0.707031 -0.707031 c 0.09375 -0.347657 -0.003906 -0.714844 -0.257812 -0.96875 z m 0 0"/><path d="m 8 10 c -1.117188 0 -2 -0.882812 -2 -2 s 0.882812 -2 2 -2 s 2 0.882812 2 2 s -0.882812 2 -2 2 z m 0 -6 c -2.207031 0 -4 1.792969 -4 4 s 1.792969 4 4 4 s 4 -1.792969 4 -4 s -1.792969 -4 -4 -4 z m 0 0"/></g></svg>
+6 -2
justfile
··· 18 18 bin-dst := base-dir / 'bin' / NAME 19 19 desktop-dst := share-dst / 'applications' / APPID + '.desktop' 20 20 icon-dst := share-dst / 'icons/hicolor/scalable/apps' / APPID + '-symbolic.svg' 21 - applet-icon-dst := share-dst / 'icons/hicolor/scalable/apps' /APPID + '-sun-symbolic.svg' 21 + applet-sun-icon-dst := share-dst / 'icons/hicolor/scalable/apps' /APPID + '-sun-symbolic.svg' 22 + applet-moon-icon-dst := share-dst / 'icons/hicolor/scalable/apps' /APPID + '-moon-symbolic.svg' 22 23 23 24 install: 24 25 install -Dm0755 {{ bin-src }} {{ bin-dst }} 25 26 install -Dm0644 data/cosmic-ext-applet-weather.svg {{ icon-dst }} 26 - install -Dm0644 data/cosmic-ext-applet-weather-sun.svg {{ applet-icon-dst }} 27 27 install -Dm0644 data/cosmic-ext-applet-weather.desktop {{ desktop-dst }} 28 + install -Dm0644 data/cosmic-ext-applet-weather-sun.svg {{ applet-sun-icon-dst }} 29 + install -Dm0644 data/cosmic-ext-applet-weather-moon.svg {{ applet-moon-icon-dst }} 28 30 29 31 uninstall: 30 32 rm {{ bin-dst }} 31 33 rm {{ icon-dst }} 32 34 rm {{ desktop-dst }} 35 + rm {{ applet-sun-icon-dst }} 36 + rm {{ applet-moon-icon-dst }}
+9 -2
src/applet.rs
··· 1 1 use std::time::Duration; 2 2 3 + use chrono::{Local, Timelike}; 4 + 3 5 use crate::{ 4 - config::{APP_ID, SUN_ICON, WeatherConfig}, 6 + config::{APP_ID, MOON_ICON, SUN_ICON, WeatherConfig}, 5 7 weather::get_location_forecast, 6 8 }; 7 9 ··· 92 94 } 93 95 94 96 fn view(&self) -> cosmic::Element<Message> { 97 + let icon_name = match Local::now().hour() { 98 + 6..19 => SUN_ICON, 99 + _ => MOON_ICON, 100 + }; 101 + 95 102 let icon = cosmic::iced_widget::row![ 96 - cosmic::widget::icon::from_name(SUN_ICON) 103 + cosmic::widget::icon::from_name(icon_name) 97 104 .size(14) 98 105 .symbolic(true), 99 106 ]
+1
src/config.rs
··· 6 6 7 7 pub const APP_ID: &str = "io.github.cosmic-utils.cosmic-ext-applet-weather"; 8 8 pub const SUN_ICON: &str = "io.github.cosmic-utils.cosmic-ext-applet-weather-sun-symbolic"; 9 + pub const MOON_ICON: &str = "io.github.cosmic-utils.cosmic-ext-applet-weather-moon-symbolic"; 9 10 10 11 #[derive(Default, Debug, CosmicConfigEntry)] 11 12 pub struct WeatherConfig {