Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
ximper-shell-notification-center
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ximper Linux
ximper-shell-notification-center
Commits
c54bf8ba
Unverified
Commit
c54bf8ba
authored
Apr 18, 2022
by
Erik Reider
Committed by
GitHub
Apr 18, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added hide and close latest notification to client (#113)
parent
f400e4a1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
58 additions
and
1 deletion
+58
-1
swaync-client
completions/bash/swaync-client
+2
-0
swaync-client.fish
completions/fish/swaync-client.fish
+2
-0
_swaync-client
completions/zsh/_swaync-client
+3
-1
swaync-client.1.scd
man/swaync-client.1.scd
+6
-0
ccDaemon.vala
src/ccDaemon/ccDaemon.vala
+6
-0
client.vala
src/client.vala
+10
-0
notiDaemon.vala
src/notiDaemon/notiDaemon.vala
+8
-0
notiWindow.vala
src/notiWindow/notiWindow.vala
+21
-0
No files found.
completions/bash/swaync-client
View file @
c54bf8ba
...
@@ -30,6 +30,8 @@ _swaync-client() {
...
@@ -30,6 +30,8 @@ _swaync-client() {
--toggle-dnd
--toggle-dnd
--get-dnd
--get-dnd
--count
--count
--hide-latest
--close-latest
--close-all
--close-all
--skip-wait
--skip-wait
--subscribe
--subscribe
...
...
completions/fish/swaync-client.fish
View file @
c54bf8ba
...
@@ -9,6 +9,8 @@ complete -c swaync-client -s cp -l close-panel --description "Closes the notific
...
@@ -9,6 +9,8 @@ complete -c swaync-client -s cp -l close-panel --description "Closes the notific
complete -c swaync-client -s d -l toggle-dnd --description "Toggle and print the current dnd state" -r
complete -c swaync-client -s d -l toggle-dnd --description "Toggle and print the current dnd state" -r
complete -c swaync-client -s D -l get-dnd --description "Print the current dnd state" -r
complete -c swaync-client -s D -l get-dnd --description "Print the current dnd state" -r
complete -c swaync-client -s c -l count --description "Print the current notificaion count" -r
complete -c swaync-client -s c -l count --description "Print the current notificaion count" -r
complete -c swaync-client -l hide-latest --description "Hides latest notification. Still shown in Control Center" -r
complete -c swaync-client -l close-latest --description "Closes latest notification" -r
complete -c swaync-client -s C -l close-all --description "Closes all notifications" -r
complete -c swaync-client -s C -l close-all --description "Closes all notifications" -r
complete -c swaync-client -s sw -l skip-wait --description "Doesn't wait when swaync hasn't been started" -r
complete -c swaync-client -s sw -l skip-wait --description "Doesn't wait when swaync hasn't been started" -r
complete -c swaync-client -s s -l subscribe --description "Subscribe to notificaion add and close events" -r
complete -c swaync-client -s s -l subscribe --description "Subscribe to notificaion add and close events" -r
...
...
completions/zsh/_swaync-client
View file @
c54bf8ba
...
@@ -11,7 +11,9 @@ _arguments -s \
...
@@ -11,7 +11,9 @@ _arguments -s \
'(-d --toggle-dnd)'{-d,--toggle-dnd}'[Toggle and print the current dnd state]' \
'(-d --toggle-dnd)'{-d,--toggle-dnd}'[Toggle and print the current dnd state]' \
'(-D --get-dnd)'{-D,--get-dnd}'[Print the current dnd state]' \
'(-D --get-dnd)'{-D,--get-dnd}'[Print the current dnd state]' \
'(-c --count)'{-c,--count}'[Print the current notificaion count]' \
'(-c --count)'{-c,--count}'[Print the current notificaion count]' \
'(-C --close-all)'{-C,--close-all}'[Closes all notifications]' \
'(--hide-latest)'{--hide-latest}'[Closes all notifications]' \
'(--close-latest)'{--close-latest}'[Hides latest notification. Still shown in Control Center]' \
'(-C --close-all)'{-C,--close-all}'[Closes latest notification]' \
'(-sw --skip-wait)'{-sw,--skip-wait}"[Doesn't wait when swaync hasn't been started]" \
'(-sw --skip-wait)'{-sw,--skip-wait}"[Doesn't wait when swaync hasn't been started]" \
'(-s --subscribe)'{-s,--subscribe}'[Subscribe to notificaion add and close events]' \
'(-s --subscribe)'{-s,--subscribe}'[Subscribe to notificaion add and close events]' \
'(-swb --subscribe-waybar)'{-swb,--subscribe-waybar}'[Subscribe to notificaion add and close events with waybar support. Read README for example]' \
'(-swb --subscribe-waybar)'{-swb,--subscribe-waybar}'[Subscribe to notificaion add and close events with waybar support. Read README for example]' \
man/swaync-client.1.scd
View file @
c54bf8ba
...
@@ -40,6 +40,12 @@ swaync-client - Client executable
...
@@ -40,6 +40,12 @@ swaync-client - Client executable
*-c, --count*
*-c, --count*
Print the current notificaion count
Print the current notificaion count
*--hide-latest*
Hides latest notification. Still shown in Control Center
*--close-latest*
Closes latest notification
*-C, --close-all*
*-C, --close-all*
Closes all notifications
Closes all notifications
...
...
src/ccDaemon/ccDaemon.vala
View file @
c54bf8ba
...
@@ -70,6 +70,12 @@ namespace SwayNotificationCenter {
...
@@ -70,6 +70,12 @@ namespace SwayNotificationCenter {
return
controlCenter
.
get_visibility
();
return
controlCenter
.
get_visibility
();
}
}
/** Closes latest popup notification */
public
void
hide_latest_notifications
(
bool
close
)
throws
DBusError
,
IOError
{
notiDaemon
.
hide_latest_notification
(
close
);
}
/** Closes all popup and controlcenter notifications */
/** Closes all popup and controlcenter notifications */
public
void
close_all_notifications
()
throws
DBusError
,
IOError
{
public
void
close_all_notifications
()
throws
DBusError
,
IOError
{
notiDaemon
.
close_all_notifications
();
notiDaemon
.
close_all_notifications
();
...
...
src/client.vala
View file @
c54bf8ba
...
@@ -5,6 +5,8 @@ interface CcDaemon : GLib.Object {
...
@@ -5,6 +5,8 @@ interface CcDaemon : GLib.Object {
public
abstract
void
reload_config
()
throws
Error
;
public
abstract
void
reload_config
()
throws
Error
;
public
abstract
void
hide_latest_notifications
(
bool
close
)
throws
DBusError
,
IOError
;
public
abstract
void
close_all_notifications
()
throws
DBusError
,
IOError
;
public
abstract
void
close_all_notifications
()
throws
DBusError
,
IOError
;
public
abstract
uint
notification_count
()
throws
DBusError
,
IOError
;
public
abstract
uint
notification_count
()
throws
DBusError
,
IOError
;
...
@@ -39,6 +41,8 @@ private void print_help (string[] args) {
...
@@ -39,6 +41,8 @@ private void print_help (string[] args) {
print
(
@"\t -d, \t --toggle-dnd \t\t Toggle and print the current dnd state\n"
);
print
(
@"\t -d, \t --toggle-dnd \t\t Toggle and print the current dnd state\n"
);
print
(
@"\t -D, \t --get-dnd \t\t Print the current dnd state\n"
);
print
(
@"\t -D, \t --get-dnd \t\t Print the current dnd state\n"
);
print
(
@"\t -c, \t --count \t\t Print the current notificaion count\n"
);
print
(
@"\t -c, \t --count \t\t Print the current notificaion count\n"
);
print
(
@"\t \t --hide-latest \t\t Hides latest notification. Still shown in Control Center\n"
);
print
(
@"\t \t --close-latest \t Closes latest notification\n"
);
print
(
@"\t -C, \t --close-all \t\t Closes all notifications\n"
);
print
(
@"\t -C, \t --close-all \t\t Closes all notifications\n"
);
print
(
@"\t -sw, \t --skip-wait \t\t Doesn't wait when swaync hasn't been started\n"
);
print
(
@"\t -sw, \t --skip-wait \t\t Doesn't wait when swaync hasn't been started\n"
);
print
(
@"\t -s, \t --subscribe \t\t Subscribe to notificaion add and close events\n"
);
print
(
@"\t -s, \t --subscribe \t\t Subscribe to notificaion add and close events\n"
);
...
@@ -118,6 +122,12 @@ public int command_line (string[] args) {
...
@@ -118,6 +122,12 @@ public int command_line (string[] args) {
case
"-c"
:
case
"-c"
:
print
(
cc_daemon
.
notification_count
().
to_string
());
print
(
cc_daemon
.
notification_count
().
to_string
());
break
;
break
;
case
"--close-latest"
:
cc_daemon
.
hide_latest_notifications
(
true
);
break
;
case
"--hide-latest"
:
cc_daemon
.
hide_latest_notifications
(
false
);
break
;
case
"--close-all"
:
case
"--close-all"
:
case
"-C"
:
case
"-C"
:
cc_daemon
.
close_all_notifications
();
cc_daemon
.
close_all_notifications
();
...
...
src/notiDaemon/notiDaemon.vala
View file @
c54bf8ba
...
@@ -78,6 +78,14 @@ namespace SwayNotificationCenter {
...
@@ -78,6 +78,14 @@ namespace SwayNotificationCenter {
ccDaemon
.
controlCenter
.
close_all_notifications
();
ccDaemon
.
controlCenter
.
close_all_notifications
();
}
}
/** Closes latest popup notification */
public
void
hide_latest_notification
(
bool
close
)
throws
DBusError
,
IOError
{
uint32
?
id
=
notiWindow
.
get_latest_notification
();
if
(
id
==
null
)
return
;
manually_close_notification
(
id
,
!
close
);
}
/*
/*
* D-Bus Specification
* D-Bus Specification
* https://specifications.freedesktop.org/notification-spec/latest/ar01s09.html
* https://specifications.freedesktop.org/notification-spec/latest/ar01s09.html
...
...
src/notiWindow/notiWindow.vala
View file @
c54bf8ba
...
@@ -27,6 +27,11 @@ namespace SwayNotificationCenter {
...
@@ -27,6 +27,11 @@ namespace SwayNotificationCenter {
public
void
close_notification
(
uint32
id
)
{
public
void
close_notification
(
uint32
id
)
{
notificationWindow
.
close_notification
(
id
);
notificationWindow
.
close_notification
(
id
);
}
}
public
uint32
?
get_latest_notification
()
{
if
(!
notis
.
get_realized
()
||
notis
.
closed
)
return
null
;
return
notificationWindow
.
get_latest_notification
();
}
}
}
[
GtkTemplate
(
ui
=
"/org/erikreider/sway-notification-center/notiWindow/notiWindow.ui"
)]
[
GtkTemplate
(
ui
=
"/org/erikreider/sway-notification-center/notiWindow/notiWindow.ui"
)]
...
@@ -169,5 +174,21 @@ namespace SwayNotificationCenter {
...
@@ -169,5 +174,21 @@ namespace SwayNotificationCenter {
}
}
}
}
}
}
public
uint32
?
get_latest_notification
()
{
List
<
weak
Gtk
.
Widget
>
children
=
box
.
get_children
();
if
(
children
.
is_empty
())
return
null
;
Gtk
.
Widget
?
child
=
null
;
if
(
list_reverse
)
{
child
=
children
.
last
().
data
;
}
else
{
child
=
children
.
first
().
data
;
}
if
(
child
==
null
||
!(
child
is
Notification
))
return
null
;
Notification
noti
=
(
Notification
)
child
;
return
noti
.
param
.
applied_id
;
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment