Migrating to wl-clipboard-manager tooling.

For some reason clipman causes crashes, plus this works better.
This commit is contained in:
James Patrick 2020-06-27 00:47:59 -04:00
parent f3bf8f377f
commit 3e1eb7e28d
6 changed files with 55 additions and 15 deletions

View File

@ -13,8 +13,6 @@ set $tty-popup $scripts/tty-popup
set $menu bash ~/.config/sway/scripts/menu
set $pass_menu $tty-popup pass $scripts/fzf-pass
set $clipman_menu bash ~/.config/sway/scripts/menu_clipman
set $clipman_clear_menu bash ~/.config/sway/scripts/clipman_clear_menu
set $printscreen bash ~/.config/sway/scripts/printscreen
# Support for picture in picture mode.

View File

@ -7,6 +7,10 @@ exec --no-startup-id protonmail-bridge 2>&1 >/tmp/mail.log
### Make things a little easier easier on the eyes.
exec --no-startup-id redshift 2>&1 >/tmp/redshift.log
### Clipboard manager
exec --no-startup-id $scripts/clipboard daemon 2>&1 >/tmp/clipboardmanager.log
### Notifications
# https://github.com/emersion/mako
exec --no-startup-id mako 2>&1 >/tmp/mako.log
@ -39,9 +43,5 @@ exec_always {
tail -f /tmp/wobpipe | ~/.config/sway/scripts/sanitize_wob | wob
}
### Clipboard manager
# https://github.com/yory8/clipman
exec --no-startup-id wl-paste -t text --watch clipman store
# vim: ft=cfg
# -*- mode: conf-space -*-

View File

@ -8,9 +8,7 @@ bindsym $mod+q kill
bindsym $mod+space exec $menu
# gopass prompt
bindsym $mod+backslash exec $pass_menu
# Clipboard management
bindsym $mod+Mod1+c exec $clipman_menu
bindsym $mod+Shift+Mod1+c exec $clipman_clear_menu
# reload the configuration file
bindsym $mod+Shift+c reload

50
sway/scripts/clipboard Executable file
View File

@ -0,0 +1,50 @@
#!/bin/bash
workdir="${XDG_DATA_HOME:-$HOME/.local/share/clipboard/history}"
mkdir -p "$workdir"
cd "$workdir"
if [ "$1" = "daemon" ]; then
wl-paste -w $0 on-copy
elif [ "$1" = "lock" ]; then
touch .lock
elif [ "$1" = "unlock" ]; then
rm -f .lock
elif [ "$1" = "on-copy" ]; then
[ -f .lock ] && exit 0
file="$(date +%s)"
cat >"$file"
ext="$(file --mime-type "$file" | cut -d' ' -f2 | cut -d'/' -f2)"
mv "$file" "$file.$ext"
fdupes -idN .
find . -type f -size 0 -delete
find . -type f -size +10000000c -delete
find . -type f -print0 | sort -zn | head -z -n -10000 | xargs -r -0 rm
elif [ "$1" = "dmenu" ]; then
find . -type f -printf '%P\0' | sort -znr | while IFS= read -r -d '' file; do
if [[ "$file" =~ \.(plain|x-python)$ ]]; then
cat "$file"
else
printf '%s' "$file"
fi
printf '\0'
done | dmenu -0 -p clipboard -r "$(realpath "$0") preview" | {
read -r -d '' result
if [ -z "$result" ]; then
exit 0
elif [ -f "$result" ]; then
wl-copy <"$result"
else
printf '%s' "$result" | sed -e 's/[[:space:]]*$//' | sed -Ez 's/\s+$//' | wl-copy
fi
}
elif [ "$1" = "preview" ]; then
if [ -f "$2" ]; then
kitty +kitten icat --silent --stdin=no "$2"
else
echo "$2" | bat -l bash --color always -pp
fi
else
echo >&2 "Usage: $0 <daemon|lock|unlock|on-copy|dmenu|preview>"
exit 1
fi

View File

@ -1,3 +0,0 @@
#! /bin/sh
# -*- sh -*-
clipman clear --tool rofi

View File

@ -1,3 +0,0 @@
#! /bin/sh
# -*- sh -*-
clipman pick --tool rofi