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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
{-# LANGUAGE DuplicateRecordFields #-}
-- |
-- Module : Foobar.Models.Config
-- Description: Data stored in the configuration file.
module Foobar.Models.Config
( -- * Top-Level Configuration
Config(..)
, GeneralConfig(..)
, PanelConfig(..)
, LauncherConfig(..)
, ControlCenterConfig(..)
, NotificationConfig(..)
, -- * Common Data Structures
ScreenEdge(..)
, Orientation(..)
, Action(..)
, -- * Panel Configuration
PanelItem(..)
, PanelItemConfig(..)
, PanelIconConfig(..)
, PanelClockConfig(..)
, PanelWorkspacesConfig(..)
, PanelStatusConfig(..)
, PanelStatusItem(..)
, PanelItemPosition(..)
, -- * Control Center Configuration
ControlCenterRow(..)
, ControlCenterAlignment(..)
) where
import Data.Text
-- | Main configuration structure containing the configuration state for all components of the application.
data Config
= Config { general :: !GeneralConfig -- ^ The general application configuration.
, panel :: !PanelConfig -- ^ The panel configuration.
, launcher :: !LauncherConfig -- ^ The launcher configuration.
, controlCenter :: !ControlCenterConfig -- ^ The control center configuration.
, notifications :: !NotificationConfig -- ^ The notification configuration.
}
deriving (Show, Eq)
-- | General application settings not specific to a single component.
data GeneralConfig
= GeneralConfig { stylesheet :: !Text -- ^ URI to the CSS stylesheet to use -- this may be a resource that's bundled
-- with Foobar or a "file:" URI.
}
deriving (Show, Eq)
-- | Configuration for the panel shown at the edge of a screen.
data PanelConfig
= PanelConfig { position :: !ScreenEdge -- ^ The screen edge which the panel should appear on.
, margin :: !Int -- ^ Offset of the panel from all screen edges.
, padding :: !Int -- ^ Inset of the panel along its orientation.
, size :: !Int -- ^ Size of the panel (depending on the orientation, this can be either
-- the width or the height).
, spacing :: !Int -- ^ Spacing between panel items.
, multiMonitor :: !Bool -- ^ Flag to enable the panel on all monitors.
, items :: ![PanelItem] -- ^ Items configured to be displayed in the panel.
}
deriving (Show, Eq)
-- | Configuration for the application launcher.
data LauncherConfig
= LauncherConfig { width :: !Int -- ^ Horizontal size of the launcher.
, position :: !Int -- ^ Offset from the top of the screen.
, maxHeight :: !Int -- ^ Maximum allowed height for the launcher before scrolling is enabled.
}
deriving (Show, Eq)
-- | Configuration for the control center.
data ControlCenterConfig
= ControlCenterConfig { width :: !Int -- ^ Horizontal size of the control center.
, height :: !Int -- ^ Vertical size of the control center.
, position :: !ScreenEdge -- ^ The screen edge which the control center should
-- be attached to.
, offset :: !Int -- ^ Offset from the attached screen edge.
, padding :: !Int -- ^ Spacing between the edges of the control center
-- and its items.
, spacing :: !Int -- ^ Spacing between the items.
, orientation :: !Orientation -- ^ The orientation used to arrange the controls and
-- notifications sections.
, alignment :: !ControlCenterAlignment -- ^ Alignment along the attached screen edge.
, rows :: ![ControlCenterRow] -- ^ Ordered list of rows to display in the controls
-- section.
}
deriving (Show, Eq)
-- | Configuration for notifications and the notification area shown in the corner of the screen.
data NotificationConfig
= NotificationConfig { width :: !Int -- ^ Horizontal size of notifications in the notification area.
, minHeight :: !Int -- ^ Minimum height for each notification.
, spacing :: !Int -- ^ Spacing between notifications and from the screen edges.
, closeButtonInset :: !Int -- ^ Inset of the close button within the notification (may be
-- negative).
, timeFormat :: !Text -- ^ The time format string as used by g_date_time_format.
}
deriving (Show, Eq)
-- | An edge of the screen.
data ScreenEdge
= ScreenEdgeLeft
| ScreenEdgeRight
| ScreenEdgeTop
| ScreenEdgeBottom
deriving (Show, Enum, Bounded, Eq)
-- | An orientation value.
data Orientation
= OrientationHorizontal
| OrientationVertical
deriving (Show, Enum, Bounded, Eq)
-- | The action to be executed when a panel item is clicked.
data Action
= ActionNone
| ActionLauncher
| ActionControlCenter
deriving (Show, Enum, Bounded, Eq)
-- | Configuration for an item in the panel, including a general item configuration and an item-specific configuration.
data PanelItem
= PanelItemIcon !PanelItemConfig !PanelIconConfig
| PanelItemClock !PanelItemConfig !PanelClockConfig
| PanelItemWorkspaces !PanelItemConfig !PanelWorkspacesConfig
| PanelItemStatus !PanelItemConfig !PanelStatusConfig
deriving (Show, Eq)
-- | General configuration for items in the panel.
data PanelItemConfig
= PanelItemConfig { name :: !Text -- ^ Name of the panel item (this is derived from the section
-- name, which has the form "panel.[name]").
, position :: !PanelItemPosition -- ^ Position where the item should be placed item within the
-- panel.
}
deriving (Show, Eq)
-- | Configuration for icon items in the panel.
data PanelIconConfig
= PanelIconConfig { iconName :: !Text -- ^ The GTK icon to use for the item.
, action :: !Action -- ^ Action invoked when the user clicks the item.
}
deriving (Show, Eq)
-- | Configuration for clock items in the panel.
data PanelClockConfig
= PanelClockConfig { format :: !Text -- ^ The time format string as used by g_date_time_format.
, action :: !Action -- ^ Action invoked when the user clicks the item.
}
deriving (Show, Eq)
-- | Configuration for workspace items in the panel.
data PanelWorkspacesConfig
= PanelWorkspacesConfig { buttonSize :: !Int -- ^ Size of each workspace button.
, spacing :: !Int -- ^ Inner spacing between the workspace buttons.
}
deriving (Show, Eq)
-- | Configuration for status items in the panel.
data PanelStatusConfig
= PanelStatusConfig { items :: ![PanelStatusItem] -- ^ Ordered list of status items to display in the item.
, spacing :: !Int -- ^ Inner spacing between the status items.
, showLabels :: !Bool -- ^ Indicates whether text labels should be shown next
-- to the status icons.
, enableScrolling :: !Bool -- ^ If set to true, some settings like volume or
-- brightness can be adjusted by scrolling while
-- hovering over the status item.
, action :: !Action -- ^ Action invoked when the user clicks the item.
}
deriving (Show, Eq)
-- | An item to display in a status panel item.
data PanelStatusItem
= PanelStatusItemNetwork
| PanelStatusItemBluetooth
| PanelStatusItemBattery
| PanelStatusItemBrightness
| PanelStatusItemAudio
| PanelStatusItemNotifications
deriving (Show, Enum, Bounded, Eq)
-- | Position of a panel item in the panel.
data PanelItemPosition
= PanelItemPositionStart
| PanelItemPositionCenter
| PanelItemPositionEnd
deriving (Show, Enum, Bounded, Eq)
-- | A row in the "controls" section of the control center.
data ControlCenterRow
= ControlCenterRowConnectivity
| ControlCenterRowAudioOutput
| ControlCenterRowAudioInput
| ControlCenterRowBrightness
deriving (Show, Enum, Bounded, Eq)
-- | Alignment of the control center along its screen edge.
data ControlCenterAlignment
= ControlCenterAlignmentStart
| ControlCenterAlignmentCenter
| ControlCenterAlignmentEnd
| ControlCenterAlignmentFill
deriving (Show, Enum, Bounded, Eq)
|