forked from chjj/compton
-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dbus server accepts parsing blur strength and added dbus example
- Loading branch information
Showing
4 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/sh | ||
|
||
if [ "$#" -ne 1 ]; then | ||
echo "Illegal number of parameters: blur strength is required" | ||
fi | ||
|
||
strength="$@" | ||
|
||
if [ -z "$SED" ]; then | ||
SED="sed" | ||
command -v gsed > /dev/null && SED="gsed" | ||
fi | ||
|
||
# === Get connection parameters === | ||
|
||
dpy=$(echo -n "$DISPLAY" | tr -c '[:alnum:]' _) | ||
|
||
if [ -z "$dpy" ]; then | ||
echo "Cannot find display." | ||
exit 1 | ||
fi | ||
|
||
service="com.github.chjj.compton.${dpy}" | ||
interface='com.github.chjj.compton' | ||
object='/com/github/chjj/compton' | ||
type_win='uint32' | ||
type_enum='uint16' | ||
|
||
# === DBus methods === | ||
|
||
# List all window ID compton manages (except destroyed ones) | ||
dbus-send --print-reply --dest="$service" "$object" "${interface}.list_win" | ||
|
||
# Ensure we are tracking focus | ||
dbus-send --print-reply --dest="$service" "$object" "${interface}.opts_set" string:track_focus boolean:true | ||
|
||
# Get window ID of currently focused window | ||
focused=$(dbus-send --print-reply --dest="$service" "$object" "${interface}.find_win" string:focused | $SED -n 's/^[[:space:]]*'${type_win}'[[:space:]]*\([[:digit:]]*\).*/\1/p') | ||
|
||
if [ -n "$focused" ]; then | ||
# Set the window to have selected strength | ||
dbus-send --print-reply --dest="$service" "$object" "${interface}.win_set" "${type_win}:${focused}" string:the_blur_strength "${type_enum}:$strength" | ||
else | ||
echo "Cannot find focused window." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters