Skip to content

Commit

Permalink
Merge branch 'main' into mpris_blacklist
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikReider authored Jul 10, 2024
2 parents fb09aaf + 653058b commit 4c408db
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/PKGBUILD-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Install packages
run: |
pacman-key --init
pacman -Sy
pacman -Syu --noconfirm
- name: Add builduser
run: |
Expand Down
39 changes: 23 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,19 @@ These widgets can be customized, added, removed and even reordered

## Install

### Alpine Linux

```zsh
apk add swaync
````

### Arch

The package is available on the AUR:
```zsh
sudo pacman -S swaync
```

- [swaync](https://aur.archlinux.org/packages/swaync/)
- [swaync-git](https://aur.archlinux.org/packages/swaync-git/)
Alternatively, [swaync-git](https://aur.archlinux.org/packages/swaync-git/) is available on the AUR.

### Fedora

Expand All @@ -127,7 +134,7 @@ An **unofficial** ebuild is available in [GURU](https://github.com/gentoo/guru)

```zsh
eselect repository enable guru
emaint sync -r guru
emaint sync --repo guru
emerge --ask gui-apps/swaync
```

Expand All @@ -141,7 +148,7 @@ sudo zypper install SwayNotificationCenter

Lunar and later:

```
```zsh
sudo apt install sway-notification-center
```

Expand All @@ -150,14 +157,14 @@ sudo apt install sway-notification-center

Bookworm and later:

```
```zsh
sudo apt install sway-notification-center
```

### Guix

The simplest way is to install it to user's profile:
```
```zsh
guix install swaynotificationcenter
```
Expand Down Expand Up @@ -197,7 +204,7 @@ But we recommend to use [Guix Home](https://guix.gnu.org/manual/devel/en/html_no
- `libnotify`
```zsh
meson build --prefix=/usr
meson setup build --prefix=/usr
ninja -C build
meson install -C build
```
Expand Down Expand Up @@ -250,7 +257,7 @@ To reload css after changes
- Shift+D: Toggle Do Not Disturb
- Buttons 1-9: Execute alternative actions
- Left click button / actions: Activate notification action
- Right click notification: Close notification
- Middle/Right click notification: Close notification
## Configuring
Expand Down Expand Up @@ -278,7 +285,7 @@ The active toggle button also gains the css-class ".toggle:checked"
`config.json` example:
```json
```jsonc
{
"buttons-grid": { // also works with actions in menubar widget
"actions": [
Expand Down Expand Up @@ -329,7 +336,7 @@ Notification information can be printed into a terminal by running

Config properties:

```json
```jsonc
{
"scripts": {
"example-script": {
Expand All @@ -341,13 +348,13 @@ Config properties:
"category": "Notification category Regex"
}
}
other non scripting properties...
// other non scripting properties...
}
```

`config.json` example:

```json
```jsonc
{
"scripts": {
// This script will only run when Spotify sends a notification containing
Expand All @@ -359,7 +366,7 @@ Config properties:
"body": "Rick Astley - Whenever You Need Somebody"
}
}
other non scripting properties...
// other non scripting properties...
}
```

Expand Down Expand Up @@ -431,9 +438,9 @@ Waybar css file

Alternatively, the number of notifications can be shown by adding `{}` anywhere in the `format` field in the Waybar config

```json
```jsonc
"custom/notification": {
"format": "{} {icon}",
...
// ...
},
```
6 changes: 3 additions & 3 deletions build-scripts/PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# vim: ft=PKGBUILD
# vim: ft=sh
# Maintainer: Erik Reider <erik.reider@protonmail.com>
pkgname=swaync
pkgver=0.10.0
pkgver=0.10.1
pkgrel=1
pkgdesc="A simple notification daemon with a GTK panel for checking previous notifications like other DEs"
_pkgfoldername=SwayNotificationCenter
Expand All @@ -17,7 +17,7 @@ conflicts=("swaync" "swaync-client")
provides=("swaync" "swaync-client" "notification-daemon")
makedepends=("vala>=0.56" meson git scdoc sassc)
source=("${_pkgfoldername}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz")
sha256sums=('5eb6fb0cfdaa9eb518565e032a7d9f716b3edfd99602697344eac00e404d4c8d')
sha256sums=('5586d8a679dde5e530cb8b6f0c86abdd0d5e41362fc1c4e56e2211edea0f7a13')

build() {
arch-meson "${_pkgfoldername}-${pkgver}" build -Dscripting=true
Expand Down
4 changes: 2 additions & 2 deletions build-scripts/PKGBUILD-git
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# vim: ft=PKGBUILD
# vim: ft=sh
# Maintainer: Erik Reider <erik.reider@protonmail.com>
pkgname=swaync-git
_pkgname=swaync
pkgver=r510.8613cdc
pkgver=r517.4275fa3
pkgrel=1
pkgdesc="A simple notification daemon with a GTK panel for checking previous notifications like other DEs"
url="https://github.com/ErikReider/SwayNotificationCenter"
Expand Down
2 changes: 1 addition & 1 deletion build-scripts/swaync.rpkg.spec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%global alt_pkg_name swaync

Name: {{{ git_dir_name }}}
Version: 0.10.0
Version: 0.10.1
Release: 1%{?dist}
Summary: Notification daemon with GTK GUI
Provides: desktop-notification-daemon
Expand Down
2 changes: 1 addition & 1 deletion man/swaync.1.scd
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ swaync - A simple notification daemon with a GTK gui for notifications and the c

*Left click button / actions*: Activate notification action

*Right click notification*: Close notification
*Middle/Right click notification*: Close notification

# CONFIGURATION

Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project('sway-notificaton-center', ['c', 'vala'],
version: '0.10.0',
version: '0.10.1',
meson_version: '>= 0.59.0',
default_options: [ 'warning_level=2' ],
)
Expand Down
4 changes: 2 additions & 2 deletions src/configSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@
"default": 12
},
"blur": {
"type": "bool",
"type": "boolean",
"description": "Appy the artwork as the MPRIS background and blur it",
"default": true
}
Expand Down Expand Up @@ -446,7 +446,7 @@
"default": ""
},
"active": {
"type": "bool",
"type": "boolean",
"description": "Wether the toggle button is active as default or not",
"default": false
}
Expand Down
2 changes: 1 addition & 1 deletion src/controlCenter/widgets/backlight/backlight.vala
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace SwayNotificationCenter.Widgets {
slider.set_draw_value (false);
slider.set_round_digits (0);
slider.value_changed.connect (() => {
this.client.set_brightness ((float) slider.get_value ());
this.client.set_brightness.begin ((float) slider.get_value ());
slider.tooltip_text = ((int) slider.get_value ()).to_string ();
});

Expand Down
8 changes: 4 additions & 4 deletions src/controlCenter/widgets/backlight/backlightUtil.vala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace SwayNotificationCenter.Widgets {

[DBus (name = "org.freedesktop.login1.Session")]
interface Login1 : Object {
public abstract void set_brightness (string subsystem,
public abstract async void set_brightness (string subsystem,
string name, uint32 brightness) throws GLib.Error;
}

Expand Down Expand Up @@ -77,14 +77,14 @@ namespace SwayNotificationCenter.Widgets {
if (monitor != null) monitor.cancel ();
}

public void set_brightness (float percent) {
public async void set_brightness (float percent) {
this.close ();
try {
if (subsystem == "backlight") {
int actual = calc_actual (percent);
login1.set_brightness (subsystem, device, actual);
login1.set_brightness.begin (subsystem, device, actual);
} else {
login1.set_brightness (subsystem, device, (uint32) percent);
login1.set_brightness.begin (subsystem, device, (uint32) percent);
}
} catch (Error e) {
error ("Error %s\n", e.message);
Expand Down
23 changes: 20 additions & 3 deletions src/controlCenter/widgets/mpris/mpris_player.vala
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ namespace SwayNotificationCenter.Widgets.Mpris {
update_buttons (source.media_player.metadata);
});
});
album_art.set_pixel_size (mpris_config.image_size);
}

public void before_destroy () {
Expand Down Expand Up @@ -379,12 +380,28 @@ namespace SwayNotificationCenter.Widgets.Mpris {
if (desktop_entry is DesktopAppInfo) {
icon = desktop_entry.get_icon ();
}
Gtk.IconInfo ? icon_info = null;
if (icon != null) {
album_art.set_from_gicon (icon, mpris_config.image_size);
album_art.set_from_gicon (icon, Gtk.IconSize.INVALID);
icon_info = Gtk.IconTheme.get_default ().lookup_by_gicon (icon,
mpris_config.image_size,
Gtk.IconLookupFlags.USE_BUILTIN);
} else {
// Default icon
album_art.set_from_icon_name ("audio-x-generic-symbolic",
mpris_config.image_size);
string icon_name = "audio-x-generic-symbolic";
album_art.set_from_icon_name (icon_name,
Gtk.IconSize.INVALID);
icon_info = Gtk.IconTheme.get_default ().lookup_icon (icon_name,
mpris_config.image_size,
Gtk.IconLookupFlags.USE_BUILTIN);
}

if (icon_info != null) {
try {
this.album_art_pixbuf = icon_info.load_icon ();
} catch (Error e) {
warning ("Could not load icon: %s", e.message);
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/controlCenter/widgets/shared/toggleButton.vala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace SwayNotificationCenter.Widgets {

private string command;
private string update_command;
private ulong handler_id;

public ToggleButton (string label, string command, string update_command, bool active) {
this.command = command;
Expand All @@ -13,7 +14,7 @@ namespace SwayNotificationCenter.Widgets {
this.active = true;
}

this.toggled.connect (on_toggle);
this.handler_id = this.toggled.connect (on_toggle);
}

private async void on_toggle () {
Expand All @@ -31,11 +32,13 @@ namespace SwayNotificationCenter.Widgets {
// remove trailing whitespaces
Regex regex = new Regex ("\\s+$");
string res = regex.replace (msg, msg.length, 0, "");
GLib.SignalHandler.block (this, this.handler_id);
if (res.up () == "TRUE") {
this.active = true;
} else {
this.active = false;
}
GLib.SignalHandler.unblock (this, this.handler_id);
} catch (RegexError e) {
stderr.printf ("RegexError: %s\n", e.message);
}
Expand Down
15 changes: 10 additions & 5 deletions src/fadedViewport/fadedViewport.vala
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ private class FadedViewportChild : Gtk.Container {
base.set_can_focus (true);
base.set_redraw_on_allocate (false);

this.y_padding = (int) (y_padding * 0.5);
// Half due to the fade basically stopping at 50% of the height
this.y_padding = y_padding / 2;
this._child = null;

this.show ();
Expand Down Expand Up @@ -116,10 +117,15 @@ private class FadedViewportChild : Gtk.Container {
uint border_width = this.get_border_width ();
if (this._child != null && this._child.get_visible ()) {
child_allocation.x = allocation.x + (int) border_width;
child_allocation.y = allocation.y + y_padding + (int) border_width;
child_allocation.y = allocation.y + (int) border_width;
Gtk.Align align_y = _child.get_valign ();
if (align_y == Gtk.Align.END) {
child_allocation.y -= y_padding;
} else {
child_allocation.y += y_padding;
}
child_allocation.width = allocation.width - 2 * (int) border_width;
child_allocation.height = allocation.height + y_padding * 2
- 2 * (int) border_width;
child_allocation.height = allocation.height - 2 * (int) border_width;
this._child.size_allocate (child_allocation);
if (this.get_realized ()) {
this._child.show ();
Expand Down Expand Up @@ -147,7 +153,6 @@ private class FadedViewportChild : Gtk.Container {
minimum_height += y_padding * 2;
natural_height += y_padding * 2;
}

}

public override bool draw (Cairo.Context cr) {
Expand Down
13 changes: 9 additions & 4 deletions src/notification/notification.vala
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,15 @@ namespace SwayNotificationCenter {
///

this.button_press_event.connect ((event) => {
if (event.button != Gdk.BUTTON_SECONDARY) return false;
// Right click
this.close_notification ();
return true;
// Close notification on middle and right button click
switch (event.button) {
case Gdk.BUTTON_MIDDLE:
case Gdk.BUTTON_SECONDARY:
this.close_notification ();
return true;
default:
return false;
}
});

// Adds CSS :hover selector to EventBox
Expand Down

0 comments on commit 4c408db

Please sign in to comment.