14 | )
15 | }
16 |
17 | export default render
18 |
--------------------------------------------------------------------------------
/lib/Memory/style.jsx:
--------------------------------------------------------------------------------
1 | export const container = {
2 | height: '100%',
3 | width: '85px',
4 | position: 'absolute',
5 | right: '330px',
6 | top: '0px'
7 | }
8 |
9 | export const arrow = {
10 | height: '0',
11 | width: '0',
12 | borderTop: '10px solid transparent',
13 | borderBottom: '10px solid transparent',
14 | borderRight:'10px solid rgba(76, 86, 106, 1)',
15 | position: 'absolute',
16 | left: '0px'
17 | }
18 |
19 | export const content = {
20 | height: '100%',
21 | width: '75px',
22 | background: 'rgba(76, 86, 106, 1)',
23 | textAlign: 'left',
24 | color: 'rgba(235, 239, 243, 1)',
25 | position: 'absolute',
26 | right: '-10px',
27 | paddingLeft: '10px'
28 | }
29 |
30 | export default null
31 |
--------------------------------------------------------------------------------
/lib/Wifi/index.jsx:
--------------------------------------------------------------------------------
1 | import { container, arrow, content } from './style.jsx';
2 |
3 | const render = ({output}) => {
4 | if (typeof output === 'undefined') return null;
5 | return (
6 |
7 |
8 |
9 | {output.ssid}
10 |
11 |
12 | )
13 | }
14 |
15 | export default render
16 |
--------------------------------------------------------------------------------
/lib/Wifi/style.jsx:
--------------------------------------------------------------------------------
1 | export const container = {
2 | height: '100%',
3 | width: '125px',
4 | position: 'absolute',
5 | right: '515px',
6 | top: '0px'
7 | }
8 |
9 | export const arrow = {
10 | height: '0',
11 | width: '0',
12 | borderTop: '10px solid transparent',
13 | borderBottom: '10px solid transparent',
14 | borderRight:'10px solid rgba(76, 86, 106, 1)',
15 | position: 'absolute',
16 | left: '0px'
17 | }
18 |
19 | export const content = {
20 | height: '100%',
21 | width: '115px',
22 | background: 'rgba(76, 86, 106, 1)',
23 | textAlign: 'left',
24 | color: 'rgba(235, 239, 243, 1)',
25 | position: 'absolute',
26 | right: '-10px',
27 | paddingLeft: '10px'
28 | }
29 |
30 | export default null
31 |
--------------------------------------------------------------------------------
/lib/parse.jsx:
--------------------------------------------------------------------------------
1 | const parse = (data) => {
2 | try {
3 | return JSON.parse(data)
4 | } catch (e) {
5 | return undefined;
6 | }
7 | }
8 |
9 | export default parse
10 |
--------------------------------------------------------------------------------
/lib/style.jsx:
--------------------------------------------------------------------------------
1 | export const bar = {
2 | background: 'rgba(46, 51, 64, 0.5)',
3 | zIndex: '-1',
4 | width: '100%',
5 | height: '20px',
6 | position: 'fixed',
7 | display: 'flex',
8 | overflow: 'hidden',
9 | top: '0px',
10 | right: '0px',
11 | left: '0px',
12 | WebkitBackdropFilter: 'blur(15px)'
13 | }
14 |
15 | export const leftSide = {
16 | height: '20px',
17 | width: '50%',
18 | position: 'fixed',
19 | display: 'flex',
20 | overflow: 'hidden',
21 | left: '0px',
22 | top: '0px',
23 | fontFamily: 'Roboto Mono For Powerline',
24 | fontSize: '8pt',
25 | lineHeight: '20px',
26 | color: 'rgba(216, 222, 232, 1)'
27 | }
28 |
29 | export const rightSide = {
30 | height: '20px',
31 | width: '50%',
32 | position: 'fixed',
33 | display: 'flex',
34 | overflow: 'hidden',
35 | right: '0px',
36 | top: '0px',
37 | fontFamily: 'Roboto Mono For Powerline',
38 | fontSize: '8pt',
39 | lineHeight: '20px',
40 | color: 'rgba(216, 222, 232, 1)'
41 | }
42 |
--------------------------------------------------------------------------------
/right.jsx:
--------------------------------------------------------------------------------
1 | import DateTime from './lib/DateTime/index.jsx';
2 | import Battery from './lib/Battery/index.jsx';
3 | import Cpu from './lib/Cpu/index.jsx';
4 | import Memory from './lib/Memory/index.jsx';
5 | import Hdd from './lib/Hdd/index.jsx';
6 | import Wifi from './lib/Wifi/index.jsx';
7 | import Error from './lib/Error/index.jsx';
8 | import { rightSide } from './lib/style.jsx';
9 | import parse from './lib/parse.jsx';
10 |
11 | export const refreshFrequency = 15000
12 |
13 | export const command = './powerbar/status-right.sh'
14 |
15 | export const render = ({output}) => {
16 | console.log(`Right bar output: ${output}`);
17 | const data = parse(output);
18 | if (typeof data === 'undefined') {
19 | return (
20 |
21 |
22 |
23 | )
24 | }
25 | return (
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | )
35 | }
36 |
37 | export default null
38 |
--------------------------------------------------------------------------------
/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajdnik/powerbar/ac1031c6eeafc89bf3eb698865d7312a9bef500c/screenshot.png
--------------------------------------------------------------------------------
/status-left.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Check if chunkc exists
4 | if ! [ -x "$(command -v chunkc)" ]; then
5 | echo "{\"error\":\"chunkc binary not found\"}"
6 | exit 1
7 | fi
8 |
9 | CURRENT_DESKTOP=$(chunkc tiling:query -m id)
10 | DESKTOP_ACTIVE=$(chunkc tiling::query -d id)
11 | DESKTOP_START=$(chunkc tiling::query -D $CURRENT_DESKTOP | head -c 1)
12 | DESKTOP_END=$(chunkc tiling::query -D $CURRENT_DESKTOP | tail -c 1)
13 |
14 | echo $(cat <<-EOF
15 | {
16 | "desktop": {
17 | "active": $DESKTOP_ACTIVE,
18 | "start": $DESKTOP_START,
19 | "end": $DESKTOP_END
20 | }
21 | }
22 | EOF
23 | )
24 |
--------------------------------------------------------------------------------
/status-right.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Check if date exists
4 | if ! [ -x "$(command -v date)" ]; then
5 | echo "{\"error\":\"date binary not found\"}"
6 | exit 1
7 | fi
8 |
9 | # Check if pmset exists
10 | if ! [ -x "$(command -v pmset)" ]; then
11 | echo "{\"error\":\"pmset binary not found\"}"
12 | exit 1
13 | fi
14 |
15 | # Check if egrep exists
16 | if ! [ -x "$(command -v egrep)" ]; then
17 | echo "{\"error\":\"egrep binary not found\"}"
18 | exit 1
19 | fi
20 |
21 | # Check if cut exists
22 | if ! [ -x "$(command -v cut)" ]; then
23 | echo "{\"error\":\"cut binary not found\"}"
24 | exit 1
25 | fi
26 |
27 | # Check if memory_pressure exists
28 | if ! [ -x "$(command -v memory_pressure)" ]; then
29 | echo "{\"error\":\"memory_pressure binary not found\"}"
30 | exit 1
31 | fi
32 |
33 | # Check if sysctl exists
34 | if ! [ -x "$(command -v sysctl)" ]; then
35 | echo "{\"error\":\"sysctl binary not found\"}"
36 | exit 1
37 | fi
38 |
39 | # Check if osascript exists
40 | if ! [ -x "$(command -v osascript)" ]; then
41 | echo "{\"error\":\"osascript binary not found\"}"
42 | exit 1
43 | fi
44 |
45 | # Check if df exists
46 | if ! [ -x "$(command -v df)" ]; then
47 | echo "{\"error\":\"df binary not found\"}"
48 | exit 1
49 | fi
50 |
51 | # Check if grep exists
52 | if ! [ -x "$(command -v grep)" ]; then
53 | echo "{\"error\":\"grep binary not found\"}"
54 | exit 1
55 | fi
56 |
57 | # Check if awk exists
58 | if ! [ -x "$(command -v awk)" ]; then
59 | echo "{\"error\":\"awk binary not found\"}"
60 | exit 1
61 | fi
62 |
63 | # Check if networksetup exists
64 | if ! [ -x "$(command -v networksetup)" ]; then
65 | echo "{\"error\":\"networksetup binary not found\"}"
66 | exit 1
67 | fi
68 |
69 | export LC_TIME="en_US.UTF-8"
70 | TIME=$(date +"%H:%M")
71 | DATE=$(date +"%a %d/%m/%Y")
72 |
73 | BATTERY_PERCENTAGE=$(pmset -g batt | egrep '([0-9]+\%).*' -o --colour=auto | cut -f1 -d'%')
74 |
75 | BATTERY_STATUS=$(pmset -g batt | grep "'.*'" | sed "s/'//g" | cut -c 18-19)
76 |
77 | BATTERY_CHARGING=""
78 | if [ "$BATTERY_STATUS" == "Ba" ]; then
79 | BATTERY_CHARGING="false"
80 | elif [ "$BATTERY_STATUS" == "AC" ]; then
81 | BATTERY_CHARGING="true"
82 | fi
83 |
84 | LOAD_AVERAGE=$(sysctl -n vm.loadavg | awk '{print $2}')
85 |
86 | VOLUME=$(osascript -e 'output volume of (get volume settings)')
87 | IS_MUTED=$(osascript -e 'output muted of (get volume settings)')
88 |
89 | HDD_TOTAL_BYTES=$(df | grep -m 1 /disk1 | awk -F" " '{print $2}')
90 | HDD_FREE_BYTES=$(df | grep -m 1 /disk1 | awk -F" " '{print $4}')
91 |
92 | MEMORY_FREE=$(memory_pressure | grep "Pages free" | grep -o -E '[0-9]+')
93 | MEMORY_TOTAL=$(memory_pressure | grep system | awk -F" " '{print $5}' | grep -o -E '[0-9]+')
94 |
95 | WIFI_SSID=$(networksetup -getairportnetwork en0 | cut -c 24-)
96 |
97 | echo $(cat <<-EOF
98 | {
99 | "datetime": {
100 | "time": "$TIME",
101 | "date": "$DATE"
102 | },
103 | "battery": {
104 | "percentage": $BATTERY_PERCENTAGE,
105 | "charging": $BATTERY_CHARGING
106 | },
107 | "cpu": {
108 | "loadAverage": $LOAD_AVERAGE
109 | },
110 | "volume": {
111 | "volume": $VOLUME,
112 | "muted": $IS_MUTED
113 | },
114 | "hdd": {
115 | "freeBytes": $HDD_FREE_BYTES,
116 | "totalBytes": $HDD_TOTAL_BYTES
117 | },
118 | "memory": {
119 | "total": $MEMORY_TOTAL,
120 | "free": $MEMORY_FREE
121 | },
122 | "wifi": {
123 | "ssid": "$WIFI_SSID"
124 | }
125 | }
126 | EOF
127 | )
128 |
--------------------------------------------------------------------------------
/widget.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Powerline Bar",
3 | "description": "Displays a bar at the top of the screen with system stats.",
4 | "author": "Rok Ajdnik",
5 | "email": "r.ajdnik@gmail.com"
6 | }
7 |
--------------------------------------------------------------------------------