Skip to content

Commit

Permalink
Merge branch 'main' of github.com:ErikReider/SwayNotificationCenter i…
Browse files Browse the repository at this point in the history
…nto mpris_app_blur
  • Loading branch information
abmantis committed Mar 27, 2024
2 parents 993a69f + be1533a commit 06ad441
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 67 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
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,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 +141,7 @@ sudo zypper install SwayNotificationCenter

Lunar and later:

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

Expand All @@ -150,14 +150,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 +197,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 @@ -278,7 +278,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 +329,7 @@ Notification information can be printed into a terminal by running

Config properties:

```json
```jsonc
{
"scripts": {
"example-script": {
Expand All @@ -341,13 +341,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 +359,7 @@ Config properties:
"body": "Rick Astley - Whenever You Need Somebody"
}
}
other non scripting properties...
// other non scripting properties...
}
```

Expand Down Expand Up @@ -431,9 +431,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 <[email protected]>
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 <[email protected]>
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 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
82 changes: 41 additions & 41 deletions src/controlCenter/widgets/mpris/mpris_player.vala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace SwayNotificationCenter.Widgets.Mpris {
private unowned Config mpris_config;

public MprisPlayer (MprisSource source, Config mpris_config) {
Object (source: source);
Object (source : source);
this.mpris_config = mpris_config;

source.properties_changed.connect (properties_changed);
Expand All @@ -63,17 +63,17 @@ namespace SwayNotificationCenter.Widgets.Mpris {
// Repeat
button_repeat.clicked.connect (() => {
switch (source.media_player.loop_status) {
case "None":
source.media_player.loop_status = "Playlist";
break;
case "Playlist":
source.media_player.loop_status = "Track";
break;
case "Track":
source.media_player.loop_status = "None";
break;
default:
return;
case "None" :
source.media_player.loop_status = "Playlist";
break;
case "Playlist" :
source.media_player.loop_status = "Track";
break;
case "Track":
source.media_player.loop_status = "None";
break;
default:
return;
}
// Wait until dbus value has updated
button_repeat.sensitive = false;
Expand All @@ -96,7 +96,7 @@ namespace SwayNotificationCenter.Widgets.Mpris {
update_buttons (source.media_player.metadata);
});
});
album_art.set_pixel_size(mpris_config.image_size);
album_art.set_pixel_size (mpris_config.image_size);
}

public void before_destroy () {
Expand Down Expand Up @@ -127,8 +127,8 @@ namespace SwayNotificationCenter.Widgets.Mpris {
- margin.left - margin.right
- border.left - border.right;
int height = get_allocated_height ()
- margin.top - margin.bottom
- border.top - border.bottom;
- margin.top - margin.bottom
- border.top - border.bottom;

cr.save ();
cr.new_sub_path ();
Expand Down Expand Up @@ -180,7 +180,7 @@ namespace SwayNotificationCenter.Widgets.Mpris {
var metadata = source.media_player.metadata;
foreach (string key in changed.get_keys ()) {
switch (key) {
case "DesktopEntry":
case "DesktopEntry" :
update_desktop_entry ();
break;
case "PlaybackStatus":
Expand Down Expand Up @@ -268,9 +268,9 @@ namespace SwayNotificationCenter.Widgets.Mpris {
string ? name = null;
if (desktop_entry is DesktopAppInfo) {
name = desktop_entry.get_display_name ();
if (name == "") name = desktop_entry.get_name ();
if (name == "")name = desktop_entry.get_name ();
}
if (name == null) name = "Media Player";
if (name == null)name = "Media Player";
title.set_text (name);
}
}
Expand All @@ -288,7 +288,7 @@ namespace SwayNotificationCenter.Widgets.Mpris {
// Try to get either "artist" or "albumArtist"
const string[] TYPES = { "xesam:artist", "xesam:albumArtist" };
foreach (unowned string type in TYPES) {
if (artist != null && artist.length > 0) break;
if (artist != null && artist.length > 0)break;
if (type in metadata
&& metadata[type].get_type_string () == "as") {
VariantIter iter = new VariantIter (metadata[type]);
Expand Down Expand Up @@ -316,7 +316,7 @@ namespace SwayNotificationCenter.Widgets.Mpris {
private async void update_album_art (HashTable<string, Variant> metadata) {
if ("mpris:artUrl" in metadata) {
string url = metadata["mpris:artUrl"].get_string ();
if (url == prev_art_url) return;
if (url == prev_art_url)return;
prev_art_url = url;

int scale = get_style_context ().get_scale ();
Expand Down Expand Up @@ -382,31 +382,31 @@ namespace SwayNotificationCenter.Widgets.Mpris {
}
Gtk.IconInfo ? icon_info = null;
if (icon != null) {
album_art.set_from_gicon (icon, Gtk.IconSize.DIALOG);
icon_info = Gtk.IconTheme.get_default().lookup_by_gicon(icon,
mpris_config.image_size,
Gtk.IconLookupFlags.USE_BUILTIN);
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
string icon_name = "audio-x-generic-symbolic";
album_art.set_from_icon_name (icon_name,
Gtk.IconSize.DIALOG);
icon_info = Gtk.IconTheme.get_default().lookup_icon (icon_name,
mpris_config.image_size,
Gtk.IconLookupFlags.USE_BUILTIN);
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();
this.album_art_pixbuf = icon_info.load_icon ();
} catch (Error e) {
warning ("Could not load icon: %s", e.message);
}
}
}

private void update_button_shuffle (HashTable<string, Variant> metadata) {
if (!(button_shuffle is Gtk.Widget)) return;
if (!(button_shuffle is Gtk.Widget))return;

if (source.media_player.can_control) {
// Shuffle check
Expand All @@ -426,25 +426,25 @@ namespace SwayNotificationCenter.Widgets.Mpris {
}

private void update_button_prev (HashTable<string, Variant> metadata) {
if (!(button_prev is Gtk.Widget)) return;
if (!(button_prev is Gtk.Widget))return;

button_prev.set_sensitive (source.media_player.can_go_previous
&& source.media_player.can_control);
}

private void update_button_play_pause (HashTable<string, Variant> metadata) {
if (!(button_play_pause is Gtk.Widget)) return;
if (!(button_play_pause is Gtk.Widget))return;

string icon_name;
bool check;
switch (source.media_player.playback_status) {
case "Playing":
case "Playing" :
icon_name = ICON_PAUSE;
check = source.media_player.can_pause;
break;
case "Paused":
case "Stopped":
default:
case "Paused" :
case "Stopped" :
default :
icon_name = ICON_PLAY;
check = source.media_player.can_play;
break;
Expand All @@ -454,14 +454,14 @@ namespace SwayNotificationCenter.Widgets.Mpris {
}

private void update_button_forward (HashTable<string, Variant> metadata) {
if (!(button_next is Gtk.Widget)) return;
if (!(button_next is Gtk.Widget))return;

button_next.set_sensitive (source.media_player.can_go_next
&& source.media_player.can_control);
}

private void update_button_repeat (HashTable<string, Variant> metadata) {
if (!(button_repeat is Gtk.Widget)) return;
if (!(button_repeat is Gtk.Widget))return;

if (source.media_player.can_control) {
// Repeat check
Expand All @@ -474,8 +474,8 @@ namespace SwayNotificationCenter.Widgets.Mpris {
double opacity = 1.0;
bool remove_flat_css_class = true;
switch (repeat.get_string ()) {
default:
case "None":
default :
case "None" :
icon_name = ICON_REPEAT;
opacity = UNSELECTED_OPACITY;
remove_flat_css_class = false;
Expand All @@ -488,7 +488,7 @@ namespace SwayNotificationCenter.Widgets.Mpris {
break;
}
unowned Gtk.StyleContext ctx = button_repeat.get_style_context ();
if (remove_flat_css_class) ctx.remove_class ("flat");
if (remove_flat_css_class)ctx.remove_class ("flat");
else ctx.add_class ("flat");
button_repeat.get_child ().opacity = opacity;
button_repeat.sensitive = true;
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
Loading

0 comments on commit 06ad441

Please sign in to comment.