Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
oh-my-zsh
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
e6a1db21
Unverified
Commit
e6a1db21
authored
Nov 20, 2023
by
bretello
Committed by
GitHub
Nov 20, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(bgnotify): add support to wayland (#12045)
parent
22f9a8d3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
10 deletions
+18
-10
bgnotify.plugin.zsh
plugins/bgnotify/bgnotify.plugin.zsh
+18
-10
No files found.
plugins/bgnotify/bgnotify.plugin.zsh
View file @
e6a1db21
...
@@ -59,11 +59,14 @@ function bgnotify_formatted {
...
@@ -59,11 +59,14 @@ function bgnotify_formatted {
fi
fi
}
}
# for macOS, output is "app ID, window ID" (com.googlecode.iterm2, 116)
function
bgnotify_appid
{
function
bgnotify_appid
{
if
((
${
+commands[osascript]
}
))
;
then
if
((
${
+commands[osascript]
}
))
;
then
# output is "app ID, window ID" (com.googlecode.iterm2, 116)
osascript
-e
'tell application (path to frontmost application as text) to get the {id, id of front window}'
2>/dev/null
osascript
-e
'tell application (path to frontmost application as text) to get the {id, id of front window}'
2>/dev/null
elif
((
${
+commands[xprop]
}
))
;
then
elif
[[
-n
$WAYLAND_DISPLAY
&&
${
+commands[swaymsg]
}
&&
${
+commands[jq]
}
]]
;
then
# wayland+sway
# output is "app_id, container id" (Alacritty, 1694)
swaymsg
-t
get_tree | jq
'.. | select(.type?) | select(.focused==true) | {app_id, id} | join(", ")'
elif
[[
-n
$DISPLAY
&&
${
+commands[xprop]
}
]]
;
then
xprop
-root
_NET_ACTIVE_WINDOW 2>/dev/null |
cut
-d
' '
-f5
xprop
-root
_NET_ACTIVE_WINDOW 2>/dev/null |
cut
-d
' '
-f5
else
else
echo
$EPOCHSECONDS
echo
$EPOCHSECONDS
...
@@ -71,7 +74,8 @@ function bgnotify_appid {
...
@@ -71,7 +74,8 @@ function bgnotify_appid {
}
}
function
bgnotify
{
function
bgnotify
{
# $1: title, $2: message
local
title
=
"
$1
"
local
message
=
"
$2
"
if
((
${
+commands[terminal-notifier]
}
))
;
then
# macOS
if
((
${
+commands[terminal-notifier]
}
))
;
then
# macOS
local
term_id
=
"
${
bgnotify_termid
%%,*
}
"
# remove window id
local
term_id
=
"
${
bgnotify_termid
%%,*
}
"
# remove window id
if
[[
-z
"
$term_id
"
]]
;
then
if
[[
-z
"
$term_id
"
]]
;
then
...
@@ -82,18 +86,22 @@ function bgnotify {
...
@@ -82,18 +86,22 @@ function bgnotify {
fi
fi
if
[[
-z
"
$term_id
"
]]
;
then
if
[[
-z
"
$term_id
"
]]
;
then
terminal-notifier
-message
"
$
2
"
-title
"
$1
"
&>/dev/null
terminal-notifier
-message
"
$
message
"
-title
"
$title
"
&>/dev/null
else
else
terminal-notifier
-message
"
$
2
"
-title
"
$1
"
-activate
"
$term_id
"
-sender
"
$term_id
"
&>/dev/null
terminal-notifier
-message
"
$
message
"
-title
"
$title
"
-activate
"
$term_id
"
-sender
"
$term_id
"
&>/dev/null
fi
fi
elif
((
${
+commands[growlnotify]
}
))
;
then
# macOS growl
elif
((
${
+commands[growlnotify]
}
))
;
then
# macOS growl
growlnotify
-m
"
$1
"
"
$2
"
growlnotify
-m
"
$title
"
"
$message
"
elif
((
${
+commands[notify-send]
}
))
;
then
# GNOME
elif
((
${
+commands[notify-send]
}
))
;
then
notify-send
"
$1
"
"
$2
"
if
[[
-n
$ALACRITTY_WINDOW_ID
]]
;
then
notify-send
-i
Alacritty
"
$title
"
"
$message
"
else
notify-send
"
$title
"
"
$message
"
fi
elif
((
${
+commands[kdialog]
}
))
;
then
# KDE
elif
((
${
+commands[kdialog]
}
))
;
then
# KDE
kdialog
--title
"
$
1
"
--passivepopup
"
$2
"
5
kdialog
--title
"
$
title
"
--passivepopup
"
$message
"
5
elif
((
${
+commands[notifu]
}
))
;
then
# cygwin
elif
((
${
+commands[notifu]
}
))
;
then
# cygwin
notifu /m
"
$
2
"
/p
"
$1
"
notifu /m
"
$
message
"
/p
"
$title
"
fi
fi
}
}
...
...
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