From 2ac99db38bfa15cf11058e5399b4b40bf472ad88 Mon Sep 17 00:00:00 2001 From: Mark Riedesel Date: Wed, 12 Jun 2024 11:42:25 -0500 Subject: [PATCH] add a bunch of sway stuff --- .config/kitty/kitty.conf | 15 +++ .config/sway/autostart | 50 +++++++++ .config/sway/config | 8 ++ .config/sway/config.d/10-service.conf | 10 ++ .config/sway/config.d/50-systemd-user.conf | 16 +++ .config/sway/definitions | 120 +++++++++++++++++++++ .config/sway/modes/default | 103 ++++++++++++++++++ .config/sway/modes/recording | 19 ++++ .config/sway/modes/resize | 17 +++ .config/sway/modes/screenshot | 20 ++++ .config/sway/modes/shutdown | 34 ++++++ .config/sway/scripts/brightness.sh | 25 +++++ .config/sway/scripts/recorder.sh | 44 ++++++++ .config/sway/scripts/scale.sh | 32 ++++++ .config/user-dirs.dirs | 8 ++ 15 files changed, 521 insertions(+) create mode 100644 .config/kitty/kitty.conf create mode 100644 .config/sway/autostart create mode 100644 .config/sway/config create mode 100644 .config/sway/config.d/10-service.conf create mode 100644 .config/sway/config.d/50-systemd-user.conf create mode 100644 .config/sway/definitions create mode 100644 .config/sway/modes/default create mode 100644 .config/sway/modes/recording create mode 100644 .config/sway/modes/resize create mode 100644 .config/sway/modes/screenshot create mode 100644 .config/sway/modes/shutdown create mode 100755 .config/sway/scripts/brightness.sh create mode 100755 .config/sway/scripts/recorder.sh create mode 100755 .config/sway/scripts/scale.sh diff --git a/.config/kitty/kitty.conf b/.config/kitty/kitty.conf new file mode 100644 index 0000000..402d07a --- /dev/null +++ b/.config/kitty/kitty.conf @@ -0,0 +1,15 @@ +font_family Envy Code R +bold_font Envy Code R Bold +italic_font Envy Code R Italic +# font_family Meslo LG L DZ Nerd Font Mono +italic_font auto +bold_font auto +bold_italic_font auto + +font_size 12.0 + +window_padding_width 2.0 +term xterm-256color +enable_audio_bell no +sync_to_monitor yes +background_opacity 0.99 diff --git a/.config/sway/autostart b/.config/sway/autostart new file mode 100644 index 0000000..3e40557 --- /dev/null +++ b/.config/sway/autostart @@ -0,0 +1,50 @@ +# units + +set $initialize_foot_server '[ -x "$(command -v foot)" ] && systemctl --now --user enable foot-server.socket && systemctl --now --user enable foot-server' +set $initialize_swayr_daemon '[ -x "$(command -v swayrd)" ] && systemctl --now --user enable swayrd' +set $initialize_waybar '[ -x "$(command -v waybar)" ] && (pkill waybar || exit 0) && systemctl --now --user enable waybar && (systemctl --user start waybar || /usr/share/sway/scripts/waybar.sh)' +set $initialize_workspace_icons '[ -x "$(command -v sworkstyle)" ] && systemctl --now --user enable sworkstyle' +set $initialize_poweralert_daemon '[ -x "$(command -v poweralertd)" ] && systemctl --now --user enable poweralertd' +set $initialize_idlehack_daemon '[ -x "$(command -v idlehack)" ] && systemctl --now --user enable idlehack' +set $initialize_mounting_daemon '[ -x "$(command -v pcmanfm)" ] && systemctl --now --user enable pcmanfm' +set $initialize_way_displays '[ -x "$(command -v way-displays)" ] && systemctl --now --user enable way-displays' + +# autostarts + +set $autostart_dex '[ -x "$(command -v dex)" ] && gdbus wait --session org.kde.StatusNotifierWatcher && dex -a -e SWAY' +set $flashfocus '[ -x "$(command -v flashfocus)" ] && flashfocus' +set $wlsunset '[ -x "$(command -v wlsunset)" ] && /usr/share/sway/scripts/sunset.sh "on"' +set $autotiling '[ -x "$(command -v autotiling)" ] && autotiling || [ -x "$(command -v autotiling-rs)" ] && autotiling-rs' +set $help_menu '[ -x "$(command -v nwg-wrapper)" ] && [ -f $HOME/.config/nwg-wrapper/help.sh ] && /usr/share/sway/scripts/help.sh' +set $kanshi '[ -x "$(command -v kanshi)" ] && pkill -x kanshi; exec kanshi' +set $xdg-dirs '[ -x "$(command -v xdg-user-dirs-update)" ] && exec xdg-user-dirs-update' + +## apply the keyboard layout from localectl if no keyboard layout has been set via config.d +set $auto_xdg_keyboard 'grep -q xkb_layout ~/.config/sway/config.d/*.conf || /usr/share/sway/scripts/keyboard.sh' +set $update_rofi_theme 'mkdir -p $HOME/.config/rofi/ && echo $rofi_theme > $HOME/.config/rofi/Manjaro.rasi' +set $create_rofi_config 'mkdir -p $HOME/.config/rofi/ && cp -n /usr/share/sway/templates/rofi/config.rasi $HOME/.config/rofi/config.rasi' +set $enable_noisetorch '[ -x "$(command -v noisetorch)" ] && noisetorch -u && noisetorch -i' +set $swayidle swayidle -w \ + timeout $idle_timeout 'brightnessctl -s && brightnessctl set 10' \ + resume 'brightnessctl -r' \ + timeout $locking_timeout 'exec $locking' \ + timeout $screen_timeout '/usr/share/sway/scripts/keyboard-backlight-switch.sh off && swaymsg "output * dpms off"' \ + resume '/usr/share/sway/scripts/keyboard-backlight-switch.sh on && swaymsg "output * dpms on"' \ + timeout $sleep_timeout_bat '[ "$(acpi -b | grep Discharging)" != "" ] && systemctl suspend' \ + timeout $sleep_timeout_ac '[ "$(acpi -b | grep Discharging)" = "" ] && systemctl suspend' \ + before-sleep 'playerctl pause' \ + before-sleep 'exec $locking & sleep $sleep_delay' \ + after-resume '/usr/share/sway/scripts/keyboard-backlight-switch.sh on && swaymsg "output * dpms on" && brightnessctl -r' +set $disable_nm_applet_autostart '[ -x "$(command -v nm-applet)" ] && [ ! -f $HOME/.config/autostart/nm-applet.desktop ] && cp /etc/xdg/autostart/nm-applet.desktop $HOME/.config/autostart/nm-applet.desktop && echo "Hidden=true" >> $HOME/.config/autostart/nm-applet.desktop' +set $apply_background swaymsg 'output * bg $background fill' + +## daemons + +set $mako '[ -x "$(command -v mako)" ] && pkill -x mako; /usr/share/sway/scripts/mako.sh --font "$term-font" --text-color "$text-color" --border-color "$accent-color" --background-color "$background-color" --border-size 3 --width 400 --height 200 --padding 20 --margin 20 --default-timeout 15000' +set $swappy_notify '[ -x "$(command -v swappy)" ] && /usr/share/sway/scripts/screenshot-notify.sh' +set $cliphist_watch '[ -x "$(command -v wl-paste)" ] && [ -x "$(command -v cliphist)" ] && wl-paste --watch waybar-signal clipboard' +set $cliphist_store '[ -x "$(command -v wl-paste)" ] && [ -x "$(command -v cliphist)" ] && wl-paste --watch cliphist store' +set $clip-persist '[ -x "$(command -v wl-clip-persist)" ] && pkill -x wl-clip-persist; wl-clip-persist --clipboard regular --all-mime-type-regex \'(?i)^(?!image/x-inkscape-svg).+\'' +set $calendar_daemon 'calcurse --daemon' +set $nm_applet '[ -x "$(command -v nm-applet)" ] && pkill -x nm-applet && dbus-launch nm-applet' +set $watch_playerctl '[ -x "$(command -v playerctl)" ] && pkill -x playerctl; playerctl -a metadata --format \"{{status}} {{title}}\" --follow | while read line; do waybar-signal playerctl; waybar-signal idle; done' diff --git a/.config/sway/config b/.config/sway/config new file mode 100644 index 0000000..6bb4781 --- /dev/null +++ b/.config/sway/config @@ -0,0 +1,8 @@ +set $sway-scripts-dir $HOME/.config/sway/scripts + +include "$HOME/.config/sway/definitions" +include "$HOME/.config/sway/definitions.d/*.conf" +include "$HOME/.config/sway/autostart" +include "$HOME/.config/sway/modes/*" +include "$HOME/.config/sway/config.d/*.conf" +include "$HOME/.config/sway/hosts/`hostname`" diff --git a/.config/sway/config.d/10-service.conf b/.config/sway/config.d/10-service.conf new file mode 100644 index 0000000..dc2a343 --- /dev/null +++ b/.config/sway/config.d/10-service.conf @@ -0,0 +1,10 @@ +# Import variables set-up by sway into the environment and notify systemd that +# sway is ready. +exec test -n "$$NOTIFY_SOCKET" \ + && systemctl --user import-environment SWAYSOCK \ + DISPLAY \ + I3SOCK \ + WAYLAND_DISPLAY \ + XCURSOR_SIZE \ + XCURSOR_THEME \ + && systemd-notify --ready diff --git a/.config/sway/config.d/50-systemd-user.conf b/.config/sway/config.d/50-systemd-user.conf new file mode 100644 index 0000000..8781db9 --- /dev/null +++ b/.config/sway/config.d/50-systemd-user.conf @@ -0,0 +1,16 @@ +# sway does not set DISPLAY/WAYLAND_DISPLAY in the systemd user environment +# See FS#63021 +# Adapted from xorg's 50-systemd-user.sh, which achieves a similar goal. + +# Upstream refuses to set XDG_CURRENT_DESKTOP so we have to. +exec systemctl --user set-environment XDG_CURRENT_DESKTOP=sway +exec systemctl --user import-environment DISPLAY \ + SWAYSOCK \ + WAYLAND_DISPLAY \ + XDG_CURRENT_DESKTOP + +exec hash dbus-update-activation-environment 2>/dev/null && \ + dbus-update-activation-environment --systemd DISPLAY \ + SWAYSOCK \ + XDG_CURRENT_DESKTOP=sway \ + WAYLAND_DISPLAY diff --git a/.config/sway/definitions b/.config/sway/definitions new file mode 100644 index 0000000..a04fb7e --- /dev/null +++ b/.config/sway/definitions @@ -0,0 +1,120 @@ +# shellcheck disable=SC2148,SC2086,SC2154,SC2046,SC2016 +### Variables +# +# Logo key. Use Mod1 for Alt and Mod4 for Super. +set $mod Mod4 +set $alt_mod Mod1 + +# Direction keys +set $left Left +set $down Down +set $up Up +set $right Right + +# Alternative direction keys +set $left_alt h +set $down_alt j +set $up_alt k +set $right_alt l + +# Support non-latin layouts +set $bindsym bindsym --to-code +set $unbindsym unbindsym --to-code + +# Your preferred terminal emulator +set $term kitty +set $term_cwd $term -D "$(swaycwd 2>/dev/null || echo $HOME)" + +# onscreen bar +set $onscreen_bar /usr/share/sway/scripts/wob.sh "$accent-color" "$background-color" + +# brightness control +set $brightness /usr/share/sway/scripts/brightness.sh +set $brightness_up $brightness up | $onscreen_bar +set $brightness_down $brightness down | $onscreen_bar + +# scaling +set $scale_up $sway-scripts-dir/scale.sh up +set $scale_down $sway-scripts-dir/scale.sh down + +# audio control +set $sink_volume pactl get-sink-volume @DEFAULT_SINK@ | grep '^Volume:' | cut -d / -f 2 | tr -d ' ' | sed 's/%//' +set $source_volume pactl get-source-volume @DEFAULT_SOURCE@ | grep '^Volume:' | cut -d / -f 2 | tr -d ' ' | sed 's/%//' +set $volume_down $onscreen_bar $(pactl set-sink-volume @DEFAULT_SINK@ -5% && $sink_volume) +set $volume_up $onscreen_bar $(pactl set-sink-volume @DEFAULT_SINK@ +5% && $sink_volume) +set $volume_mute $onscreen_bar $(pactl set-sink-mute @DEFAULT_SINK@ toggle && pactl get-sink-mute @DEFAULT_SINK@ | sed -En "/no/ s/.*/$($sink_volume)/p; /yes/ s/.*/0/p") +set $mic_mute $onscreen_bar $(pactl set-source-mute @DEFAULT_SOURCE@ toggle && pactl get-source-mute @DEFAULT_SOURCE@ | sed -En "/no/ s/.*/$($source_volume)/p; /yes/ s/.*/0/p") + +# rofi theme +set $rofi_theme "* {\nlightbg: $background-color;\nbackground: $background-color;\nlightfg: $accent-color;\nforeground: $text-color;\n}\nwindow {\nwidth: 25em;\n}\n" + +# clipboard history +set $clipboard cliphist list | rofi -dmenu -font "$gui-font" -p "Select item to copy" -lines 10 | cliphist decode | wl-copy +set $clipboard-del cliphist list | rofi -dmenu -font "$gui-font" -p "Select item to delete" -lines 10 | cliphist delete + +# zeit tracking +set $zeit_list zeit list --only-projects-and-tasks --append-project-id-to-task | rofi -dmenu -font "$gui-font" -p "Select task to track" -lines 10 | /usr/share/sway/scripts/zeit.sh track && waybar-signal zeit + +# Your preferred application launcher +set $menu rofi -show combi -combi-modi "drun,run" -terminal "$term" -ssh-command "{terminal} {ssh-client} {host} [-p {port}]" -run-shell-command "{terminal} {cmd}" -show-icons -font "$gui-font" -lines 10 + +### Lockscreen configuration +set $locking swaylock --daemonize --color "$selection-color" --inside-color "$selection-color" --inside-clear-color "$text-color" --ring-color "$color2" --ring-clear-color "$color11" --ring-ver-color "$color13" --show-failed-attempts --fade-in 0.2 --grace 2 --effect-vignette 0.5:0.5 --effect-blur 7x5 --ignore-empty-password --screenshots --clock + +# bluetooth menu +set $bluetooth $once $term_float bluetuith + +### Idle configuration +# This will lock your screen after 300 seconds of inactivity, then turn off +# your displays after another 300 seconds, and turn your screens back on when +# resumed. It will also lock your screen before your computer goes to sleep. +# +set $idle_timeout 240 +set $locking_timeout 300 +set $screen_timeout 600 +set $sleep_timeout_bat 900 +set $sleep_timeout_ac 3600 +set $sleep_delay 2 + +### Autostart applications definition. Can be removed soon-ish as it is being imported in userspace. +include /etc/sway/autostart + +# hide cursor after 5 seconds of inactivty +seat seat0 hide_cursor 5000 + +# pulseaudio command +set $pulseaudio $once $term_float pulsemixer + +# help command +set $help /usr/share/sway/scripts/help.sh --toggle + +# calendar application +set $calendar $once $term_float calcurse + +# workspace names +set $ws1 number 1 +set $ws2 number 2 +set $ws3 number 3 +set $ws4 number 4 +set $ws5 number 5 +set $ws6 number 6 +set $ws7 number 7 +set $ws8 number 8 +set $ws9 number 9 +set $ws10 number 10 + +# screenshot +set $grimshot grimshot +set $pipe_output $grimshot save output - +set $pipe_selection $grimshot save area - +set $notify_paste [[ $(wl-paste -l) == "image/png" ]] && notify-send "Screenshot copied to clipboard" +set $swappy swappy -f - +set $upload_pipe curl -s -F "file=@-;filename=.png" https://x0.at/ | tee >(wl-copy) >(xargs notify-send) + +set $screenshot_screen $pipe_output | $swappy && $notify_paste +set $screenshot_screen_upload $pipe_output | $upload_pipe + +set $screenshot_selection $pipe_selection | $swappy && $notify_paste +set $screenshot_selection_upload $pipe_selection | $upload_pipe + +set $update-manager '/usr/share/sway/scripts/checkupdates.sh upgrade' diff --git a/.config/sway/modes/default b/.config/sway/modes/default new file mode 100644 index 0000000..18086c0 --- /dev/null +++ b/.config/sway/modes/default @@ -0,0 +1,103 @@ +# quick-launch +$bindsym $mod+Return exec kitty +$bindsym $mod+Home exec thunar +$bindsym $mod+b exec firefox +$bindsym $mod+d exec --no-startup-id ~/bin/launcher + +# quick-access screenshot +$bindsym $mod+g exec $screenshot_selection +$bindsym $mod+Shift+g exec $screenshot_selection + +# session actions +$bindsym $mod+Shift+c reload +$bindsym $mod+Shift+r restart + +# window bindings and behavior +floating_modifier $mod +focus_follows_mouse no + +# kill focused window +$bindsym $mod+Shift+q kill + +# move window focus (Vim style) +$bindsym $mod+h focus left +$bindsym $mod+j focus down +$bindsym $mod+k focus up +$bindsym $mod+l focus right + +# move window focus (with arrow keys) +$bindsym $mod+Left focus left +$bindsym $mod+Down focus down +$bindsym $mod+Up focus up +$bindsym $mod+Right focus right + +# move window (Vim style) +$bindsym $mod+Shift+h move left +$bindsym $mod+Shift+j move down +$bindsym $mod+Shift+k move up +$bindsym $mod+Shift+l move right + +# move window (with arrow keys) +$bindsym $mod+Shift+Left move left +$bindsym $mod+Shift+Down move down +$bindsym $mod+Shift+Up move up +$bindsym $mod+Shift+Right move right + +# container layout (stacked, tabbed, toggle split) +$bindsym $mod+s layout stacking +$bindsym $mod+w layout tabbed +$bindsym $mod+e layout toggle split + +# splits +$bindsym $mod+u split h +$bindsym $mod+i split v + +# fullscreen +$bindsym $mod+f fullscreen + +# toggle tiling/floating +$bindsym $mod+Shift+space floating toggle + +# toggle focus between tiling/floating +$bindsym $mod+space focus mode_toggle + +# focus parent container +$bindsym $mod+a focus parent + +# switch to specific workspace +$bindsym $mod+1 workspace 1 +$bindsym $mod+2 workspace 2 +$bindsym $mod+3 workspace 3 +$bindsym $mod+4 workspace 4 +$bindsym $mod+5 workspace 5 +$bindsym $mod+6 workspace 6 +$bindsym $mod+7 workspace 7 +$bindsym $mod+8 workspace 8 +$bindsym $mod+9 workspace 9 +$bindsym $mod+0 workspace 10 + +# move focused container to workspace +$bindsym $mod+Shift+1 move container to workspace 1 +$bindsym $mod+Shift+2 move container to workspace 2 +$bindsym $mod+Shift+3 move container to workspace 3 +$bindsym $mod+Shift+4 move container to workspace 4 +$bindsym $mod+Shift+5 move container to workspace 5 +$bindsym $mod+Shift+6 move container to workspace 6 +$bindsym $mod+Shift+7 move container to workspace 7 +$bindsym $mod+Shift+8 move container to workspace 8 +$bindsym $mod+Shift+9 move container to workspace 9 +$bindsym $mod+Shift+0 move container to workspace 10 + +# move focus to adjacent output +$bindsym $mod+bracketleft focus output left +$bindsym $mod+bracketright focus output right + +# jump to workspace on same output +$bindsym $mod+Shift+bracketleft workspace prev_on_output +$bindsym $mod+Shift+bracketright workspace next_on_output + +# scale entire display +$bindsym $alt_mod+plus exec $scale_up +$bindsym $alt_mod+minus exec $scale_down + +$bindsym $mod+Shift+i exec inhibit-idle interactive diff --git a/.config/sway/modes/recording b/.config/sway/modes/recording new file mode 100644 index 0000000..666ac38 --- /dev/null +++ b/.config/sway/modes/recording @@ -0,0 +1,19 @@ +set $mode_recording " \ +Record (r) \ ++ [Shift for 󰍮]" + +set $recorder /usr/share/sway/scripts/recorder.sh + +mode --pango_markup $mode_recording { + $bindsym r exec $recorder, mode "default" + $bindsym Shift+r exec $recorder -a, mode "default" + + # Return to default mode. + $bindsym Escape mode "default" +} + +## Launch // Recording Mode ## +$bindsym $mod+Shift+r mode $mode_recording + +## Launch // Stop Recording Mode ## +$bindsym $mod+Escape exec killall -s SIGINT wf-recorder \ No newline at end of file diff --git a/.config/sway/modes/resize b/.config/sway/modes/resize new file mode 100644 index 0000000..538aa74 --- /dev/null +++ b/.config/sway/modes/resize @@ -0,0 +1,17 @@ +mode "resize" { + $bindsym h resize shrink width 10 px or 10 ppt + $bindsym j resize grow height 10 px or 10 ppt + $bindsym k resize shrink height 10 px or 10 ppt + $bindsym l resize grow width 10 px or 10 ppt + + # same bindings, but for the arrow keys + $bindsym Left resize shrink width 10 px or 10 ppt + $bindsym Down resize grow height 10 px or 10 ppt + $bindsym Up resize shrink height 10 px or 10 ppt + $bindsym Right resize grow width 10 px or 10 ppt + + # back to normal: Enter or Escape + $bindsym Return mode "default" + $bindsym Escape mode "default" +} +$bindsym $mod+r mode "resize" diff --git a/.config/sway/modes/screenshot b/.config/sway/modes/screenshot new file mode 100644 index 0000000..1cb1c90 --- /dev/null +++ b/.config/sway/modes/screenshot @@ -0,0 +1,20 @@ +set $mode_screenshot "󰄄 \ +Pick (p) \ +Output (o) \ ++ Shift for " + +mode --pango_markup $mode_screenshot { + # output = currently active output + $bindsym o mode "default", exec $screenshot_screen + $bindsym Shift+o mode "default", exec $screenshot_screen_upload + + # pick the region to screenshot + $bindsym p mode "default", exec $screenshot_selection + $bindsym Shift+p mode "default", exec $screenshot_selection_upload + + # Return to default mode. + $bindsym Escape mode "default" +} + +## Launch // Screenshot Mode ## +$bindsym Print mode $mode_screenshot diff --git a/.config/sway/modes/shutdown b/.config/sway/modes/shutdown new file mode 100644 index 0000000..48f446a --- /dev/null +++ b/.config/sway/modes/shutdown @@ -0,0 +1,34 @@ +set $mode_shutdown "\ + \ + \ +(l)lock \ +(e)logout \ +(r)reboot \ +(u)suspend \ +(s)shutdown \ +" + +set $purge_cliphist [ $purge_cliphist_logout == 'true' ] && rm -f $HOME/.cache/cliphist/db || exit 0 + +mode --pango_markup $mode_shutdown { + # lock + $bindsym l mode "default", exec $locking + + # logout + $bindsym e exec $purge_cliphist; exec swaymsg exit + + # suspend + $bindsym u mode "default", exec systemctl suspend + + # shutdown + $bindsym s exec $purge_cliphist; exec systemctl poweroff + + # reboot + $bindsym r exec $purge_cliphist; exec systemctl reboot + + # Return to default mode. + $bindsym Escape mode "default" +} + +## Launch // Exit Menu ## +$bindsym $mod+Shift+e mode $mode_shutdown diff --git a/.config/sway/scripts/brightness.sh b/.config/sway/scripts/brightness.sh new file mode 100755 index 0000000..281918e --- /dev/null +++ b/.config/sway/scripts/brightness.sh @@ -0,0 +1,25 @@ +#!/bin/sh +current_abs=$(brightnessctl get) +current_rel() { + echo "$(brightnessctl get) * 100 / $(brightnessctl max)" | bc +} +max=$(brightnessctl max) +factor=3 +brightness_step=$((max * factor / 100 < 1 ? 1 : max * factor / 100)) + +case $1'' in +'') ;; +'down') + # if current value <= 3% and absolute value != 1, set brightness to absolute 1 + if [ "$(current_rel)" -le "$factor" ] && [ "$current_abs" -ge 0 ]; then + brightnessctl --quiet set 1 + else + brightnessctl --quiet set "${brightness_step}-" + fi + ;; +'up') + brightnessctl --quiet set "${brightness_step}+" + ;; +esac + +current_rel diff --git a/.config/sway/scripts/recorder.sh b/.config/sway/scripts/recorder.sh new file mode 100755 index 0000000..ac92463 --- /dev/null +++ b/.config/sway/scripts/recorder.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env sh +set -x + +pgrep wf-recorder +status=$? + +countdown() { + notify "Recording in 3 seconds" -t 1000 + sleep 1 + notify "Recording in 2 seconds" -t 1000 + sleep 1 + notify "Recording in 1 seconds" -t 1000 + sleep 1 +} + +notify() { + line=$1 + shift + notify-send "Recording" "${line}" -i /usr/share/icons/Papirus-Dark/32x32/devices/camera-video.svg $* +} + +if [ $status != 0 ]; then + target_path=$(xdg-user-dir SCREENSHOT) + timestamp=$(date +'recording_%Y%m%d-%H%M%S') + + notify "Select a region to record" -t 1000 + area=$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp) + + countdown + (sleep 0.5 && waybar-signal recorder) & + + if [ "$1" = "-a" ]; then + file="$target_path/$timestamp.mp4" + wf-recorder --audio -g "$area" --file="$file" + else + file="$target_path/$timestamp.webm" + wf-recorder -g "$area" -c libvpx --codec-param="qmin=0" --codec-param="qmax=25" --codec-param="crf=4" --codec-param="b:v=1M" --file="$file" + fi + + waybar-signal recorder && notify "Finished recording ${file}" +else + pkill -x --signal SIGINT wf-recorder + waybar-signal recorder +fi diff --git a/.config/sway/scripts/scale.sh b/.config/sway/scripts/scale.sh new file mode 100755 index 0000000..134e94c --- /dev/null +++ b/.config/sway/scripts/scale.sh @@ -0,0 +1,32 @@ +#!/bin/sh +make=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused==true) | .make') +model=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused==true) | .model') +name=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused==true) | .name') +current_screen="$make $model ($name)" + +increment=0.1 + +current_scale() { + swaymsg -t get_outputs | jq -r '.[] | select(.focused==true) | .scale' +} + +next_scale=$(current_scale) + +scale() { + [ -x "$(command -v way-displays)" ] && way-displays -s SCALE "$current_screen" $next_scale && way-displays -w || swaymsg output "\"$name\"" scale "$next_scale" +} + +case $1'' in +'') + current_scale +;; +'up') + next_scale=$(echo "$(current_scale) + $increment" | bc) + scale + ;; +'down') + next_scale=$(echo "$(current_scale) - $increment" | bc) + scale + ;; +esac + diff --git a/.config/user-dirs.dirs b/.config/user-dirs.dirs index 6917d4e..13699fe 100644 --- a/.config/user-dirs.dirs +++ b/.config/user-dirs.dirs @@ -1,3 +1,10 @@ +# This file is written by xdg-user-dirs-update +# If you want to change or add directories, just edit the line you're +# interested in. All local changes will be retained on the next run. +# Format is XDG_xxx_DIR="$HOME/yyy", where yyy is a shell-escaped +# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an +# absolute path. No other format is supported. +# XDG_DESKTOP_DIR="$HOME/desktop" XDG_DOWNLOAD_DIR="$HOME/downloads" XDG_TEMPLATES_DIR="$HOME/templates" @@ -7,3 +14,4 @@ XDG_MUSIC_DIR="$HOME/media/music" XDG_PICTURES_DIR="$HOME/media/pictures" XDG_VIDEOS_DIR="$HOME/media/videos" XDG_CACHE_DIR="$HOME/.cache" +XDG_SCREENSHOT_DIR="$HOME/screenshots"