From d4c4898bc47505aa599fb773dbdb15a83d04c81c Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 6 Jan 2024 11:35:43 +0800 Subject: [PATCH] SwayWM --- .config/sway/conf.d/custom | 3 + .../sway/{config.d => conf.d}/custom.d/fedora | 0 .../custom.d/input-settings | 0 .../{config.d => conf.d}/custom.d/outputs | 19 ++- .config/sway/{config.d => conf.d}/display | 0 .config/sway/{config.d => conf.d}/exec | 0 .config/sway/{config.d => conf.d}/keybinds | 8 +- .config/sway/conf.d/theme | 3 + .config/sway/{config.d => conf.d}/themes/dark | 2 +- .../sway/{config.d => conf.d}/themes/light | 0 .config/sway/config | 12 +- .config/sway/config.d/custom | 3 - .config/sway/config.d/theme | 3 - .config/sway/scripts/boxshadow.sh | 13 -- .config/sway/scripts/grimshot-ui.sh | 22 --- .config/sway/scripts/grimshot.sh | 156 ------------------ .config/sway/scripts/logout.sh | 5 +- .config/sway/scripts/themes.sh | 2 +- .zshrc | 3 + 19 files changed, 33 insertions(+), 221 deletions(-) create mode 100644 .config/sway/conf.d/custom rename .config/sway/{config.d => conf.d}/custom.d/fedora (100%) rename .config/sway/{config.d => conf.d}/custom.d/input-settings (100%) rename .config/sway/{config.d => conf.d}/custom.d/outputs (71%) rename .config/sway/{config.d => conf.d}/display (100%) rename .config/sway/{config.d => conf.d}/exec (100%) rename .config/sway/{config.d => conf.d}/keybinds (89%) create mode 100644 .config/sway/conf.d/theme rename .config/sway/{config.d => conf.d}/themes/dark (94%) rename .config/sway/{config.d => conf.d}/themes/light (100%) delete mode 100644 .config/sway/config.d/custom delete mode 100644 .config/sway/config.d/theme delete mode 100755 .config/sway/scripts/boxshadow.sh delete mode 100755 .config/sway/scripts/grimshot-ui.sh delete mode 100755 .config/sway/scripts/grimshot.sh diff --git a/.config/sway/conf.d/custom b/.config/sway/conf.d/custom new file mode 100644 index 0000000..2bde2b8 --- /dev/null +++ b/.config/sway/conf.d/custom @@ -0,0 +1,3 @@ +# vim: filetype=swayconfig + +include ~/.config/sway/conf.d/custom.d/* diff --git a/.config/sway/config.d/custom.d/fedora b/.config/sway/conf.d/custom.d/fedora similarity index 100% rename from .config/sway/config.d/custom.d/fedora rename to .config/sway/conf.d/custom.d/fedora diff --git a/.config/sway/config.d/custom.d/input-settings b/.config/sway/conf.d/custom.d/input-settings similarity index 100% rename from .config/sway/config.d/custom.d/input-settings rename to .config/sway/conf.d/custom.d/input-settings diff --git a/.config/sway/config.d/custom.d/outputs b/.config/sway/conf.d/custom.d/outputs similarity index 71% rename from .config/sway/config.d/custom.d/outputs rename to .config/sway/conf.d/custom.d/outputs index d619fd2..c19143f 100644 --- a/.config/sway/config.d/custom.d/outputs +++ b/.config/sway/conf.d/custom.d/outputs @@ -1,18 +1,18 @@ +output * adaptive_sync on + # 75hz monitor output 'Lectron Company Ltd LECOO M2412HL GG30A137' mode 2560x1440@74.968Hz output 'Lectron Company Ltd LECOO M2412HL GG30A137' subpixel rgb output 'Lectron Company Ltd LECOO M2412HL GG30A137' pos 0 500 # output 'Lectron Company Ltd LECOO M2412HL GG30A137' max_render_time 5 -# output 'Lectron Company Ltd LECOO M2412HL GG30A137' render_bit_depth 10 - -output * adaptive_sync on +output 'Lectron Company Ltd LECOO M2412HL GG30A137' render_bit_depth 10 # laptop screen output 'Thermotrex Corporation TL160ADMP03-0 Unknown' subpixel rgb # output 'Thermotrex Corporation TL160ADMP03-0 Unknown' mode 2560x1600@60.000Hz # output 'Thermotrex Corporation TL160ADMP03-0 Unknown' max_render_time 5 -output 'Thermotrex Corporation TL160ADMP03-0 Unknown' mode 2560x1600@240.000Hz -output 'Thermotrex Corporation TL160ADMP03-0 Unknown' max_render_time 8 +output 'Thermotrex Corporation TL160ADMP03-0 Unknown' mode 2560x1600@60.000Hz +# output 'Thermotrex Corporation TL160ADMP03-0 Unknown' max_render_time 8 # output 'Thermotrex Corporation TL160ADMP03-0 Unknown' render_bit_depth 10 # TV at home @@ -20,9 +20,10 @@ output 'Unknown HUAWEI INC 0x00000000' mode 3840x2160@60.000Hz output 'Unknown HUAWEI INC 0x00000000' scale 2 # lab screen -# output "XMI Redmi 27 NU 3948622WH08F4" mode 1920x1080@60.000Hz +output "XMI Redmi 27 NU 3948622WH08F4" mode --custom 2560x1440@75.000Hz output "XMI Redmi 27 NU 3948622WH08F4" transform 90 -output "XMI Redmi 27 NU 3948622WH08F4" max_render_time 3 -output "XMI Redmi 27 NU 3948622WH08F4" subpixel rgb -output "XMI Redmi 27 NU 3948622WH08F4" scale 1.5 output "XMI Redmi 27 NU 3948622WH08F4" pos 2560 0 +output "XMI Redmi 27 NU 3948622WH08F4" subpixel rgb +# output "XMI Redmi 27 NU 3948622WH08F4" max_render_time off +# output "XMI Redmi 27 NU 3948622WH08F4" scale 1.5 +output "XMI Redmi 27 NU 3948622WH08F4" render_bit_depth 10 diff --git a/.config/sway/config.d/display b/.config/sway/conf.d/display similarity index 100% rename from .config/sway/config.d/display rename to .config/sway/conf.d/display diff --git a/.config/sway/config.d/exec b/.config/sway/conf.d/exec similarity index 100% rename from .config/sway/config.d/exec rename to .config/sway/conf.d/exec diff --git a/.config/sway/config.d/keybinds b/.config/sway/conf.d/keybinds similarity index 89% rename from .config/sway/config.d/keybinds rename to .config/sway/conf.d/keybinds index bec5f61..0d651bf 100644 --- a/.config/sway/config.d/keybinds +++ b/.config/sway/conf.d/keybinds @@ -11,8 +11,8 @@ set $menu wofi # my keybinds # screenshot -bindsym $mod+Print exec ~/.config/sway/scripts/grimshot-ui.sh -bindsym $mod+Shift+s exec ~/.config/sway/scripts/grimshot-ui.sh +bindsym $mod+Print exec grimshot --cursor copy area +bindsym $mod+Shift+s exec grimshot --cursor copy area # notification client bindsym $mod+m exec swaync-client -t -sw # Logout @@ -36,8 +36,8 @@ bindsym --whole-window $mod+button9 workspace next # bind fn keys bindsym XF86AudioMicMute exec amixer set Capture toggle exec mkfifo $SWAYSOCK.wob && tail -f $SWAYSOCK.wob | wob -bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +3% && pactl get-sink-volume @DEFAULT_SINK@ | head -n 1| awk '{print substr($5, 1, length($5)-1)}' > $SWAYSOCK.wob -bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -3% && pactl get-sink-volume @DEFAULT_SINK@ | head -n 1 | awk '{print substr($5, 1, length($5)-1)}' > $SWAYSOCK.wob +bindsym XF86AudioRaiseVolume exec wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 2% && pactl get-sink-volume @DEFAULT_SINK@ | head -n 1| awk '{print substr($5, 1, length($5)-1)}' > $SWAYSOCK.wob +bindsym XF86AudioLowerVolume exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 2%- && pactl get-sink-volume @DEFAULT_SINK@ | head -n 1 | awk '{print substr($5, 1, length($5)-1)}' > $SWAYSOCK.wob bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle && ~/.config/sway/scripts/getmute.sh > $SWAYSOCK.wob bindsym XF86MonBrightnessUp exec light -A 5 && light -G | cut -d'.' -f1 > $SWAYSOCK.wob bindsym XF86MonBrightnessDown exec light -U 5 && light -G | cut -d'.' -f1 > $SWAYSOCK.wob diff --git a/.config/sway/conf.d/theme b/.config/sway/conf.d/theme new file mode 100644 index 0000000..4f3b303 --- /dev/null +++ b/.config/sway/conf.d/theme @@ -0,0 +1,3 @@ +# vim: filetype=swayconfig + +include ~/.config/sway/conf.d/themes/dark diff --git a/.config/sway/config.d/themes/dark b/.config/sway/conf.d/themes/dark similarity index 94% rename from .config/sway/config.d/themes/dark rename to .config/sway/conf.d/themes/dark index 07c5e38..d6a51d1 100644 --- a/.config/sway/config.d/themes/dark +++ b/.config/sway/conf.d/themes/dark @@ -4,7 +4,7 @@ set $gnome-schema org.gnome.desktop.interface exec_always { gsettings set $gnome-schema color-scheme 'prefer-dark' - gsettings set $gnome-schema gtk-theme 'Adwaita-dark' + gsettings set $gnome-schema gtk-theme 'Adwaita' gsettings set $gnome-schema icon-theme 'Papirus-Dark' gsettings set $gnome-schema cursor-theme 'Adwaita' gsettings set $gnome-schema font-name 'ibm-plex 12' diff --git a/.config/sway/config.d/themes/light b/.config/sway/conf.d/themes/light similarity index 100% rename from .config/sway/config.d/themes/light rename to .config/sway/conf.d/themes/light diff --git a/.config/sway/config b/.config/sway/config index a5d2b0a..e2badd0 100644 --- a/.config/sway/config +++ b/.config/sway/config @@ -1,7 +1,5 @@ -include ~/.config/sway/config.d/display -include ~/.config/sway/config.d/theme -include ~/.config/sway/config.d/keybinds -include ~/.config/sway/config.d/custom -include ~/.config/sway/config.d/exec - -exec kitty +include ~/.config/sway/conf.d/display +include ~/.config/sway/conf.d/theme +include ~/.config/sway/conf.d/keybinds +include ~/.config/sway/conf.d/custom +include ~/.config/sway/conf.d/exec diff --git a/.config/sway/config.d/custom b/.config/sway/config.d/custom deleted file mode 100644 index 6023060..0000000 --- a/.config/sway/config.d/custom +++ /dev/null @@ -1,3 +0,0 @@ -# vim: filetype=swayconfig - -include ~/.config/sway/config.d/custom.d/* diff --git a/.config/sway/config.d/theme b/.config/sway/config.d/theme deleted file mode 100644 index eb8f44c..0000000 --- a/.config/sway/config.d/theme +++ /dev/null @@ -1,3 +0,0 @@ -# vim: filetype=swayconfig - -include ~/.config/sway/config.d/themes/dark diff --git a/.config/sway/scripts/boxshadow.sh b/.config/sway/scripts/boxshadow.sh deleted file mode 100755 index 719548e..0000000 --- a/.config/sway/scripts/boxshadow.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# Take $1 as input, add a box shadow, output to $2 - -# you can change background color here -background_color=none - -convert $1 \ - \( -clone 0 -background black -shadow 40x5+12+16 \) \ - \( -clone 0 -background black -shadow 40x5-4-4 \) \ - \( -clone 0 -background black -shadow 40x12+12-4 \) \ - \( -clone 0 -background black -shadow 40x12-4+16 \) \ - -reverse -background $background_color -layers merge +repage \ - $2 diff --git a/.config/sway/scripts/grimshot-ui.sh b/.config/sway/scripts/grimshot-ui.sh deleted file mode 100755 index 33b2b3d..0000000 --- a/.config/sway/scripts/grimshot-ui.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -SCRIPT_LOC=~/.config/sway/scripts/ -FOLDER=~/Pictures/Screenshots/ -# FILE="/tmp/share/screenshots/`date +'%y%m%d%H%M.png'`" -FILE="$FOLDER`date +'%y%m%d%H%M.png'`" - -action=`echo -e "copy\nsave" | wofi -d -Oalphabetical --prompt="Select your action"` -target=`echo -e "active\nscreen\noutput\narea\nwindow" | wofi -d -Oalphabetical --prompt="Select the target"` - -test $action || exit -test $target || exit - -# test -d /tmp/share/screenshot || mkdir -p /tmp/share/screenshots - -~/.config/sway/scripts/grimshot.sh --notify $action $target $FILE - -if [ $target = "active" ] || [ $target = "window" ] || [ $target = "area" ] -then - $SCRIPT_LOC/boxshadow.sh "$FILE" "$FILE" || die "Unable to save screenshot" - echo -e "saved file" -fi diff --git a/.config/sway/scripts/grimshot.sh b/.config/sway/scripts/grimshot.sh deleted file mode 100755 index 7b65c9c..0000000 --- a/.config/sway/scripts/grimshot.sh +++ /dev/null @@ -1,156 +0,0 @@ -#!/bin/sh - -## TAKEN FROM https://github.com/swaywm/sway/blob/master/contrib/grimshot -## -## Grimshot: a helper for screenshots within sway -## Requirements: -## - `grim`: screenshot utility for wayland -## - `slurp`: to select an area -## - `swaymsg`: to read properties of current window -## - `wl-copy`: clipboard utility -## - `jq`: json utility to parse swaymsg output -## - `notify-send`: to show notifications -## Those are needed to be installed, if unsure, run `grimshot check` -## -## See `man 1 grimshot` or `grimshot usage` for further details. - -getTargetDirectory() { - test -f ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs && \ - . ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs - - echo ${XDG_SCREENSHOTS_DIR:-${XDG_PICTURES_DIR:-$HOME}} -} - -if [ "$1" = "--notify" ]; then - NOTIFY=yes - shift 1 -else - NOTIFY=no -fi - -ACTION=${1:-usage} -SUBJECT=${2:-screen} -FILE=${3:-$(getTargetDirectory)/$(date +'%y%m%d%H%M.png')} - -if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "check" ]; then - echo "Usage:" - echo " grimshot [--notify] (copy|save) [active|screen|output|area|window] [FILE|-]" - echo " grimshot check" - echo " grimshot usage" - echo "" - echo "Commands:" - echo " copy: Copy the screenshot data into the clipboard." - echo " save: Save the screenshot to a regular file or '-' to pipe to STDOUT." - echo " check: Verify if required tools are installed and exit." - echo " usage: Show this message and exit." - echo "" - echo "Targets:" - echo " active: Currently active window." - echo " screen: All visible outputs." - echo " output: Currently active output." - echo " area: Manually select a region." - echo " window: Manually select a window." - exit -fi - -notify() { - notify-send -t 3000 -a grimshot "$@" -} -notifyOk() { - [ "$NOTIFY" = "no" ] && return - - TITLE=${2:-"Screenshot"} - MESSAGE=${1:-"OK"} - notify-send "$TITLE" "$MESSAGE" -} -notifyError() { - if [ $NOTIFY = "yes" ]; then - TITLE=${2:-"Screenshot"} - MESSAGE=${1:-"Error taking screenshot with grim"} - notify -u critical "$TITLE" "$MESSAGE" - else - echo $1 - fi -} - -die() { - MSG=${1:-Bye} - notifyError "Error: $MSG" - exit 2 -} - -check() { - COMMAND=$1 - if command -v "$COMMAND" > /dev/null 2>&1; then - RESULT="OK" - else - RESULT="NOT FOUND" - fi - echo " $COMMAND: $RESULT" -} - -takeScreenshot() { - FILE=$1 - GEOM=$2 - OUTPUT=$3 - if [ ! -z "$OUTPUT" ]; then - grim -o "$OUTPUT" "$FILE" || die "Unable to invoke grim" - elif [ -z "$GEOM" ]; then - grim "$FILE" || die "Unable to invoke grim" - else - grim -g "$GEOM" "$FILE" || die "Unable to invoke grim" - fi -} - -if [ "$ACTION" = "check" ] ; then - echo "Checking if required tools are installed. If something is missing, install it to your system and make it available in PATH..." - check grim - check slurp - check swaymsg - check wl-copy - check jq - check notify-send - exit -elif [ "$SUBJECT" = "area" ] ; then - GEOM=$(slurp -d) - # Check if user exited slurp without selecting the area - if [ -z "$GEOM" ]; then - exit 1 - fi - WHAT="Area" -elif [ "$SUBJECT" = "active" ] ; then - FOCUSED=$(swaymsg -t get_tree | jq -r 'recurse(.nodes[]?, .floating_nodes[]?) | select(.focused)') - GEOM=$(echo "$FOCUSED" | jq -r '.rect | "\(.x),\(.y) \(.width)x\(.height)"') - APP_ID=$(echo "$FOCUSED" | jq -r '.app_id') - WHAT="$APP_ID window" -elif [ "$SUBJECT" = "screen" ] ; then - GEOM="" - WHAT="Screen" -elif [ "$SUBJECT" = "output" ] ; then - GEOM="" - OUTPUT=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused)' | jq -r '.name') - WHAT="$OUTPUT" -elif [ "$SUBJECT" = "window" ] ; then - GEOM=$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp) - # Check if user exited slurp without selecting the area - if [ -z "$GEOM" ]; then - exit 1 - fi - WHAT="Window" -else - die "Unknown subject to take a screen shot from" "$SUBJECT" -fi - -if [ "$ACTION" = "copy" ] ; then - takeScreenshot - "$GEOM" "$OUTPUT" | wl-copy --type image/png || die "Clipboard error" - notifyOk "$WHAT copied to buffer" -else - if takeScreenshot "$FILE" "$GEOM" "$OUTPUT"; then - TITLE="Screenshot of $SUBJECT" - MESSAGE=$(basename "$FILE") - notifyOk "$MESSAGE" "$TITLE" - echo $FILE - else - notifyError "Error taking screenshot with grim" - fi -fi diff --git a/.config/sway/scripts/logout.sh b/.config/sway/scripts/logout.sh index 49154c7..e4ee1e3 100755 --- a/.config/sway/scripts/logout.sh +++ b/.config/sway/scripts/logout.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Modified from sway's locking script @@ -8,7 +8,8 @@ if [[ ! $(which swayidle 2> /dev/null) ]]; then exit 1 fi -choice=$(echo -e "suspend\nshutdown\npoweroff\nreboot\nlock" | wofi -d --prompt "󰚥 Choose power option" -Oalphabetical) +choices=("suspend" "shutdown" "poweroff" "reboot" "lock") +choice=$(printf "%s\n" "${choices[@]}" | wofi -d --prompt "󰚥 Choose power option" -Oalphabetical ) if test "$choice" = lock ; then diff --git a/.config/sway/scripts/themes.sh b/.config/sway/scripts/themes.sh index 90dbe5d..3484182 100755 --- a/.config/sway/scripts/themes.sh +++ b/.config/sway/scripts/themes.sh @@ -10,7 +10,7 @@ else fi sed -i $command ~/.config/kitty/kitty.conf -sed -i $command ~/.config/sway/config.d/theme +sed -i $command ~/.config/sway/conf.d/theme sed -i $command ~/.config/swaync/style.css sed -i $command ~/.config/waybar/style.css sed -i $command ~/.config/wofi/config diff --git a/.zshrc b/.zshrc index f7dd10e..dbbe4bb 100644 --- a/.zshrc +++ b/.zshrc @@ -135,3 +135,6 @@ export MANPATH="${MANPATH}:${HOME}/.local/share/man" #ccache support export USE_CCACHE=1 export PATH="/usr/lib/ccache/bin${PATH:+:}$PATH" + +# ssh-agent +export SSH_AUTH_SOCK=$XDG_RUNTIME_DIR/ssh-agent.socket