Add uptime-module to waybar
This commit is contained in:
		
							parent
							
								
									c9b0185c9a
								
							
						
					
					
						commit
						6a85c0e22b
					
				
					 3 changed files with 30 additions and 3 deletions
				
			
		|  | @ -14,6 +14,7 @@ | |||
| 		"cpu", | ||||
| 		"memory", | ||||
| 		"custom/pacman", | ||||
| 		"custom/status", | ||||
| 		"custom/weather", | ||||
| 		"clock", | ||||
| 		"tray" | ||||
|  | @ -32,7 +33,7 @@ | |||
|         "tooltip-format": "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>" | ||||
| 	}, | ||||
| 	"cpu": { | ||||
| 		"format": " {usage}%" | ||||
| 		"format": " {usage}%" | ||||
| 	}, | ||||
| 	"memory": { | ||||
| 		"format": " {percentage}%" | ||||
|  | @ -47,7 +48,7 @@ | |||
| 		"spacing": 4 | ||||
| 	}, | ||||
|     "custom/pacman": { | ||||
|         "format": " {}", | ||||
|         "format": " {}", | ||||
|         "interval": 3600, | ||||
|         "exec": "~/.config/waybar/custom/pacman", | ||||
|         "on-click": "alacritty -e 'archlinux-update'", | ||||
|  | @ -61,5 +62,13 @@ | |||
| 		"format": "{}", | ||||
| 		"tooltip": true, | ||||
| 		"interval": 1200 | ||||
| 	}, | ||||
| 	"custom/status": { | ||||
| 		"format": " {}", | ||||
|         "exec": "~/.config/waybar/custom/status-serguzim-net", | ||||
|         "on-click": "xdg-open 'https://status.serguzim.net'", | ||||
| 		"return-type": "json", | ||||
| 		"tooltip": true, | ||||
| 		"interval": 500 | ||||
| 	} | ||||
| } | ||||
|  |  | |||
							
								
								
									
										14
									
								
								.config/waybar/custom/status-serguzim-net
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										14
									
								
								.config/waybar/custom/status-serguzim-net
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,14 @@ | |||
| #!/usr/bin/env sh | ||||
| 
 | ||||
| result=$(curl https://status.serguzim.net/api/status-page/heartbeat/serguzim-net \ | ||||
| 	| jq '.heartbeatList | to_entries | map(.value | last .status)  | ||||
| 	| [group_by(.)[] | {value: .[0], count: length}] | map({(.value|tostring): .count}) | add') | ||||
| 
 | ||||
| up_count=$(echo "$result" | jq '."1" // 0') | ||||
| down_count=$(echo "$result" | jq '."0" // 0') | ||||
| count=$((up_count + down_count)) | ||||
| percent=$((up_count * 100 / count)) | ||||
| 
 | ||||
| tooltip="status.serguzim.net\nUp: $up_count\nDown: $down_count\nTotal: $count\nPercent: $percent%" | ||||
| 
 | ||||
| echo "{\"text\": \"$percent%\", \"tooltip\": \"$tooltip\"}" | ||||
|  | @ -4,7 +4,7 @@ | |||
|     border: none; | ||||
| 	border-radius: 0; | ||||
| 	 | ||||
|     font-family: "JetBrains Mono", monospace; | ||||
|     font-family: "JetBrainsMono Nerd Font", monospace; | ||||
|     font-size: 10pt; | ||||
|     min-height: 0; | ||||
| } | ||||
|  | @ -56,3 +56,7 @@ window#waybar { | |||
| #custom-pacman { | ||||
| 	border-bottom: solid 2px @cyan; | ||||
| } | ||||
| 
 | ||||
| #custom-status { | ||||
| 	border-bottom: solid 2px @orange; | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue