-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-paste.sh
More file actions
executable file
·30 lines (26 loc) · 963 Bytes
/
Copy pathsetup-paste.sh
File metadata and controls
executable file
·30 lines (26 loc) · 963 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env bash
set -Eeuo pipefail
SOURCE_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
DROPIN_DIR="/etc/systemd/system/ydotool.service.d"
TEMP_FILE="$(mktemp)"
trap 'rm -f "$TEMP_FILE"' EXIT
TARGET_UID="${1:-$(id -u)}"
TARGET_GID="${2:-$(id -g)}"
TARGET_USER="$(getent passwd "$TARGET_UID" | cut -d: -f1)"
if [[ -z "$TARGET_USER" ]]; then
echo "Could not resolve user ID $TARGET_UID" >&2
exit 1
fi
if [[ $EUID -eq 0 ]]; then
AS_ROOT=()
else
AS_ROOT=(sudo)
fi
sed -e "s/@USER_ID@/$TARGET_UID/g" -e "s/@GROUP_ID@/$TARGET_GID/g" \
"$SOURCE_DIR/systemd/ydotool-freeflow.conf" > "$TEMP_FILE"
"${AS_ROOT[@]}" install -d -m 755 "$DROPIN_DIR"
"${AS_ROOT[@]}" install -m 644 "$TEMP_FILE" "$DROPIN_DIR/freeflow.conf"
"${AS_ROOT[@]}" systemctl daemon-reload
"${AS_ROOT[@]}" systemctl enable --now ydotool.service
"${AS_ROOT[@]}" systemctl restart ydotool.service
echo "Automatic Wayland pasting is configured for user $TARGET_USER."