|
60 | 60 | fi |
61 | 61 | ''; |
62 | 62 |
|
63 | | - # Weather helper |
64 | | - weatherHelper = pkgs.writeShellScriptBin "ashell-weather-helper" '' |
65 | | - if [ -f "${config.home.homeDirectory}/weather_config.json" ]; then |
66 | | - WEATHER=$(${lib.getExe pkgs.curl} -s "$(cat ${config.home.homeDirectory}/weather_config.json | ${lib.getExe pkgs.jq} -r .url)" | \ |
67 | | - ${lib.getExe pkgs.jq} -r '.current.condition.text + " " + (.current.temp_c | tostring) + "°C"' 2>/dev/null || echo "Weather N/A") |
68 | | - echo "{\"text\": \"$WEATHER\", \"alt\": \"weather\"}" |
| 63 | + # Detailed weather popup |
| 64 | + weatherDetailPopup = pkgs.writeShellScriptBin "ashell-weather-detail" '' |
| 65 | + # Get comprehensive weather information |
| 66 | + CURRENT_WEATHER=$(${lib.getExe pkgs.curl} -s "wttr.in?format=j1" 2>/dev/null) |
| 67 | +
|
| 68 | + if [ $? -eq 0 ] && [ -n "$CURRENT_WEATHER" ]; then |
| 69 | + # Parse JSON for detailed info |
| 70 | + LOCATION=$(echo "$CURRENT_WEATHER" | ${lib.getExe pkgs.jq} -r '.nearest_area[0].areaName[0].value + ", " + .nearest_area[0].country[0].value') |
| 71 | + CURRENT_TEMP=$(echo "$CURRENT_WEATHER" | ${lib.getExe pkgs.jq} -r '.current_condition[0].temp_F + "°F (" + .current_condition[0].temp_C + "°C)"') |
| 72 | + FEELS_LIKE=$(echo "$CURRENT_WEATHER" | ${lib.getExe pkgs.jq} -r '.current_condition[0].FeelsLikeF + "°F (" + .current_condition[0].FeelsLikeC + "°C)"') |
| 73 | + CONDITION=$(echo "$CURRENT_WEATHER" | ${lib.getExe pkgs.jq} -r '.current_condition[0].weatherDesc[0].value') |
| 74 | + HUMIDITY=$(echo "$CURRENT_WEATHER" | ${lib.getExe pkgs.jq} -r '.current_condition[0].humidity + "%"') |
| 75 | + WIND=$(echo "$CURRENT_WEATHER" | ${lib.getExe pkgs.jq} -r '.current_condition[0].windspeedMiles + " mph " + .current_condition[0].winddir16Point') |
| 76 | + UV_INDEX=$(echo "$CURRENT_WEATHER" | ${lib.getExe pkgs.jq} -r '.current_condition[0].uvIndex') |
| 77 | + VISIBILITY=$(echo "$CURRENT_WEATHER" | ${lib.getExe pkgs.jq} -r '.current_condition[0].visibility + " miles"') |
| 78 | +
|
| 79 | + # Get today's forecast |
| 80 | + TODAY_HIGH=$(echo "$CURRENT_WEATHER" | ${lib.getExe pkgs.jq} -r '.weather[0].maxtempF + "°F"') |
| 81 | + TODAY_LOW=$(echo "$CURRENT_WEATHER" | ${lib.getExe pkgs.jq} -r '.weather[0].mintempF + "°F"') |
| 82 | +
|
| 83 | + WEATHER_DETAIL="🌍 Location: $LOCATION |
| 84 | +
|
| 85 | + 🌡️ Current: $CURRENT_TEMP |
| 86 | + 🤚 Feels like: $FEELS_LIKE |
| 87 | + ☁️ Condition: $CONDITION |
| 88 | +
|
| 89 | + 📊 Today's Range: $TODAY_LOW - $TODAY_HIGH |
| 90 | + 💧 Humidity: $HUMIDITY |
| 91 | + 💨 Wind: $WIND |
| 92 | + ☀️ UV Index: $UV_INDEX |
| 93 | + 👁️ Visibility: $VISIBILITY" |
69 | 94 | else |
70 | | - echo "{\"text\": \"Weather N/A\", \"alt\": \"none\"}" |
| 95 | + WEATHER_DETAIL="❌ Unable to fetch detailed weather information" |
71 | 96 | fi |
| 97 | +
|
| 98 | + # Show in rofi popup |
| 99 | + if command -v ${lib.getExe pkgs.rofi} &> /dev/null; then |
| 100 | + echo "$WEATHER_DETAIL" | ${lib.getExe pkgs.rofi} -dmenu -p "Weather Details" -theme-str 'window {width: 500px; height: 350px;}' -no-custom |
| 101 | + else |
| 102 | + # Fallback to terminal notification |
| 103 | + echo "$WEATHER_DETAIL" |
| 104 | + fi |
| 105 | + ''; |
| 106 | + |
| 107 | + # Power menu helper with rofi integration |
| 108 | + powerMenuHelper = pkgs.writeShellScriptBin "ashell-power-menu" '' |
| 109 | + # Create power menu options |
| 110 | + POWER_OPTIONS="🔒 Lock |
| 111 | + 🌙 Sleep |
| 112 | + 🔄 Restart |
| 113 | + ⏻ Shutdown |
| 114 | + 🚪 Logout" |
| 115 | +
|
| 116 | + # Use rofi to display power options |
| 117 | + SELECTED=$(echo "$POWER_OPTIONS" | ${lib.getExe pkgs.rofi} -dmenu -p "Power Menu" -theme-str 'window {width: 200px;}' -no-custom) |
| 118 | +
|
| 119 | + case "$SELECTED" in |
| 120 | + "🔒 Lock") |
| 121 | + ${lib.getExe config.programs.hyprlock.package} & |
| 122 | + ;; |
| 123 | + "🌙 Sleep") |
| 124 | + systemctl suspend |
| 125 | + ;; |
| 126 | + "🔄 Restart") |
| 127 | + systemctl reboot |
| 128 | + ;; |
| 129 | + "⏻ Shutdown") |
| 130 | + systemctl poweroff |
| 131 | + ;; |
| 132 | + "🚪 Logout") |
| 133 | + ${lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl"} dispatch exit |
| 134 | + ;; |
| 135 | + esac |
72 | 136 | ''; |
73 | 137 |
|
74 | 138 | # Default custom modules |
75 | | - defaultCustomModules = [ |
76 | | - { |
77 | | - name = "CustomNotifications"; |
78 | | - icon = ""; |
79 | | - command = "${lib.getExe' config.services.swaync.package "swaync-client"} -t -sw"; |
80 | | - listen_cmd = "${lib.getExe notificationHelper}"; |
81 | | - icons = { |
82 | | - "dnd.*" = ""; |
83 | | - "notification" = ""; |
84 | | - "none" = ""; |
85 | | - }; |
86 | | - alert = ".*notification"; |
87 | | - } |
88 | | - { |
89 | | - name = "CustomGithub"; |
90 | | - icon = ""; |
91 | | - command = "${lib.getExe' pkgs.xdg-utils "xdg-open"} https://github.com/notifications"; |
92 | | - listen_cmd = "${lib.getExe githubHelper}"; |
93 | | - icons = { |
94 | | - "notification" = ""; |
95 | | - "none" = ""; |
96 | | - }; |
97 | | - alert = ".*notification"; |
98 | | - } |
99 | | - { |
100 | | - name = "CustomWeather"; |
101 | | - icon = ""; |
102 | | - command = "${lib.getExe' pkgs.xdg-utils "xdg-open"} https://weather.com"; |
103 | | - listen_cmd = "${lib.getExe weatherHelper}"; |
104 | | - icons = { |
105 | | - "weather" = ""; |
106 | | - "none" = ""; |
107 | | - }; |
108 | | - } |
109 | | - ]; |
| 139 | + CustomPowerMenu = { |
| 140 | + name = "CustomPowerMenu"; |
| 141 | + icon = ""; |
| 142 | + command = "${lib.getExe powerMenuHelper}"; |
| 143 | + icons = { |
| 144 | + "power" = ""; |
| 145 | + "none" = ""; |
| 146 | + }; |
| 147 | + }; |
| 148 | + CustomNotifications = { |
| 149 | + name = "CustomNotifications"; |
| 150 | + icon = ""; |
| 151 | + command = "${lib.getExe' config.services.swaync.package "swaync-client"} -t -sw"; |
| 152 | + listen_cmd = "${lib.getExe notificationHelper}"; |
| 153 | + icons = { |
| 154 | + "dnd.*" = ""; |
| 155 | + "notification" = ""; |
| 156 | + "none" = ""; |
| 157 | + }; |
| 158 | + alert = ".*notification"; |
| 159 | + }; |
| 160 | + CustomGithub = { |
| 161 | + name = "CustomGithub"; |
| 162 | + icon = ""; |
| 163 | + command = "${lib.getExe' pkgs.xdg-utils "xdg-open"} https://github.com/notifications"; |
| 164 | + listen_cmd = "${lib.getExe githubHelper}"; |
| 165 | + icons = { |
| 166 | + "notification" = ""; |
| 167 | + "none" = ""; |
| 168 | + }; |
| 169 | + alert = ".*notification"; |
| 170 | + }; |
| 171 | + CustomWeather = { |
| 172 | + name = "CustomWeather"; |
| 173 | + icon = " "; |
| 174 | + command = "${lib.getExe weatherDetailPopup}"; |
| 175 | + listen_cmd = "${ |
| 176 | + lib.getExe ( |
| 177 | + pkgs.wttrbar.overrideAttrs { |
| 178 | + # Ashell needs `alt` instead of tooltip |
| 179 | + postPatch = '' |
| 180 | + substituteInPlace src/main.rs \ |
| 181 | + --replace-fail "data.insert(\"tooltip\", tooltip);" \ |
| 182 | + "data.insert(\"alt\", tooltip);" |
| 183 | + ''; |
| 184 | + } |
| 185 | + ) |
| 186 | + } --fahrenheit --ampm"; |
| 187 | + icons = { |
| 188 | + "weather" = ""; |
| 189 | + "none" = ""; |
| 190 | + }; |
| 191 | + }; |
110 | 192 |
|
111 | 193 | # All custom modules (default + user-defined) |
112 | | - allCustomModules = defaultCustomModules ++ cfg.customModules; |
| 194 | + allCustomModules = [ |
| 195 | + CustomGithub |
| 196 | + CustomNotifications |
| 197 | + CustomPowerMenu |
| 198 | + CustomWeather |
| 199 | + ] ++ cfg.customModules; |
| 200 | + |
| 201 | + leftModules = [ |
| 202 | + "CustomPowerMenu" |
| 203 | + "Workspaces" |
| 204 | + "WindowTitle" |
| 205 | + ]; |
| 206 | + |
| 207 | + rightModules = [ |
| 208 | + "SystemInfo" |
| 209 | + [ |
| 210 | + "Clipboard" |
| 211 | + "CustomNotifications" |
| 212 | + "CustomGithub" |
| 213 | + ] |
| 214 | + [ |
| 215 | + "CustomWeather" |
| 216 | + "Clock" |
| 217 | + "Privacy" |
| 218 | + "Settings" |
| 219 | + ] |
| 220 | + ]; |
113 | 221 |
|
114 | 222 | # Configuration for different bar sizes |
115 | 223 | commonModules = { |
116 | | - left = [ "Workspaces" ]; |
117 | | - center = [ "WindowTitle" ]; |
118 | | - right = |
119 | | - [ "SystemInfo" ] |
120 | | - ++ (builtins.map (mod: mod.name) allCustomModules) |
121 | | - ++ [ |
122 | | - [ |
123 | | - "Clock" |
124 | | - "Privacy" |
125 | | - "Settings" |
126 | | - ] |
127 | | - ]; |
| 224 | + left = leftModules; |
| 225 | + center = [ ]; |
| 226 | + right = rightModules; |
128 | 227 | }; |
129 | 228 |
|
130 | 229 | fullSizeModules = { |
131 | | - left = [ "Workspaces" ]; |
132 | | - center = [ "WindowTitle" ]; |
133 | | - right = |
134 | | - [ |
135 | | - "Tray" |
136 | | - "SystemInfo" |
137 | | - ] |
138 | | - ++ (builtins.map (mod: mod.name) allCustomModules) |
139 | | - ++ [ |
140 | | - [ |
141 | | - "Clock" |
142 | | - "Privacy" |
143 | | - "Settings" |
144 | | - ] |
145 | | - ]; |
| 230 | + left = leftModules; |
| 231 | + center = [ "MediaPlayer" ]; |
| 232 | + right = [ |
| 233 | + "Tray" |
| 234 | + ] ++ rightModules; |
146 | 235 | }; |
147 | 236 | in |
148 | 237 | { |
149 | 238 | log_level = "warn"; |
150 | 239 | outputs = "All"; |
151 | 240 | position = "Top"; |
152 | 241 |
|
153 | | - app_launcher_cmd = "~/.config/rofi/launcher.sh"; |
| 242 | + app_launcher_cmd = "anyrun"; |
154 | 243 | clipboard_cmd = "cliphist-rofi-img | wl-copy"; |
155 | 244 | truncate_title_after_length = 150; |
156 | 245 |
|
|
167 | 256 |
|
168 | 257 | system = { |
169 | 258 | indicators = [ |
| 259 | + "DownloadSpeed" |
| 260 | + "UploadSpeed" |
170 | 261 | "Cpu" |
171 | 262 | "Memory" |
172 | 263 | "Temperature" |
|
0 commit comments