From 170020a28705fe191336e315fc1607485247afb7 Mon Sep 17 00:00:00 2001 From: tiyn Date: Wed, 9 Apr 2025 02:31:49 +0200 Subject: [PATCH] wayland: preliminary migration done --- .config/swaylock/config | 1 + .config/swhkd/swhkdrc | 86 +++++++ .config/waybar/config.jsonc | 84 +++++++ .config/waybar/style.css | 238 ++++++++++++++++++ .config/wayland/wayland.conf | 22 ++ .../etc/screen_capture/record_replay_start | 9 +- .local/bin/etc/screen_capture/record_start | 8 +- .local/bin/etc/sxhkd/screenshot | 27 +- .profile | 17 +- 9 files changed, 473 insertions(+), 19 deletions(-) create mode 100644 .config/swaylock/config create mode 100644 .config/swhkd/swhkdrc create mode 100644 .config/waybar/config.jsonc create mode 100644 .config/waybar/style.css create mode 100755 .config/wayland/wayland.conf diff --git a/.config/swaylock/config b/.config/swaylock/config new file mode 100644 index 0000000..f32e615 --- /dev/null +++ b/.config/swaylock/config @@ -0,0 +1 @@ +image=~/.local/share/lock diff --git a/.config/swhkd/swhkdrc b/.config/swhkd/swhkdrc new file mode 100644 index 0000000..f3ad474 --- /dev/null +++ b/.config/swhkd/swhkdrc @@ -0,0 +1,86 @@ +super + b + $BROWSER + +super + m + thunderbird + +super + u + record_stop + +super + i + record_start + +super + o + record_replay_start + +super + p + record_replay_save + +super + a + lmc previous + +super + s + lmc playpause + +super + d + lmc next + +super + c + lmc loop + +super + x + lmc shuffle + +super + bracketright + lmc mute_toggle + +super + backslash + lmc deaf_toggle + +super + apostrophe + lmc tap_toggle + +super + bracketleft + dnd toggle + +super + shift + b + killall -SIGUSR1 waybar + +super + shift + r + pkill -HUP swhkd ; notify-send -u low 'SWHKD' 'Reloaded hotkeys' + +super + shift + space + dunstctl close-all + +super + F7 + mount_menu + +super + F8 + umount_menu + +super + F9 + systemctl restart NetworkManager ; notify-send -u low 'Network' 'Restartet NM' + +super + F10 + prompt "Lock computer?" "swaylock -i ~/.local/share/lock" + +super + shift + F10 + prompt "Hibernate computer?" "systemctl hibernate" + +super + F11 + prompt "Shutdown computer?" "shutdown -h now" + +super + F12 + prompt "Reboot computer?" "reboot now" + +Print + screenshot + +XF86AudioMute + lmc deaf_toggle + +XF86AudioLowerVolume + lmc down + +XF86AudioRaiseVolume + lmc up diff --git a/.config/waybar/config.jsonc b/.config/waybar/config.jsonc new file mode 100644 index 0000000..c42318d --- /dev/null +++ b/.config/waybar/config.jsonc @@ -0,0 +1,84 @@ + +{ + "layer": "bottom", // Waybar at top layer + "position": "top", // Waybar position (top|bottom|left|right) + "height": 5, // Waybar height (to be removed for auto height) + // "width": 1280, // Waybar width + // Choose the order of the modules + "modules-left": ["dwl/tags", "dwl/window"], + "modules-right": ["cpu", "memory", "pulseaudio#output", "pulseaudio#input", "network", "battery", "clock", "tray"], + // Modules configuration + // "sway/workspaces": { + // "disable-scroll": true, + // "all-outputs": true, + // "format": "{name}: {icon}", + // "format-icons": { + // "1": "", + // "2": "", + // "3": "", + // "4": "", + // "5": "", + // "urgent": "", + // "focused": "", + // "default": "" + // } + // }, + "dwl/tags": { + "tag-labels": [ "", "", "", "", "", "", "", "", "", "" ] + }, + "dwl/window": { + "format": "{layout} {title}" + }, + "tray": { + "icon-size": 20, + "spacing": 10 + }, + "clock": { + "format": " {:%d %b %I:%M}" + }, + "battery": { + "states": { + "good": 75, + "warning": 25, + "critical": 15 + }, + "format": "{icon}", + "format-icons": { + "default": ["", "", "", "", ""], + "charging": ["", "", "", "", ""] + } + // "format-charging": "{capacity}%", + // "format-plugged": "{capacity}%", + // "format-alt": "{time} ", + // "format-good": "", // An empty format will hide the module + // "format-full": "", + }, + "network": { + // "interface": "wlp2*", // (Optional) To force the use of this interface + "format-wifi": "{icon}", + "format-ethernet": "󰈀", + "format-disconnected": "", + "format-icons": [ "" ] + }, + "pulseaudio#output": { + // "scroll-step": 1, // %, can be a float + "format-source": "", + "format-source-muted": "", + "format": "{format_source}" + }, + "pulseaudio#input": { + // "scroll-step": 1, // %, can be a float + "format": "{icon}", + "format-muted": "", + "format-bluetooth": "{format_source}", + "format-icons": [ "", "", "", ""] + }, + //disk-usage, gpu + "cpu": { + "format": "", + "tooltip": true + }, + "memory": { + "format": "" + } +} diff --git a/.config/waybar/style.css b/.config/waybar/style.css new file mode 100644 index 0000000..258acc9 --- /dev/null +++ b/.config/waybar/style.css @@ -0,0 +1,238 @@ +* { + border: none; + border-radius: 4px; + /* `ttf-font-awesome` is required to be installed for icons */ + font-family: Mono, Helvetica, Arial, sans-serif; + + /* adjust font-size value to your liking: */ + font-size: 15px; + + min-height: 0; +} + +window#waybar { + background-color: rgba(0, 0, 0, 1); + /* border-bottom: 3px solid rgba(100, 114, 125, 0.5); */ + color: #ffffff; + /* transition-property: background-color; */ + /* transition-duration: .5s; */ + /* border-radius: 0; */ +} + +/* window#waybar.hidden { + opacity: 0.2; +} */ + +/* +window#waybar.empty { + background-color: transparent; +} +window#waybar.solo { + background-color: #FFFFFF; +} +*/ + +/* window#waybar.termite { + background-color: #000000; +} + +window#waybar.chromium { + background-color: #000000; + border: none; +} */ + +#tags button { + /* padding: 0 0.4em; */ + /* background-color: transparent; */ + color: #ffffff; + /* Use box-shadow instead of border so the text isn't offset */ + box-shadow: inset 0 -3px transparent; +} + +/* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */ +#tags button:hover { + background: rgba(0, 0, 0, 0.9); + /* box-shadow: inset 0 -3px #ffffff; */ +} + +#tags button.occupied { + /* background-color: #282828; */ + box-shadow: inset 0 -3px #ffffff; +} + +#tags button.focused { + background-color: #555a63; + /* box-shadow: inset 0 -3px #ffffff; */ +} + +#tags button.urgent { + background-color: #eb4d4b; +} + +#mode { + background-color: #64727D; + /* border-bottom: 3px solid #ffffff; */ +} + +#clock, +#battery, +#cpu, +#memory, +#temperature, +#backlight, +#network, +#pulseaudio, +#custom-media, +#tray, +#mode, +#idle_inhibitor, +#mpd { + padding: 0 10px; + margin: 6px 3px; + color: #000000; +} + +#window, +#tags { + margin: 0 4px; +} + +/* If workspaces is the leftmost module, omit left margin */ +.modules-left > widget:first-child > #tags { + margin-left: 0; +} + +/* If workspaces is the rightmost module, omit right margin */ +.modules-right > widget:last-child > #tags { + margin-right: 0; +} + +#clock { + background-color: #000000; + color: white; +} + +#battery { + background-color: #000000; + color: white; +} + +#battery.charging { + color: #ffffff; + background-color: #000000; +} + +@keyframes blink { + to { + background-color: #ffffff; + color: #000000; + } +} + +#battery.critical:not(.charging) { + background-color: #f53c3c; + color: #ffffff; + animation-name: blink; + animation-duration: 0.5s; + animation-timing-function: linear; + animation-iteration-count: infinite; + animation-direction: alternate; +} + +label:focus { + background-color: #000000; +} + +#cpu { + background-color: #000000; + color: #ffffff; +} + +#memory { + background-color: #000000; + color: white; +} + +#backlight { + background-color: #000000; + color:white; +} + +#network { + background-color: #000000; + color:white; +} + +#network.disconnected { + background-color: #000000; +} + +#pulseaudio { + background-color: #000000; + color: #ffffff; +} + +#pulseaudio.muted { + background-color: #000000; + color: #ffffff; +} + +#custom-media { + background-color: #66cc99; + color: #2a5c45; + min-width: 100px; +} + +#custom-media.custom-spotify { + background-color: #66cc99; +} + +#custom-media.custom-vlc { + background-color: #ffa000; +} + +#temperature { + background-color: #f0932b; +} + +#temperature.critical { + background-color: #eb4d4b; +} + +#tray { + background-color: #000000; +} + +#idle_inhibitor { + background-color: #2d3436; +} + +#idle_inhibitor.activated { + background-color: #ecf0f1; + color: #2d3436; +} + +#mpd { + background-color: #66cc99; + color: #2a5c45; +} + +#mpd.disconnected { + background-color: #f53c3c; +} + +#mpd.stopped { + background-color: #90b1b1; +} + +#mpd.paused { + background-color: #51a37a; +} + +#language { + background: #bbccdd; + color: #333333; + padding: 0 5px; + margin: 6px 3px; + min-width: 16px; +} diff --git a/.config/wayland/wayland.conf b/.config/wayland/wayland.conf new file mode 100755 index 0000000..967f9f0 --- /dev/null +++ b/.config/wayland/wayland.conf @@ -0,0 +1,22 @@ +#!/bin/sh +$STATUSBAR & # use environment variable +unclutter & # hide cursor +xss-lock -- swaylock & # enable locking the screen upon sleep +swaybg -i ~/.local/share/bg & +dunst & +dunstctl rule dnd_low disable & +dunstctl rule dnd_normal disable & +swhks && swhkd & + +pavucontrol & +easyeffects --gapplication-service & +nextcloud & +keepassxc & +zen-browser & +discord & +signal-desktop & + +# monitor toggle & +# touchpad off & +# xset r rate 300 50 & # Speed xrate up +# redshift & # redshift for saving your eyes diff --git a/.local/bin/etc/screen_capture/record_replay_start b/.local/bin/etc/screen_capture/record_replay_start index 0ed0a19..95c311f 100755 --- a/.local/bin/etc/screen_capture/record_replay_start +++ b/.local/bin/etc/screen_capture/record_replay_start @@ -5,13 +5,18 @@ audio_2=${CAPTURE_OUTPUT_AUDIO:-easyeffects_source} output=${CAPTURE_DIR:-$HOME/downloads} device=${CAPTURE_DEVICE:-cpu} -window=$(xdotool getwindowfocus) fps=60 format="mp4" v_codec="h264" a_codec="opus" lenght=20 + +if [ $DISPLAY_SERVER = "wayland" ]; then + window="screen" +elif [ $DISPLAY_SERVER = "xorg" ]; then + window=$(xdotool getwindowfocus) +fi + gpu-screen-recorder -encoder $device -w $window -f $fps -a $audio_1 -a $audio_2 -c $format -k $v_codec -ac $a_codec -r $lenght -o $output & -# gpu-screen-recorder -encoder $device -w screen -f $fps -a $audio_1 -a $audio_2 -c $format -k $v_codec -ac $a_codec -r $lenght -o $output & # wayland command notify-send -u low 'Screen record' 'Replay started' diff --git a/.local/bin/etc/screen_capture/record_start b/.local/bin/etc/screen_capture/record_start index c762f36..cbfbd2c 100755 --- a/.local/bin/etc/screen_capture/record_start +++ b/.local/bin/etc/screen_capture/record_start @@ -5,13 +5,17 @@ audio_2=${CAPTURE_OUTPUT_AUDIO:-easyeffects_source} output=${CAPTURE_DIR:-$HOME/downloads} device=${CAPTURE_DEVICE:-cpu} -window=$(xdotool getwindowfocus) fps=30 format="mp4" v_codec="h264" a_codec="aac" output="$output/recording-$(date '+%Y-%m-%d_%H-%M-%S').$format" +if [ $DISPLAY_SERVER = "wayland" ]; then + window="screen" +elif [ $DISPLAY_SERVER = "xorg" ]; then + window=$(xdotool getwindowfocus) +fi + gpu-screen-recorder -encoder $device -w $window -c $format -k $v_codec -ac $a_codec -f $fps -o $output & -# gpu-screen-recorder -encoder $device -w screen -c $format -k $v_codec -ac $a_codec -f $fps -o $output & # wayland command notify-send -u low 'Screen record' 'Recording started' diff --git a/.local/bin/etc/sxhkd/screenshot b/.local/bin/etc/sxhkd/screenshot index fa1930d..1e6ed47 100755 --- a/.local/bin/etc/sxhkd/screenshot +++ b/.local/bin/etc/sxhkd/screenshot @@ -9,12 +9,21 @@ output="$output/screenshot-$(date '+%Y-%m-%d_%H-%M-%S').png" xclip_img="xclip -sel clip -t image/png" xclip_txt="xclip -sel clip -t text/plain" -case "$(printf "a selected area\\na selected area (copy)\\ncurrent window\\ncurrent window (copy)\\nfull screen\\nfull screen (copy)\\ncolor picker (copy)" | dmenu -l 6 -i -p "Screenshot which area?")" in - "a selected area") maim -s --hidecursor $output ;; - "a selected area (copy)") maim -s --hidecursor | ${xclip_img} ;; - "current window") maim -i "$(xdotool getactivewindow)" $output ;; - "current window (copy)") maim -i "$(xdotool getactivewindow)" | ${xclip_img} ;; - "full screen") maim $output ;; - "full screen (copy)") maim | ${xclip_img} ;; - "color picker (copy)") xcolor |tr -d '\n' | ${xclip_txt} ;; -esac +if [ $DISPLAY_SERVER = "wayland" ]; then + case "$(printf "a selected area\\na selected area (copy)\\nfull screen\\nfull screen (copy)" | dmenu -l 6 -i -p "Screenshot which area?")" in + "a selected area") grim -g "$(slurp)" $output ;; + "a selected area (copy)") grim -g "$(slurp)" - | wl-copy ;; + "full screen") grim $output ;; + "full screen (copy)") grim - | wl-copy ;; + esac +elif [ $DISPLAY_SERVER = "xorg" ]; then + case "$(printf "a selected area\\na selected area (copy)\\ncurrent window\\ncurrent window (copy)\\nfull screen\\nfull screen (copy)\\ncolor picker (copy)" | dmenu -l 6 -i -p "Screenshot which area?")" in + "a selected area") maim -s --hidecursor $output ;; + "a selected area (copy)") maim -s --hidecursor | ${xclip_img} ;; + "current window") maim -i "$(xdotool getactivewindow)" $output ;; + "current window (copy)") maim -i "$(xdotool getactivewindow)" | ${xclip_img} ;; + "full screen") maim $output ;; + "full screen (copy)") maim | ${xclip_img} ;; + "color picker (copy)") xcolor |tr -d '\n' | ${xclip_txt} ;; + esac +fi diff --git a/.profile b/.profile index 87deca8..c699d82 100644 --- a/.profile +++ b/.profile @@ -1,6 +1,9 @@ #!/bin/sh # Profile file. Runs on login. +# sets default display server (can be overwritten in ~/.config/profile/local_profile) +export DISPLAY_SERVER="xorg" + # Adds `~/.local/bin` and all subdirectories to $PATH export PATH="${PATH}:$(du "${HOME}/.local/bin/" | cut -f2 | tr '\n' ':' | sed 's/:*$//')" @@ -13,7 +16,6 @@ export EDITOR="nvim" export FILE="vifmrun" export IMAGE="sxiv" export READER="zathura" -export STATUSBAR="dwmblocks" export TERMINAL="st" export QT_QPA_PLATFORMTHEME="qt6ct" @@ -83,8 +85,11 @@ echo "$0" | grep "zsh$" >/dev/null && [ -f ${ZDOTDIR}/.zshrc ] && source "${ZDOT # load optional variables [ -f ~/.config/profile/local_profile ] && source "${HOME}/.config/profile/local_profile" -# Start graphical server if not already running. -[ "$(tty)" = "/dev/tty1" ] && ! pgrep -x Xorg >/dev/null && exec startx - -# start wayland using dwl -# dwl -s ~/.config/wayland/wayland.conf +# Start graphical server based on set display server +if [ $DISPLAY_SERVER = "wayland" ]; then + export STATUSBAR="waybar" + dwl -s ~/.config/wayland/wayland.conf +elif [ $DISPLAY_SERVER = "xorg" ]; then + export STATUSBAR="dwmblocks" + [ "$(tty)" = "/dev/tty1" ] && ! pgrep -x Xorg >/dev/null && exec startx +fi