clipnotify: fix wayland->x11 duplicating copy
Signed-off-by: Myned <dev@bjork.tech>
This commit is contained in:
parent
627e90b07f
commit
589c64bbf9
2 changed files with 10 additions and 7 deletions
|
@ -8,14 +8,11 @@ with lib; let
|
||||||
cfg = config.custom.desktops.niri.misc;
|
cfg = config.custom.desktops.niri.misc;
|
||||||
hm = config.home-manager.users.${config.custom.username};
|
hm = config.home-manager.users.${config.custom.username};
|
||||||
|
|
||||||
_1password = "${config.programs._1password-gui.package}/bin/1password";
|
|
||||||
audio = config.home-manager.users.${config.custom.username}.home.file.".local/bin/audio".source;
|
audio = config.home-manager.users.${config.custom.username}.home.file.".local/bin/audio".source;
|
||||||
niri = "${config.programs.niri.package}/bin/niri";
|
niri = "${config.programs.niri.package}/bin/niri";
|
||||||
rm = "${pkgs.coreutils}/bin/rm";
|
rm = "${pkgs.coreutils}/bin/rm";
|
||||||
sway-audio-idle-inhibit = "${pkgs.sway-audio-idle-inhibit}/bin/sway-audio-idle-inhibit";
|
sway-audio-idle-inhibit = "${pkgs.sway-audio-idle-inhibit}/bin/sway-audio-idle-inhibit";
|
||||||
wallpaper = "${config.home-manager.users.${config.custom.username}.home.file.".local/bin/wallpaper".source}";
|
wallpaper = "${config.home-manager.users.${config.custom.username}.home.file.".local/bin/wallpaper".source}";
|
||||||
wl-paste = "${pkgs.wl-clipboard}/bin/wl-paste";
|
|
||||||
xclip = "${pkgs.xclip}/bin/xclip";
|
|
||||||
in {
|
in {
|
||||||
options.custom.desktops.niri.misc = {
|
options.custom.desktops.niri.misc = {
|
||||||
enable = mkOption {default = false;};
|
enable = mkOption {default = false;};
|
||||||
|
@ -33,6 +30,7 @@ in {
|
||||||
theme = name;
|
theme = name;
|
||||||
|
|
||||||
# BUG: Heavily increases CPU usage with cursor movement
|
# BUG: Heavily increases CPU usage with cursor movement
|
||||||
|
# https://github.com/YaLTeR/niri/issues/1037
|
||||||
#// hide-after-inactive-ms = 1000 * 15; # Milliseconds
|
#// hide-after-inactive-ms = 1000 * 15; # Milliseconds
|
||||||
#// hide-when-typing = true;
|
#// hide-when-typing = true;
|
||||||
};
|
};
|
||||||
|
@ -61,9 +59,6 @@ in {
|
||||||
]
|
]
|
||||||
++ optionals config.custom.wallpaper [
|
++ optionals config.custom.wallpaper [
|
||||||
{command = [wallpaper];}
|
{command = [wallpaper];}
|
||||||
]
|
|
||||||
++ optionals config.custom.desktops.niri.xwayland [
|
|
||||||
{command = [wl-paste "--watch" xclip "-selection" "clipboard"];} # Sync (X)wayland clipboard
|
|
||||||
];
|
];
|
||||||
|
|
||||||
# https://github.com/sodiboo/niri-flake/blob/main/docs.md#programsnirisettingsswitch-eventslid-close
|
# https://github.com/sodiboo/niri-flake/blob/main/docs.md#programsnirisettingsswitch-eventslid-close
|
||||||
|
|
|
@ -9,6 +9,7 @@ with lib; let
|
||||||
|
|
||||||
clipnotify = getExe pkgs.clipnotify;
|
clipnotify = getExe pkgs.clipnotify;
|
||||||
wl-copy = getExe' pkgs.wl-clipboard "wl-copy";
|
wl-copy = getExe' pkgs.wl-clipboard "wl-copy";
|
||||||
|
wl-paste = getExe' pkgs.wl-clipboard "wl-paste";
|
||||||
xclip = getExe pkgs.xclip;
|
xclip = getExe pkgs.xclip;
|
||||||
in {
|
in {
|
||||||
options.custom.services.clipsync = {
|
options.custom.services.clipsync = {
|
||||||
|
@ -33,8 +34,15 @@ in {
|
||||||
Type = "simple";
|
Type = "simple";
|
||||||
|
|
||||||
ExecStart = pkgs.writeShellScript "clipsync" ''
|
ExecStart = pkgs.writeShellScript "clipsync" ''
|
||||||
|
# Push Wayland clipboard to X11
|
||||||
|
${wl-paste} --watch ${xclip} -selection clipboard &
|
||||||
|
|
||||||
|
# When X11 clipboard changes
|
||||||
while ${clipnotify}; do
|
while ${clipnotify}; do
|
||||||
${xclip} -selection clipboard -out | ${wl-copy}
|
# Push X11 clipboard to Wayland if not a duplicate
|
||||||
|
if [[ "$(${wl-paste})" != "$(${xclip} -selection clipboard -out)" ]]; then
|
||||||
|
${xclip} -selection clipboard -out | ${wl-copy}
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue