Commit graph

176 commits

Author SHA1 Message Date
scorpion-26
96485f408e
Check nvidia gpu features on init
When a required feature is not supported, gBar would crash inside the
query functions without a way to manually bypass NvidiaGPU. Now
NvidiaGPU checks whether all features are supported and disables the
module if any throw an error.

Fixes https://github.com/scorpion-26/gBar/issues/52
2023-09-21 19:30:42 +08:00
Sebastian Zerbe
471bc6e719
Make the partition monitored by disk sensor configurable (#50)
Allows to stat partitions other than the root partition

---------

Co-authored-by: Sebastian Zerbe <zerbe@phil.hhu.de>
2023-09-08 16:34:17 +02:00
scorpion-26
b215dfb145 Don't crash for empty string config
Fixes https://github.com/scorpion-26/gBar/issues/49
2023-09-07 18:49:25 +02:00
scorpion-26
0812c3680f Add option for sensor tooltips instead of sliders
Partially implements https://github.com/scorpion-26/gBar/issues/48
2023-09-07 17:24:41 +02:00
scorpion-26
d811b14767 Move WorkspaceSymbol parsing to other map configs 2023-09-02 00:15:04 +02:00
scorpion-26
df46c58244 Add config for number of workspaces
Adds NumWorkspaces config, https://github.com/scorpion-26/gBar/issues/45

The WorkspaceSymbols syntax was also upgraded to use maps, since the -n
was hardcoded to query for numbers from 1-9, which is now no longer
correct.
The old syntax for WorkspaceSymbols still works, but only for ws 1-9
2023-09-02 00:05:08 +02:00
scorpion-26
5c2ac6fa08 Generalize map config parsing
Maps like the one used by SNIIconSize and SNIPaddingTop are now
generalized, without requiring the awkward std::pair<_,_> buf and hasntFoundProperty helpers
2023-09-01 23:42:45 +02:00
scorpion-26
71278a3529 Use Hyprland IPC by default.
Hyprland will remove ext-workspace-unstable-v1 support in
v0.30.0 and Workspaces with UseHyprlandIPC: false will no longer work.
2023-09-01 17:55:22 +02:00
scorpion-26
6f9da7f7c9 Add PID to logfile
This avoid log corruption when multiple gBar instances are open at the same, as the logfile was the same
2023-09-01 03:19:07 +02:00
scorpion-26
9ecba84be5 Fix compilation without USE_LOGFILE 2023-09-01 03:19:07 +02:00
Sebastian Zerbe
2cc0ec0a66
Add config for time widget locale (#44)
This makes the `DateTimeStyle` string respect the current locale or
whatever valid locale is set via configuration option `DateTimeLocale`.

---------

Co-authored-by: Sebastian Zerbe <zerbe@phil.hhu.de>
2023-09-01 02:14:13 +02:00
scorpion-26
aee06ab49d SNI: Properly unsubscribe from item reload signal
I think not unsubscribing is the root cause of the mysterious calling of
ItemPropertyChanged from random names/object paths.
2023-08-24 00:09:05 +02:00
scorpion-26
383f25dbe1 SNI: Fix pixmap
g_variant_iter_n_children apparently returns 1 instead of 3 (array =
child, but I don't know).
I inverted the statement, because for empty property, it hasn't any
children.
2023-08-23 23:18:50 +02:00
scorpion-26
15ed9bfc66 SNI: Disallow watcher replacement
Should help against losing the name constantly, if another bar is
opened.
2023-08-23 15:29:13 +02:00
scorpion-26
ff22c08f01 Disable Nvidia on nvml init failure
https://github.com/scorpion-26/gBar/issues/39
2023-08-23 15:08:33 +02:00
scorpion-26
a15bb1e17e SNI: Gracefully handle empty IconPixmap
An empty pixmap caused extreme flickering.
https://github.com/scorpion-26/gBar/issues/38
2023-08-22 22:30:38 +02:00
scorpion-26
b246e9fad4 Log failure code for Nvidia polling 2023-08-22 22:10:25 +02:00
scorpion-26
ec478dec9c SNI: Fix crash with ToolTip of type String
TeamViewer exposes ToolTip as String (which is not compliant to the spec).
This caused gBar to crash, since we assume, that the tooltip variant is
always a container (struct), which glibc doesn't like.

We now fallback to g_variant_get_string if it is not according to spec

Fixes https://github.com/scorpion-26/gBar/issues/37
2023-08-22 15:17:18 +02:00
scorpion-26
1a25dbdec6 Add config for numbers instead of sliders
Currently doesn't affect the audio flyin.
Implementation for https://github.com/scorpion-26/gBar/issues/35
2023-08-21 18:22:29 +02:00
scorpion-26
ed71da316e Only use workspace manager when not using IPC
Since we always init Wayland, we would previously have both
zext_workspace_manager_v1 and Hyprland IPC which is terrible
2023-08-08 17:52:35 +02:00
scorpion-26
ef925ef174 Retry hypr socket operations.
Don't immediately ASSERT when the hyprland socket operations fail.
Instead, retry them a few times and then return gracefully instead of
crashing.

https://github.com/scorpion-26/gBar/issues/32
2023-08-08 16:32:14 +02:00
scorpion-26
3bac707bf5 Fix compiler warnings 2023-07-28 19:11:13 +02:00
scorpion-26
4a52bb744a SNI: Flush before querying item properties
Some apps have a tendency to deadlock after registration (notably
KeePassXC). Now we flush before querying the item properties, so any
pending answer should have left the bus, hopefully avoiding the deadlock
2023-07-28 18:58:00 +02:00
scorpion-26
a7862a4242 SNI: Remove callback for erased items
Should fix DBusNameVanished spam as found in https://github.com/scorpion-26/gBar/issues/29
2023-07-28 18:56:51 +02:00
scorpion-26
ef8652f046 Don't ignore WS 9
Fixes https://github.com/scorpion-26/gBar/issues/28
2023-07-28 00:19:55 +02:00
scorpion-26
09ec1bfab6 SNI: Sort items
Reloading/adding new items causes jumps in the item order. Sorting
should stabilize the order
2023-07-26 14:04:36 +02:00
scorpion-26
884d3f1324 SNI: Only reload a given senderName once
Fix for: https://github.com/scorpion-26/gBar/issues/26
2023-07-26 14:03:52 +02:00
scorpion-26
39cf17c30f SNI: Use our object path for ItemPropertyChanged
ItemPropertyChanged is called multiple times per actual icon change.
senderName is the same, objectPath is the same, but our registered name
for the callback differs.
We can't use the provided name for item searching, since that *can*
differ from the one we registered with (Looking at you, Discord. Discord
registers with org.kde.StatusNotifierItem-*, but calls back with :*.*)
Since then the object path will sometimes be wrong for the name, we just
use the one from the icon we originally registered with. This causes
multiple icons to reload though

Potential fix for https://github.com/scorpion-26/gBar/issues/26
2023-07-26 13:37:11 +02:00
scorpion-26
fe7b02b10c SNI: Honor XDG_DATA_DIRS as icon directory
Also don't crash in Utils::FindFileWithName when directory doesn't exist

Potential fix for https://github.com/scorpion-26/gBar/issues/25
2023-07-25 01:47:17 +02:00
scorpion-26
c12bef29d2 BluetoothDevices: Honor Location 2023-07-23 17:56:24 +02:00
scorpion-26
abd3774c7d Fix SNI angle for top bar 2023-07-21 01:29:25 +02:00
scorpion-26
42a0710551 Fix SNIPaddingTop for sideways bar 2023-07-21 01:24:25 +02:00
scorpion-26
f78758c4ee SNI: Allow bar rotation
Texture was also rewritten, so it doesn't need the SNIPaddingTop hack as much
anymore
2023-07-21 01:08:38 +02:00
scorpion-26
4cbada766e Fix margins for the audio flyin 2023-07-19 01:49:31 +02:00
scorpion-26
138aa9318b Add a "Location" config.
Partially implements https://github.com/scorpion-26/gBar/issues/20
2023-07-19 01:13:57 +02:00
scorpion-26
b0c13801f6 Add GetHeight for Window 2023-07-19 01:13:57 +02:00
scorpion-26
4a9ac0ff5b Add angle property to widgets
This allows us to rotate various widgets.
2023-07-19 01:13:57 +02:00
scorpion-26
e4be65a348 Fix stupid comparison bug
Previously, dim.width < dim.height would never return true, since it is
already checked by dim.height >= dim.width.
2023-07-19 01:13:57 +02:00
scorpion-26
ba366729fe Add margin to Transform 2023-07-19 01:13:57 +02:00
scorpion-26
342ff57ba7 Add char to config 2023-07-19 01:13:57 +02:00
scorpion-26
43dd0777a8 Remove tmp files on SIGINT
This allows the use of Ctrl-C without leaving stale files behind which
need to be deleted
2023-07-14 19:46:27 +02:00
scorpion-26
fcf4d75ea0 Only allow one instance of the bluetooth widget
This works analogous to the audio flyin
Fixes https://github.com/scorpion-26/gBar/issues/21
2023-07-14 19:37:21 +02:00
scorpion-26
18f3e123ed SNI: Allow IconPath to be empty
Fixes network-manager-applet
2023-07-04 12:21:19 +02:00
scorpion-26
7567465454 Refactor Wayland code out 2023-06-15 13:25:19 +02:00
scorpion-26
f2dc5a806c Log workspace dispatching 2023-06-15 00:23:02 +02:00
scorpion-26
1f56e6ba15 Greatly reduce clipping when CenterTime is set
Giving each main box element (left, center, right) caused the window to
resize and clip out of the monitor when
e.g. the right part was larger than the 1/3 of the window.

Now we have a size for the center widget and try to manually center a box with
that size by setting the left widget's size accordingly. This allows the
right widget to have more room, so it can go right up to the center widget without issues.
2023-06-10 23:50:09 +02:00
scorpion-26
a34ffd8334 Add Window::GetWidth() 2023-06-10 23:49:13 +02:00
scorpion-26
6815d8e017 Initialise GTK early 2023-06-10 23:49:13 +02:00
scorpion-26
2a66f1d64c Format BluetoothDevices.cpp 2023-06-10 23:49:13 +02:00
faulTTY
9aa310fd07
Make datetime format configurable (#18)
Co-authored-by: Sciu-Crak <sciu-crak@crak-tower.ironyworld>
Co-authored-by: FaulTTY <faultty@localhost>
2023-05-26 08:57:02 +02:00
scorpion-26
77924b5097 Add confirmation to power PowerWidget
For it to actually do something, we need to click twice within 2s. The
clicked button also changes color for visual indication on what was
pressed

See https://github.com/scorpion-26/gBar/issues/17
2023-05-23 22:40:03 +02:00
scorpion-26
c51fadbc79 Consider capacity for battery sensor 2023-05-10 13:08:17 +02:00
scorpion-26
80ade2b06e Fix inconsistent whitespace 2023-05-05 23:13:35 +02:00
scorpion-26
259083a904 Fix off by one error in default update script 2023-05-05 12:47:40 +02:00
scorpion-26
1c6cd3bd2b Update more icons
Seems like I missed some in the first round
2023-05-04 23:26:30 +02:00
scorpion-26
e9c9d3abb1 SNI: Add Icon positioning config options 2023-05-04 16:14:18 +02:00
scorpion-26
79e78826e0 SNI: Only add to clientsToQuery once 2023-05-04 15:04:06 +02:00
scorpion-26
31e070a3da SNI: Add config 2023-05-04 13:57:50 +02:00
scorpion-26
b7a92e50d9 SNI: Add context menu
Since it uses a 13 year old library, it is broken. The popup size is
hard-fixed at 200x200, with looks really ugly with non-transparent
background.
2023-05-04 13:57:50 +02:00
scorpion-26
40115befdd SNI: Improve logging 2023-05-04 13:57:50 +02:00
scorpion-26
25912c7e35 SNI: Add tooltip 2023-05-04 13:57:50 +02:00
scorpion-26
6bd5a450b1 SNI: Implement changing properties 2023-05-04 13:57:50 +02:00
scorpion-26
b50ecb0f6c SNI: Fix freeze when connecting to Qt SNI apps
Qt waits until the callback to RegisterItem is done. Thus, we can't
query the item and need to defer it
2023-05-04 13:57:50 +02:00
scorpion-26
a02bce9b91 SNI: Remove items on bus name vanish 2023-05-04 13:57:50 +02:00
scorpion-26
d4ffac395b SNI: Proper alignment for the icons 2023-05-04 13:57:50 +02:00
scorpion-26
1241d7c87c SNI: Initial proof of concept
Implements a rough outline of the SNI (StatusNotifierItem) d-bus
protocol for tray icons.

Note: This is currently *very* WIP

Full implementation will close https://github.com/scorpion-26/gBar/issues/5
2023-05-04 13:57:50 +02:00
scorpion-26
05e7635c80 Fix CI 2023-05-04 13:53:15 +02:00
scorpion-26
ecc52a81a5 Update all deprecated Material Design icons
All Material Design icons should now use their new code points.
This unbreaks gBar with Nerd Fonts v3.0.0
2023-05-03 23:21:21 +02:00
scorpion-26
be47a62880 Properly escape the default package command
/bin/sh would remove any newlines without ""
2023-05-03 23:20:29 +02:00
scorpion-26
c101449ba6 Allow Package widget to be anywhere 2023-05-03 19:02:26 +02:00
scorpion-26
aa08206e4b Fix default packages command 2023-05-03 19:00:39 +02:00
scorpion-26
299b497748 Add package widget
Polling is done via user script and a pipe. Since it is only run every
5 minutes by default, this should be fine

Partially implements https://github.com/scorpion-26/gBar/issues/14
2023-05-03 18:40:45 +02:00
scorpion-26
3517fa5de8 Widget: Fix delayed "SetText" 2023-03-25 21:15:35 +01:00
scorpion-26
507cf222fb Audio: Add Min/Max volume
AudioMinVolume/AudioMaxVolume remap the range 0%-100% to
AudioMinVolume-AudioMaxVolume

https://github.com/scorpion-26/gBar/issues/13
2023-03-21 22:09:56 +01:00
scorpion-26
d6610f2594 Config: Support double values 2023-03-21 22:08:59 +01:00
scorpion-26
2fa23a2d54 Audio: Log SetVolume*** events 2023-03-21 17:49:30 +01:00
scorpion-26
c2c38dcae7 Workspaces: Add config option for Hyprland IPC
ext_workspace wasn't as perfect of a replacement as I thought it was...
2023-03-11 00:24:50 +01:00
scorpion-26
78107f16fa Always activate first x monitors
The workspace of a second monitor would not be activated, so
lastActiveWorkspace of that would be nullptr. This would also happen for
the first monitor (First and second swapped)
after Hyprland boot.

Now the WS of the first monitor is fully activated by default and every
other monitor has at least lastActiveWorkspace set (Assumes, that WS
with MonID + 1 is on that monitor).
2023-03-05 20:30:43 +01:00
scorpion-26
f2bc8e00c8 Fix late update SetText 2023-03-04 22:07:25 +01:00
scorpion-26
ad92b7c12a Workspaces: Implement ext_workspace protocol
Even though it isn't faster than Hyprland IPC, it still is more flexible
and more future proof.

Closes https://github.com/scorpion-26/gBar/issues/8
2023-03-03 20:46:37 +01:00
scorpion-26
660e690195 Cache SetText
Apparently, gtk_button_set_label is very expensive to do. Now it is
only called when necessary.

This is the culprit for the mysterious high CPU usage and not the Hyprland
IPC as said in https://github.com/scorpion-26/gBar/issues/7 and https://github.com/scorpion-26/gBar/issues/8.
2023-03-03 17:02:59 +01:00
scorpion-26
d8eae96e50 Widgets: Avoid redraws by reducing gtk calls 2023-02-24 22:34:30 +01:00
scorpion-26
e1cf8f2475 PulseAudio: Optimizations
Instead of always polling audio volume, gBar subscribes to events,
causing the update to only happen on demand.
Plus we can block poll updates when there is audio change through gBar,
which results in a much smoother slider.

This change reduces (at least on my end) CPU times from 4-6% per core
to 2-4% per core.
2023-02-24 14:34:11 +01:00
scorpion-26
38116636ae Workspaces: Optimize GetStatus
We previously called DispatchIPC 18 times every 100ms
Now it is only 2 times per 100ms
2023-02-24 13:28:09 +01:00
scorpion-26
35a6670868 Fix issue with audio slider
Due to the fact, that we needed to manually propagate hover events from
the slider, two hover events are sent when coming from the side of the
slider. This we need to await BOTH close events until we can call the
leave function.
2023-02-22 17:23:47 +01:00
scorpion-26
3c8c93d774 Add Microphone support
This commit adds a new widget for the bar: A Microphone widget. It is
disabled by default and can can
be enabled with AudioInput: true.
Implements a flyin as well.

https://github.com/scorpion-26/gBar/issues/5 for the ping
2023-02-22 17:13:14 +01:00
scorpion-26
f5adfebfe9 PulseAudio: Improve iterator loop
We now store sthe pa_operation and check if they were done'd, cancelled or still running.
2023-02-21 22:47:30 +01:00
scorpion-26
16933c24ff Add log file
Plus refactoring out the logging.
2023-02-21 22:20:02 +01:00
scorpion-26
0e4b877654 PulseAudio: Make FlushLoop more robust
When PA_CONTEXT_READY is called multiple times, PulseAudio::FlusLoop() would get stuck to to integer underflow.
Now there are multiple things preventing that.

Possible fix for https://github.com/scorpion-26/gBar/issues/7
2023-02-21 21:19:22 +01:00
scorpion-26
60b9355e88 System: Don't crash when dbus isn't installed. 2023-02-21 11:39:39 +01:00
scorpion-26
a12cb9af5d AudioSlider: Add option for scroll speed
There seems to be a floating point error somewhere though, since
sometimes it goes up by AudioScrollSpeed - 1 instead of
AudioScrollSpeed...

For the ping https://github.com/scorpion-26/gBar/issues/5
2023-02-20 23:04:37 +01:00
scorpion-26
906a1259c3 Add Net sanity checking
This disables network if the tx_bytes file is not found on Init()
2023-02-12 20:45:05 +01:00
scorpion-26
35b7065879 Implement Workspace scroll
Scrolling the workspace widgets now scroll through the workspaces. The
exact behaviour is governed by
'WorkspaceScrollOnMonitor'(either 'm[+/-]1' or 'e[+/-]1'). The direction
can be inverted with 'WorkspaceScrollInvert'.

For the ping: https://github.com/scorpion-26/gBar/issues/5
2023-02-12 14:57:32 +01:00
scorpion-26
c29d752cb8 EventBox: Fix fault callback parameter. 2023-02-12 14:56:59 +01:00
scorpion-26
b4dfaa62b1 EventBox: Add scroll event 2023-02-12 14:28:46 +01:00
scorpion-26
3134c82245 Add a Network Widget
This new widget visualizes the up and download speeds for a
specified network adapter. It is on by default, but can be disabled.
2023-02-10 17:20:26 +01:00
scorpion-26
c901b59ab4 Add missing files
I accidently forgot to add them when commiting 883037029f
2023-02-10 17:14:57 +01:00
scorpion-26
f916b00de7 Fix bogus comment removal
The previous substr call would remove everything but the comment, which
    is not what we want.
2023-02-10 17:10:35 +01:00
scorpion-26
883037029f Refactor CSS out of Window.cpp
It has nothing to do with *windows* and obviously doesn't belong there.
Plus I don't know whether I may need static access to the provider.
2023-02-09 16:16:18 +01:00
scorpion-26
9e48830dc8 Abstract out quad calculation from Sensor
The calculation of the bounding quad is now in CairoArea, as it is quite
useful
2023-02-09 16:16:18 +01:00