Skip to content

Commit 8c28265

Browse files
committed
khanelinix: ashell config
1 parent 72f2b37 commit 8c28265

2 files changed

Lines changed: 166 additions & 71 deletions

File tree

homes/x86_64-linux/khaneliman@khanelinix/default.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ in
5353
};
5454

5555
bars = {
56+
ashell = {
57+
fullSizeOutputs = [ "DP-1" ];
58+
condensedOutputs = [ "DP-3" ];
59+
};
5660
waybar = {
5761
enableDebug = true;
5862
# enableInspect = true;

modules/home/programs/graphical/bars/ashell/default.nix

Lines changed: 162 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -60,97 +60,186 @@ in
6060
fi
6161
'';
6262

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"
6994
else
70-
echo "{\"text\": \"Weather N/A\", \"alt\": \"none\"}"
95+
WEATHER_DETAIL="❌ Unable to fetch detailed weather information"
7196
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
72136
'';
73137

74138
# 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+
};
110192

111193
# 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+
];
113221

114222
# Configuration for different bar sizes
115223
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;
128227
};
129228

130229
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;
146235
};
147236
in
148237
{
149238
log_level = "warn";
150239
outputs = "All";
151240
position = "Top";
152241

153-
app_launcher_cmd = "~/.config/rofi/launcher.sh";
242+
app_launcher_cmd = "anyrun";
154243
clipboard_cmd = "cliphist-rofi-img | wl-copy";
155244
truncate_title_after_length = 150;
156245

@@ -167,6 +256,8 @@ in
167256

168257
system = {
169258
indicators = [
259+
"DownloadSpeed"
260+
"UploadSpeed"
170261
"Cpu"
171262
"Memory"
172263
"Temperature"

0 commit comments

Comments
 (0)