Switch to wayland

Added a simple wayland configuration.
Currently set up simple wayland configuration based on river window
manager and waybar.
Rivercarro is the layout manager, being the same in principle as rivertile,
the default layout manager for river, only it comes with smart gaps
(gaps turn off if there is only one window open)
and monocle mode (give one window all space).

Runs `keyd` in the background to replace the old `xcape` capslock switching
(capslock is escape and if held control).
Uses `swaybg` to set a wallpaper.

Added powermenu and lockscreen scripts.
Improved lockscreen script to detect and work for wayland.
Moved old rofi mode 'powermenu' to more general powermenu script,
which works with any rofi-like selector (dmenu, bemenu, wofi, etc.)
Loses some of its design quality but since it was wonky anyway,
and I rarely see the menu,
we could repurpose its functionality for a more general powermenu
concept.
Currently hardcoded for `bemenu` but can be easily swapped and possibly
even extended back to rofi.
Fixed file upload link sharing to clipboard.

Updated rofi-pass to pass-pick.
Made rofi-pass universal and less integrated to rofi - that's also the
reason for the name change.
`pass-pick` works with rofi (default), bemenu or dmenu. In theory it
should also work with any other picker that contains a stdin listing
function similar to dmenu.
It has been definitely tested both on rofi and bemenu.
The best user experience still reigns on rofi, where available keys are
displayed on the picker and the keys themselves make the most sense.
But all functions can be reached from bemenu as well, though the key
mappings are more arbitrary and can not be changed as in rofi.
The autofilling tool works with both xdotool and ydotool, so should work
both on X11 and on Wayland. Ydotool ideally requires its daemon to be
running, otherwise some of the typing may get gut off. Otherwise no
change should be necessary.

Updated qutebrowser open_download for bemenu.
Updated download opening script to work with both rofi and bemenu.
Prefers original rofi implementation but works with both, and can be set
to use a custom dmenu-like file picker as well.

Add brightnessctl and removed custom audio / brightness scripts since they
became unnecessary.

Updated bootstrap script to include system files:
With `keyd` taking its configuration from the `/etc` directory and not
home, a second stow stage was necessary. These stow files are in a
module called `system-packages` inside the top-level `bootstrap` stow
package.
They will not be installed by the default dotfile stow invocation but
have been integrated as an extra step into the install script.
Installing this module requires sudo privileges!

Switched vifm überzug to sixel graphics rendering.
überzug relies on X11 functionality to work, while sixel does not.
Unfortunately, alacritty does not work with sixel graphics yet, only
foot does (somewhat).

Waybar currently runs the gruvbox dark soft color scheme.
Added the old polybar archupdates script to waybar and extended it to
output json format with additional metadata that waybar can read.
Can still output the old plaintext format that polybar expects.
Added a wireguard connection to waybar,shows if currently
connected to either a wireguard or tun VPN service.
If so, shows an icon in the waybar - that can be hovered over to show
the full assigned IP address.
Added an upcoming event display to waybar,
a simple event indicator to show upcoming events on the calendar, on
hovering over it the tooltip lists all upcoming events.

Added `screenshot` script to take simple screenshots and
rectangle region shots of the current output.
Can be invoked through the river shortcut PrintScr:
`PrintScr` - Fullscreen screenshot
`Mod+PrintScr` - Region screenshot
`Shift+PrintScr` - Fullscreen screenshot and file upload
`Mod+Shift+PrintScr` - Region screenshot and file upload

Extended `sharefile` to take paths through stdin and make
use of `fd` if it is found on the system.
This commit is contained in:
Marty Oehme 2021-11-26 07:59:35 +01:00
parent 89d1402b3e
commit 6ac552d3d5
Signed by: Marty
GPG key ID: B7538B8F50A1C800
61 changed files with 1811 additions and 2032 deletions

View file

@ -1,53 +0,0 @@
#!/usr/bin/env sh
# Brightness control script using xbacklight
# Will use notify-send to create brightness notifications, if dunst is used
# or the notification daemon supports tag stacks, will automatically update
# the same notifications and not create new ones.
#
# inspired from https://gist.github.com/Blaradox/030f06d165a82583ae817ee954438f2e
usage() {
echo "usage: control-brightness up|down [step], where step can be any int value
or: control-brightness set target, where target can be an int value 0-100"
}
direction=$1
step=${2:-10}
get_brightness() {
xbacklight -get | cut -d. -f1
}
send_notification() {
icon="preferences-system-brightness-lock"
brightness=$(get_brightness)
if type dunstify 1>/dev/null 2>/dev/null; then
notcmd="dunstify -h string:x-dunst-stack-tag:brightness"
else
notcmd="notify-send -h string:x-dunst-stack-tag:brightness"
fi
$notcmd -a "changeVolume" -u low -i "$icon" \
-h int:value:"$brightness" "Brightness: $brightness%"
}
case $direction in
up)
xbacklight -inc "$step"
send_notification
;;
down)
xbacklight -dec "$step"
send_notification
;;
set)
if [ -z "$step" ]; then
echo "set option requires target brightness to be specified."
return 1
fi
xbacklight -set "$step"
send_notification
;;
*)
echo "usage: control-brightness up|down [step], where step can be any int value"
;;
esac

View file

@ -1,97 +0,0 @@
#!/usr/bin/env sh
# change Volume in an easy and unified way
direction=$1
step=${2:-5dB}
# amixer channel to target
amixer_quiet() {
amixer -c 0 "$@" >/dev/null
}
amixer_noisy="amixer -c 0 "
# Query amixer for the current volume
get_volume() {
$amixer_noisy get Master | tail -1 | awk '{print $4}' | sed 's/[^0-9]*//g'
}
# query amixer for mute state (off=muted)
get_mute() {
$amixer_noisy get Master | tail -1 | awk '{print $6}' | sed 's/[^a-z]*//g'
}
set_volume() {
# Change the volume using alsa(might differ if you use pulseaudio)
amixer_quiet set Master "$@" >/dev/null
# Play the volume changed sound
# -- this is *extremely* laggy (>8s) on my system, no idea why and no time to find out
# canberra-gtk-play -i audio-volume-change -d "changeVolume"
}
# set mute state (off=mute)
set_mute() {
[ "$(get_mute)" = "on" ] && toggleto=off || toggleto=on
if [ "$1" = 'off' ]; then
amixer_quiet set Master mute
elif [ "$1" = 'on' ]; then
amixer_quiet set Master unmute
# the following is needed, see https://superuser.com/questions/805525/why-is-unmute-not-working-with-amixer-command
amixer_quiet set Speaker unmute
amixer_quiet set Headphone unmute
else
amixer_quiet set Master "$toggleto"
amixer_quiet set Speaker "$toggleto"
amixer_quiet set Headphone "$toggleto"
fi
}
usage() {
echo "control-volume up|down [step], with step any int value
or: control-brightness set [target], with target any int value 0-100"
}
send_notification() {
if type dunstify 1>/dev/null 2>/dev/null; then
notcmd="dunstify -h string:x-dunst-stack-tag:brightness"
else
notcmd="notify-send -h string:x-dunst-stack-tag:brightness"
fi
vol="$(get_volume)"
if [ "$vol" -eq 0 ] || [ "$(get_mute)" = "off" ]; then
# Show the sound muted notification
$notcmd -a "changeVolume" -u low -i audio-volume-muted "Volume muted"
else
# Show the volume notification
$notcmd -a "changeVolume" -u low -i audio-volume-high \
-h int:value:"$vol" "Volume: $vol%"
fi
}
case $direction in
up)
set_volume "${step}+"
;;
down)
set_volume "${step}-"
;;
mute)
set_mute "$step"
;;
mutetoggle)
set_mute
;;
set)
if [ -z "$step" ]; then
echo "set option requires target brightness to be specified."
return 1
fi
set_volume "$step"
;;
*)
usage
;;
esac
send_notification

View file

@ -1,12 +1,23 @@
#!/usr/bin/env sh
#!/usr/bin/env bash
# Example locker script -- demonstrates how to use the --transfer-sleep-lock
# option with i3lock's forking mode to delay sleep until the screen is locked.
# locker script -- makes sure that x does not give up the lock easily (using i3lock)
# simply locks the screen on wayland (using waylock)
## CONFIGURATION ##############################################################
is_wayland() {
# alternative $(</proc/self/sessionid), see
# https://stackoverflow.com/questions/3214935/can-a-bash-script-tell-if-its-being-run-via-cron
if loginctl show-session "$(loginctl show-user "$(whoami)" -p Display --value)" -p Type --value | grep -q wayland; then
true
else
false
fi
}
# Options to pass to i3lock
i3lock_options="-e -f -c 1d2021"
waylock_options="--init-color #223344 --input-color #224444 --fail-color #554444"
# Run before starting the locker
pre_lock() {
@ -26,18 +37,21 @@ post_lock() {
pre_lock
# We set a trap to kill the locker if we get killed, then start the locker and
# wait for it to exit. The waiting is not that straightforward when the locker
# forks, so we use this polling only if we have a sleep lock to deal with.
if [ -e /dev/fd/${XSS_SLEEP_LOCK_FD:--1} ]; then
if is_wayland; then
# shellcheck disable=SC2086
waylock $waylock_options
elif [ -e "/dev/fd/${XSS_SLEEP_LOCK_FD:--1}" ]; then
# On X, we set a trap to kill the locker if we get killed, then start the locker and
# wait for it to exit. The waiting is not that straightforward when the locker
# forks, so we use this polling only if we have a sleep lock to deal with.
kill_i3lock() {
pkill -xu $EUID "$@" i3lock
pkill -xu "$EUID" "$@" i3lock
}
trap kill_i3lock TERM INT
# we have to make sure the locker does not inherit a copy of the lock fd
i3lock $i3lock_options {XSS_SLEEP_LOCK_FD}<&-
i3lock "$i3lock_options" {XSS_SLEEP_LOCK_FD}<&-
# now close our fd (only remaining copy) to indicate we're ready to sleep
exec {XSS_SLEEP_LOCK_FD}<&-
@ -47,7 +61,7 @@ if [ -e /dev/fd/${XSS_SLEEP_LOCK_FD:--1} ]; then
done
else
trap 'kill %%' TERM INT
i3lock -n $i3lock_options &
i3lock -n "$i3lock_options" &
wait
fi

84
scripts/.local/bin/powermenu Executable file
View file

@ -0,0 +1,84 @@
#!/usr/bin/env bash
# A simple powermenu listing.
# Uses bemenu to display the powermenu on X11, Wayland and terminal.
#### Environment Variable Options ###
# Interface options
# POWERMENU_SHOW_ICONS=1
# POWERMENU_SHOW_TEXT=1
# POWERMENU_SHOW_UPTIME=1
# Command options
# POWERMENU_SHUTDOWN_CMD=""
# POWERMENU_REBOOT_CMD=""
# POWERMENU_LOCKSCREEN_CMD=""
# POWERMENU_LOGOUT_CMD=""
# POWERMENU_SUSPEND_CMD=""
# Command chooser options
# POWERMENU_PICKER_CMD=""
# POWERMENU_PICKER_OPTS=""
#### Menu Options ###
if [ "${POWERMENU_SHOW_TEXT:-0}" -eq 0 ] && [ "${POWERMENU_SHOW_ICONS:-1}" -eq 0 ]; then
echo "You disabled both text and icons for rofi-powermenu, nothing can be shown."
exit 1
elif [ "${POWERMENU_SHOW_ICONS:-1}" -eq 1 ]; then
power_off_btn=""
reboot_btn=""
lock_btn=""
suspend_btn="鈴"
logout_btn=""
fi
if [ "${POWERMENU_SHOW_TEXT:-1}" -eq 1 ]; then
power_off_btn="${power_off_btn} Shut Down"
reboot_btn="${reboot_btn} Restart"
lock_btn="${lock_btn} Lock Screen"
suspend_btn="${suspend_btn} Suspend"
logout_btn="${logout_btn} Log Out"
fi
## SET PROMPT
if [ "${POWERMENU_SHOW_UPTIME:-1}" -eq 1 ]; then
prompt="Uptime $(uptime -p | sed -e 's/up //g') >"
else
prompt="Power >"
fi
selector_program="${POWERMENU_PICKER_CMD:-bemenu}"
selector_opts="${POWERMENU_PICKER_OPTS:--i}"
menu=$(printf "%s\n" "$lock_btn" "$suspend_btn" "$power_off_btn" "$reboot_btn" "$logout_btn")
# shellcheck disable=SC2086
result=$(printf "%s" "$menu" | $selector_program $selector_opts --prompt "$prompt")
# grep -a since it assumes with our nullcodes etc that this is a binary file
# grep -o to only leave the things we grep for
case "$result" in
"Shutdown" | "$power_off_btn")
if [ -n "$POWERMENU_SHUTDOWN_CMD" ]; then eval "$POWERMENU_SHUTDOWN_CMD"; else
systemctl poweroff
fi
;;
"Reboot" | "$reboot_btn")
if [ -n "$POWERMENU_REBOOT_CMD" ]; then eval "$POWERMENU_REBOOT_CMD"; else
systemctl reboot
fi
;;
"Lockscreen" | "$lock_btn")
# Completely detach from the parent script
# If in/outputs are not redirected, rofi will wait for the forked process as well.
if [ -n "$POWERMENU_LOCKSCREEN_CMD" ]; then eval "$POWERMENU_LOCKSCREEN_CMD"; else
lockscreen
fi
;;
"Logout" | "$logout_btn")
if [ -n "$POWERMENU_LOGOUT_CMD" ]; then eval "$POWERMENU_LOGOUT_CMD"; else
command -v i3 >/dev/null 2>&1 && i3-msg exit
command -v riverctl >/dev/null 2>&1 && riverctl exit
fi
;;
"Suspend" | "$suspend_btn")
if [ -n "$POWERMENU_SUSPEND_CMD" ]; then eval "$POWERMENU_SUSPEND_CMD"; else
systemctl hibernate
fi
;;
esac

View file

@ -4,59 +4,81 @@
#
# Examples:
# `sharefile`
# calling without arguments allows you to first select a folder and then
# Calling without arguments allows you to first select a folder and then
# a file from the folder to share.
# `sharefile ~/my-folder/`
# Calling with a folder as argument restricts the file selection to files within.
# `sharefile ~/my-file.zip`
# calling with a file as argument automatically uploads the file and copies
# Calling with a file as argument automatically uploads the file and copies
# share link to clipboard.
# When called with a folder as argument allows you to select file within, uploads it and copies share link.
# `screenshot | sharefile -`
# Calling with a dash as argument gets the file from stdin instead.
# Be aware that this currently only works for files not folders.
OXO_URL="https://0x0.st"
folderpicker() {
selected=$(find "${1:-$HOME}" -type d | fzf)
[ "$?" -eq 130 ] && exit 130
echo "$selected"
# use fd if available
if command -v fd >/dev/null 2>&1; then
sharefile_fd_cmd="fd"
else
sharefile_fd_cmd="find"
fi
main() {
if [ $# -eq 0 ]; then
foldpick=$(picker d "")
exit_check $?
picked=$(picker f "$foldpick")
elif [ "$1" = "-" ]; then
while read -r file; do
picked="$file"
done <"/dev/stdin"
elif [ -f "$1" ]; then
picked="$1"
elif [ -d "$1" ]; then
picked=$(picker f "$1")
else
printf "Please only provide a folder or file as the optional argument to sharefile." >&2
exit 1
fi
exit_check $?
url=$(file_to_oxo "$picked")
echo "$url"
url_to_clipboard "$url"
if command -v notify-send >/dev/null 2>&1; then
notify-send "Upload finished" "URL: $url"
fi
exit
}
filepicker() {
selected=$(find "${1:-$HOME}" -type f | fzf)
[ "$?" -eq 130 ] && exit 130
echo "$selected"
picker() {
if [ "$sharefile_fd_cmd" = "fd" ]; then
selected=$(fd "$SHAREFILE_FD_OPTS" --type "${1:-f}" . "${2:-$HOME}" | fzf)
elif [ "$sharefile_fd_cmd" = "find" ]; then
selected=$(find "$SHAREFILE_FD_OPTS" "${2:-$HOME}" -type "$1" | fzf)
fi
[ "$?" -eq 130 ] && exit 130
echo "$selected"
}
filetooxo() {
curl -F"file=@$1" "$OXO_URL"
url_to_clipboard() {
if command -v wl-copy >/dev/null 2>&1; then
printf "%s" "$@" | wl-copy
elif command -v xsel >/dev/null 2>&1; then
printf "%s" "$@" | xsel --clipboard
elif command -v xclip >/dev/null 2>&1; then
printf "%s" "$@" | xclip -selection clipboard >/dev/null 2>&1
fi
}
file_to_oxo() {
curl -F"file=@$1" "$OXO_URL"
}
# exit on escape pressed
exit_check() {
[ "$1" -eq 130 ] && exit 130
}
main() {
if [ $# -eq 0 ]; then
foldpick=$(folderpicker "")
exit_check $?
picked=$(filepicker "$foldpick")
elif [ -f "$1" ]; then
picked="$1"
elif [ -d "$1" ]; then
picked=$(filepicker "$1")
else
printf "Please only provide a folder or file as the optional argument to sharefile." >&2
exit 1
fi
exit_check $?
url=$(filetooxo "$picked")
echo "$url"
if command -v notify-send >/dev/null; then
notify-send "Upload finished" "URL: $url"
fi
# printf "%s" "$url" | nohup xclip -i -selection clipboard -r -verbose -loops 2 >/dev/null 2>&1
printf "%s" "$url" | xsel --clipboard
exit
[ "$1" -eq 130 ] && exit 130
}
main "$@"