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
5d443edb
Unverified
Commit
5d443edb
authored
Jul 10, 2025
by
Zach DeCook
Committed by
GitHub
Jul 10, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hints: parse sound-name and sound-file (#477)
* hints: parse sound-name and sound-file * Added docs --------- Co-authored-by:
Erik Reider
<
35975961+ErikReider@users.noreply.github.com
>
parent
3cf08d6b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
10 deletions
+62
-10
swaync.5.scd
man/swaync.5.scd
+20
-10
configModel.vala
src/configModel/configModel.vala
+20
-0
configSchema.json
src/configSchema.json
+8
-0
notiModel.vala
src/notiModel/notiModel.vala
+14
-0
No files found.
man/swaync.5.scd
View file @
5d443edb
...
@@ -751,6 +751,14 @@ config file to be able to detect config errors
...
@@ -751,6 +751,14 @@ config file to be able to detect config errors
type: string ++
type: string ++
optional: true ++
optional: true ++
description: Which category the notification belongs to. Uses Regex.++
description: Which category the notification belongs to. Uses Regex.++
*sound-file*++
type: string ++
optional: true ++
description: Which sound file the notification requested. Uses Regex.++
*sound-name*++
type: string ++
optional: true ++
description: Which sound name the notification requested. Uses Regex.++
*run-on*++
*run-on*++
type: string ++
type: string ++
optional: true ++
optional: true ++
...
@@ -781,15 +789,17 @@ config file to be able to detect config errors
...
@@ -781,15 +789,17 @@ config file to be able to detect config errors
You can also use these environment variables in your script:
You can also use these environment variables in your script:
```
```
SWAYNC_BODY="Notification body content"
$SWAYNC_BODY="Notification body content"
SWAYNC_DESKTOP_ENTRY="Desktop entry"
$SWAYNC_DESKTOP_ENTRY="Desktop entry"
SWAYNC_URGENCY="Notification urgency"
$SWAYNC_URGENCY="Notification urgency"
SWAYNC_TIME="Notification time"
$SWAYNC_TIME="Notification time"
SWAYNC_APP_NAME="Notification app name"
$SWAYNC_APP_NAME="Notification app name"
SWAYNC_CATEGORY="SwayNC notification category"
$SWAYNC_CATEGORY="SwayNC notification category"
SWAYNC_REPLACES_ID="ID of notification to replace"
$SWAYNC_REPLACES_ID="ID of notification to replace"
SWAYNC_ID="SwayNC notification ID"
$SWAYNC_ID="SwayNC notification ID"
SWAYNC_SUMMARY="Notification summary"
$SWAYNC_SUMMARY="Notification summary"
SWAYNC_HINT_[NAME]="Value of the hint [NAME]"
$SWAYNC_HINT_[NAME]="Value of the hint [NAME]"
$SWAYNC_SOUND_NAME="The name of the requested sound"
$SWAYNC_SOUND_FILE="The file path of the requested sound"
```
```
#END scripting
#END scripting
src/configModel/configModel.vala
View file @
5d443edb
...
@@ -87,6 +87,8 @@ namespace SwayNotificationCenter {
...
@@ -87,6 +87,8 @@ namespace SwayNotificationCenter {
public
string
?
body
{
get
;
set
;
default
=
null
;
}
public
string
?
body
{
get
;
set
;
default
=
null
;
}
public
string
?
urgency
{
get
;
set
;
default
=
null
;
}
public
string
?
urgency
{
get
;
set
;
default
=
null
;
}
public
string
?
category
{
get
;
set
;
default
=
null
;
}
public
string
?
category
{
get
;
set
;
default
=
null
;
}
public
string
?
sound_name
{
get
;
set
;
default
=
null
;
}
public
string
?
sound_file
{
get
;
set
;
default
=
null
;
}
private
const
RegexCompileFlags
REGEX_COMPILE_OPTIONS
=
private
const
RegexCompileFlags
REGEX_COMPILE_OPTIONS
=
RegexCompileFlags
.
MULTILINE
;
RegexCompileFlags
.
MULTILINE
;
...
@@ -141,6 +143,22 @@ namespace SwayNotificationCenter {
...
@@ -141,6 +143,22 @@ namespace SwayNotificationCenter {
REGEX_MATCH_FLAGS
);
REGEX_MATCH_FLAGS
);
if
(!
result
)
return
false
;
if
(!
result
)
return
false
;
}
}
if
(
sound_file
!=
null
)
{
if
(
param
.
sound_file
==
null
)
return
false
;
bool
result
=
Regex
.
match_simple
(
sound_file
,
param
.
sound_file
,
REGEX_COMPILE_OPTIONS
,
REGEX_MATCH_FLAGS
);
if
(!
result
)
return
false
;
}
if
(
sound_name
!=
null
)
{
if
(
param
.
sound_name
==
null
)
return
false
;
bool
result
=
Regex
.
match_simple
(
sound_name
,
param
.
sound_name
,
REGEX_COMPILE_OPTIONS
,
REGEX_MATCH_FLAGS
);
if
(!
result
)
return
false
;
}
return
true
;
return
true
;
}
}
...
@@ -256,6 +274,8 @@ namespace SwayNotificationCenter {
...
@@ -256,6 +274,8 @@ namespace SwayNotificationCenter {
spawn_env
+=
"SWAYNC_BODY=%s"
.
printf
(
param
.
body
);
spawn_env
+=
"SWAYNC_BODY=%s"
.
printf
(
param
.
body
);
spawn_env
+=
"SWAYNC_URGENCY=%s"
.
printf
(
param
.
urgency
.
to_string
());
spawn_env
+=
"SWAYNC_URGENCY=%s"
.
printf
(
param
.
urgency
.
to_string
());
spawn_env
+=
"SWAYNC_CATEGORY=%s"
.
printf
(
param
.
category
);
spawn_env
+=
"SWAYNC_CATEGORY=%s"
.
printf
(
param
.
category
);
spawn_env
+=
"SWAYNC_SOUND_NAME=%s"
.
printf
(
param
.
sound_name
);
spawn_env
+=
"SWAYNC_SOUND_FILE=%s"
.
printf
(
param
.
sound_file
);
spawn_env
+=
"SWAYNC_ID=%s"
.
printf
(
param
.
applied_id
.
to_string
());
spawn_env
+=
"SWAYNC_ID=%s"
.
printf
(
param
.
applied_id
.
to_string
());
spawn_env
+=
"SWAYNC_REPLACES_ID=%s"
.
printf
(
param
.
replaces_id
.
to_string
());
spawn_env
+=
"SWAYNC_REPLACES_ID=%s"
.
printf
(
param
.
replaces_id
.
to_string
());
spawn_env
+=
"SWAYNC_TIME=%s"
.
printf
(
param
.
time
.
to_string
());
spawn_env
+=
"SWAYNC_TIME=%s"
.
printf
(
param
.
time
.
to_string
());
...
...
src/configSchema.json
View file @
5d443edb
...
@@ -239,6 +239,14 @@
...
@@ -239,6 +239,14 @@
"type"
:
"string"
,
"type"
:
"string"
,
"description"
:
"Which category the notification belongs to. Uses Regex."
"description"
:
"Which category the notification belongs to. Uses Regex."
},
},
"sound-file"
:
{
"type"
:
"string"
,
"description"
:
"Which sound file the notification requested. Uses Regex."
},
"sound-name"
:
{
"type"
:
"string"
,
"description"
:
"Which sound name the notification requested. Uses Regex."
},
"run-on"
:
{
"run-on"
:
{
"type"
:
"string"
,
"type"
:
"string"
,
"description"
:
"Whether to run the script on an action being activated, or when the notification is received."
,
"description"
:
"Whether to run the script on an action being activated, or when the notification is received."
,
...
...
src/notiModel/notiModel.vala
View file @
5d443edb
...
@@ -82,6 +82,8 @@ namespace SwayNotificationCenter {
...
@@ -82,6 +82,8 @@ namespace SwayNotificationCenter {
public
string
image_path
{
get
;
set
;
}
public
string
image_path
{
get
;
set
;
}
public
string
desktop_entry
{
get
;
set
;
}
public
string
desktop_entry
{
get
;
set
;
}
public
string
category
{
get
;
set
;
}
public
string
category
{
get
;
set
;
}
public
string
sound_name
{
get
;
set
;
}
public
string
sound_file
{
get
;
set
;
}
public
bool
resident
{
get
;
set
;
}
public
bool
resident
{
get
;
set
;
}
public
bool
transient
{
get
;
set
;
}
public
bool
transient
{
get
;
set
;
}
public
UrgencyLevels
urgency
{
get
;
set
;
}
public
UrgencyLevels
urgency
{
get
;
set
;
}
...
@@ -250,6 +252,16 @@ namespace SwayNotificationCenter {
...
@@ -250,6 +252,16 @@ namespace SwayNotificationCenter {
category
=
hint_value
.
get_string
();
category
=
hint_value
.
get_string
();
}
}
break
;
break
;
case
"sound-name"
:
if
(
hint_value
.
is_of_type
(
VariantType
.
STRING
))
{
sound_name
=
hint_value
.
get_string
();
}
break
;
case
"sound-file"
:
if
(
hint_value
.
is_of_type
(
VariantType
.
STRING
))
{
sound_file
=
hint_value
.
get_string
();
}
break
;
case
"resident"
:
case
"resident"
:
if
(
hint_value
.
is_of_type
(
VariantType
.
BOOLEAN
))
{
if
(
hint_value
.
is_of_type
(
VariantType
.
BOOLEAN
))
{
resident
=
hint_value
.
get_boolean
();
resident
=
hint_value
.
get_boolean
();
...
@@ -336,6 +348,8 @@ namespace SwayNotificationCenter {
...
@@ -336,6 +348,8 @@ namespace SwayNotificationCenter {
params
.
set
(
"image_path"
,
image_path
);
params
.
set
(
"image_path"
,
image_path
);
params
.
set
(
"desktop_entry"
,
desktop_entry
);
params
.
set
(
"desktop_entry"
,
desktop_entry
);
params
.
set
(
"category"
,
category
);
params
.
set
(
"category"
,
category
);
params
.
set
(
"sound_name"
,
sound_name
);
params
.
set
(
"sound_file"
,
sound_file
);
params
.
set
(
"resident"
,
resident
.
to_string
());
params
.
set
(
"resident"
,
resident
.
to_string
());
params
.
set
(
"urgency"
,
urgency
.
to_string
());
params
.
set
(
"urgency"
,
urgency
.
to_string
());
string
[]
_actions
=
{};
string
[]
_actions
=
{};
...
...
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