summaryrefslogtreecommitdiff
path: root/.config/quickshell/Modules/Bar.qml
blob: 8ddd1441d4c160704d3f131a057386e6020b902f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import Quickshell
import Quickshell.Hyprland
import QtQuick
import QtQuick.Layouts
import qs.Services

Variants {
	model: Quickshell.screens;

	delegate: Component {
		PanelWindow {
			id: root

			required property var modelData
			screen: modelData

			property string fontFamily: "FiraCode Nerd Font"
			property int fontSize: 14

			anchors {
				top: true
				left: true
				right: true
			}

			implicitHeight: 36 + 8

			color: "transparent"

			Rectangle {
				anchors {
					fill: parent
					topMargin: 8
					leftMargin: 8
					rightMargin: 8
				}
				implicitHeight: 36
				color: "transparent"

				Rectangle {
					anchors.verticalCenter: parent.verticalCenter
					anchors.left: parent.left
					implicitWidth: workspaces.implicitWidth + 12*2
					height: parent.height
					color: Flexoki.bg
					radius: 18

					Row {
						id: workspaces
						anchors.centerIn: parent
						height: 20
						spacing: 6

						Repeater {
							model: 10

							delegate: Rectangle {
								property HyprlandWorkspace ws: {
									Hyprland.workspaces.values.find(ws => ws.id === index + 1) || null
								}
								property bool focused: {
									ws && ws.monitor.name === root.screen.name && ws.focused
								}
								property bool occupied: {
									ws && ws.monitor.name === root.screen.name && ws.toplevels.values.length > 0
								}

								width: 20
								height: 20
								radius: 10

								color: {
									if (!focused) return "transparent"
									return occupied ? Flexoki.re : Flexoki.ui3
								}

								border.width: 2
								border.color: occupied ? Flexoki.re : Flexoki.ui3
							}
						}
					}
				}

				Music {}

				Rectangle {
					anchors.verticalCenter: parent.verticalCenter
					anchors.right: parent.right
					implicitWidth: status.implicitWidth + 12*2
					height: parent.height
					color: Flexoki.bg
					radius: 18

					RowLayout {
						id: status
						anchors.centerIn: parent
						implicitHeight: parent.implicitHeight
						spacing: 24

						Text {
							text: {
								//     
								var icon
								if (Volume.volume == 0) {
									icon = " "
								} else if (Volume.volume < 50) {
									icon = " "
								} else {
									icon = "  "
								}
								return icon + Volume.volume + "%"
							}
							color: Flexoki.re
							font { family: root.fontFamily; pixelSize: root.fontSize }
						}

						Text {
							text: Wifi.ssid == "" ? "󰖪 " : "󰖩 " + Wifi.ssid
							color: Flexoki.or
							font { family: root.fontFamily; pixelSize: root.fontSize }
						}

						Text {
							text: " " + Brightness.brightness + "%"
							color: Flexoki.ye
							font { family: root.fontFamily; pixelSize: root.fontSize }
						}

						Text {
							text: {
								var icon
								var i = Math.floor((Battery.capacity - 1) / 10)
								switch (Battery.status) {
									case "Full":
										icon = "󰂄"
										break
									case "Discharging":
										icon = ["󰁺","󰁻","󰁼","󰁽","󰁾","󰁿","󰂀","󰂁","󰂂","󰁹"][i]
										break
									case "Charging":
										icon = ["󰢜","󰂆","󰂇","󰂈","󰢝","󰂉","󰢞","󰂊","󰂋","󰂅"][i]
										break
								}
							  return icon + " " + Battery.capacity + "%"
							}
							color: Flexoki.gr
							font { family: root.fontFamily; pixelSize: root.fontSize }
						}

						Text {
							text: " " + Qt.formatDateTime(Time.time, "MMM d hh:mm:ss")
							color: Flexoki.bl
							font { family: root.fontFamily; pixelSize: root.fontSize }
						}

						Text {
							text: "󰐥"
							color: Flexoki.pu
							font { family: root.fontFamily; pixelSize: root.fontSize * 1.5 }
						}
					}
				}
			}
		}
	}
}