i3 screenshots add script and notifications on screenshots
This commit is contained in:
parent
247fc36d98
commit
a10f949729
@ -11,7 +11,7 @@ ssh:
|
|||||||
git:.config/git
|
git:.config/git
|
||||||
ranger:.config/ranger
|
ranger:.config/ranger
|
||||||
gpg:
|
gpg:
|
||||||
i3:.xinitrc .xprofile .Xresources .config/i3 .config/i3status .local/bin/i3status_wrapper .config/rofi .config/picom .local/bin/slm .local/bin/slm_rofi.sh .local/bin/power_rofi.sh .local/bin/i3_switch_workspace.sh .config/mimeapps.list
|
i3:.xinitrc .xprofile .Xresources .config/i3 .config/i3status .local/bin/i3status_wrapper .config/rofi .config/picom .local/bin/slm .local/bin/slm_rofi.sh .local/bin/power_rofi.sh .local/bin/i3_switch_workspace.sh .config/mimeapps.list .local/bin/screenshot
|
||||||
bat:.config/bat
|
bat:.config/bat
|
||||||
font:
|
font:
|
||||||
termux:.termux
|
termux:.termux
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# screen layout
|
# Screen layout
|
||||||
exec --no-startup-id ~/.screenlayout/default
|
exec --no-startup-id ~/.screenlayout/default
|
||||||
|
|
||||||
for_window [tiling] border pixel 3
|
for_window [tiling] border pixel 3
|
||||||
@ -7,19 +7,26 @@ smart_borders on
|
|||||||
set $mod Mod4
|
set $mod Mod4
|
||||||
|
|
||||||
|
|
||||||
# screensaver
|
# Screensaver
|
||||||
set $i3lock_cmd "i3lock -enf -c 1e1e1e"
|
set $i3lock_cmd "i3lock -enf -c 1e1e1e"
|
||||||
exec --no-startup-id xset s off
|
exec --no-startup-id xset s off
|
||||||
exec --no-startup-id xset +dpms dpms 600 600 600
|
exec --no-startup-id xset +dpms dpms 600 600 600
|
||||||
exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock -enf -c 1e1e1e
|
exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock -enf -c 1e1e1e
|
||||||
|
|
||||||
# hide cursor
|
|
||||||
|
# Notifications
|
||||||
|
#systemctl --user enable --now dbus.service
|
||||||
|
exec --no-startup-id dunst
|
||||||
|
|
||||||
|
|
||||||
|
# Hide cursor
|
||||||
exec --no-startup-id unclutter -idle 0.3 -root
|
exec --no-startup-id unclutter -idle 0.3 -root
|
||||||
|
|
||||||
|
|
||||||
exec_always --no-startup-id xset r rate 250 100
|
exec_always --no-startup-id xset r rate 250 100
|
||||||
exec_always --no-startup-id setxkbmap -model pc105 -layout us,ru -option grp:win_space_toggle -option ctrl:nocaps
|
exec_always --no-startup-id setxkbmap -model pc105 -layout us,ru -option grp:win_space_toggle -option ctrl:nocaps
|
||||||
|
|
||||||
# wallpapers
|
# Wallpapers
|
||||||
exec --no-startup-id nitrogen --restore; sleep 1; picom -b --config ~/.config/picom/picom.conf
|
exec --no-startup-id nitrogen --restore; sleep 1; picom -b --config ~/.config/picom/picom.conf
|
||||||
exec --no-startup-id hsetroot
|
exec --no-startup-id hsetroot
|
||||||
exec --no-startup-id feh --randomize --no-fehbg --bg-scale $HOME/.wallpaper/*
|
exec --no-startup-id feh --randomize --no-fehbg --bg-scale $HOME/.wallpaper/*
|
||||||
@ -27,7 +34,7 @@ exec --no-startup-id feh --randomize --no-fehbg --bg-scale $HOME/.wallpaper/*
|
|||||||
set $font_size 11
|
set $font_size 11
|
||||||
font xft:FiraCode $font_size
|
font xft:FiraCode $font_size
|
||||||
|
|
||||||
# Use pactl to adjust volume in PulseAudio.
|
# use pactl to adjust volume in PulseAudio.
|
||||||
set $refresh_i3status killall -SIGUSR1 i3status
|
set $refresh_i3status killall -SIGUSR1 i3status
|
||||||
bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +10% && $refresh_i3status
|
bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +10% && $refresh_i3status
|
||||||
bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -10% && $refresh_i3status
|
bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -10% && $refresh_i3status
|
||||||
@ -166,41 +173,41 @@ bindsym $mod+Shift+u workspace next
|
|||||||
# resize window (you can also use the mouse for that)
|
# resize window (you can also use the mouse for that)
|
||||||
bindsym $mod+r mode "resize"
|
bindsym $mod+r mode "resize"
|
||||||
mode "resize" {
|
mode "resize" {
|
||||||
bindsym h resize shrink width 10 px or 10 ppt
|
bindsym h resize shrink width 10 px or 10 ppt
|
||||||
bindsym j resize grow height 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 k resize shrink height 10 px or 10 ppt
|
||||||
bindsym l resize grow width 10 px or 10 ppt
|
bindsym l resize grow width 10 px or 10 ppt
|
||||||
|
|
||||||
bindsym $mod+r mode "default"
|
bindsym $mod+r mode "default"
|
||||||
bindsym p mode "resize_precise"
|
bindsym p mode "resize_precise"
|
||||||
|
|
||||||
bindsym Return mode "default"
|
bindsym Return mode "default"
|
||||||
bindsym Escape mode "default"
|
bindsym Escape mode "default"
|
||||||
}
|
}
|
||||||
mode "resize_precise" {
|
mode "resize_precise" {
|
||||||
bindsym h resize shrink width 1 px or 1 ppt
|
bindsym h resize shrink width 1 px or 1 ppt
|
||||||
bindsym j resize grow height 1 px or 1 ppt
|
bindsym j resize grow height 1 px or 1 ppt
|
||||||
bindsym k resize shrink height 1 px or 1 ppt
|
bindsym k resize shrink height 1 px or 1 ppt
|
||||||
bindsym l resize grow width 1 px or 1 ppt
|
bindsym l resize grow width 1 px or 1 ppt
|
||||||
|
|
||||||
bindsym $mod+r mode "default"
|
bindsym $mod+r mode "default"
|
||||||
bindsym p mode "resize"
|
bindsym p mode "resize"
|
||||||
|
|
||||||
bindsym Return mode "default"
|
bindsym Return mode "default"
|
||||||
bindsym Escape mode "default"
|
bindsym Escape mode "default"
|
||||||
}
|
}
|
||||||
|
|
||||||
set $exitmode "Power: [e]xit, [r]eboot, [s]hutdown, s[u]spend, [l]ock, [b]lack"
|
set $exitmode "Power: [e]xit, [r]eboot, [s]hutdown, s[u]spend, [l]ock, [b]lack"
|
||||||
mode $exitmode {
|
mode $exitmode {
|
||||||
bindsym e exit
|
bindsym e exit
|
||||||
bindsym r exec reboot
|
bindsym r exec reboot
|
||||||
bindsym s exec shutdown -h now
|
bindsym s exec shutdown -h now
|
||||||
bindsym u exec systemctl suspend; mode "default"
|
bindsym u exec systemctl suspend; mode "default"
|
||||||
bindsym l exec $i3lock_cmd; mode "default"
|
bindsym l exec $i3lock_cmd; mode "default"
|
||||||
bindsym b exec magick canvas:none PNG:- | feh -YF -; mode "default"
|
bindsym b exec magick canvas:none PNG:- | feh -YF -; mode "default"
|
||||||
|
|
||||||
bindsym Escape mode "default"
|
bindsym Escape mode "default"
|
||||||
bindsym Return mode "default"
|
bindsym Return mode "default"
|
||||||
}
|
}
|
||||||
bindsym $mod+x mode $exitmode
|
bindsym $mod+x mode $exitmode
|
||||||
|
|
||||||
@ -211,21 +218,19 @@ bindsym $mod+Shift+c reload
|
|||||||
bindsym $mod+Shift+r restart
|
bindsym $mod+Shift+r restart
|
||||||
|
|
||||||
bar {
|
bar {
|
||||||
output primary
|
output primary
|
||||||
output nonprimary
|
output nonprimary
|
||||||
tray_output primary
|
tray_output primary
|
||||||
status_command exec ~/.local/bin/i3status_wrapper
|
status_command exec ~/.local/bin/i3status_wrapper
|
||||||
}
|
}
|
||||||
|
|
||||||
## Clipboard Screenshots
|
bindsym Print exec --no-startup-id screenshot select copy
|
||||||
bindsym Print exec --no-startup-id maim | xclip -selection clipboard -t image/png
|
bindsym $mod+Print exec --no-startup-id screenshot window copy
|
||||||
bindsym $mod+Print exec --no-startup-id maim --window $(xdotool getactivewindow) | xclip -selection clipboard -t image/png
|
bindsym Ctrl+Print exec --no-startup-id screenshot entire copy
|
||||||
bindsym Ctrl+Print exec --no-startup-id maim --select | xclip -selection clipboard -t image/png
|
|
||||||
|
|
||||||
# Screenshots
|
bindsym Shift+Print exec --no-startup-id screenshot select save
|
||||||
bindsym Shift+Print exec --no-startup-id maim "$SCREENSHOTS_DIR/$(date +'%d-%m-%Y-%T').png"
|
bindsym Shift+$mod+Print exec --no-startup-id screenshot window save
|
||||||
bindsym Shift+$mod+Print exec --no-startup-id maim --window $(xdotool getactivewindow) "$SCREENSHOTS_DIR/$(date +'%d-%m-%Y-%T').png"
|
bindsym Shift+Ctrl+Print exec --no-startup-id screenshot entire save
|
||||||
bindsym Shift+Ctrl+Print exec --no-startup-id maim --select "$SCREENSHOTS_DIR/$(date +'%d-%m-%Y-%T').png"
|
|
||||||
|
|
||||||
|
|
||||||
# default workspaces for monitors in setup
|
# default workspaces for monitors in setup
|
||||||
|
|||||||
131
home/user/.local/bin/screenshot
Executable file
131
home/user/.local/bin/screenshot
Executable file
@ -0,0 +1,131 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
|
||||||
|
readonly LOG_FILE="${HOME}/.screenshots.log"
|
||||||
|
readonly NOTIFY_TIME_MS=3000
|
||||||
|
readonly NOTIFY_TIME_ERROR_MS=5000
|
||||||
|
readonly NOTIFY_LABEL="Screenshot"
|
||||||
|
readonly SCREENSHOTS_DIR="${SCREENSHOTS_DIR:-${HOME}/Pictures/screenshots}"
|
||||||
|
|
||||||
|
|
||||||
|
_notify() {
|
||||||
|
notify-send --urgency normal --expire-time "${NOTIFY_TIME_MS}" "${NOTIFY_LABEL}" "${1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
_notify_error() {
|
||||||
|
notify-send --urgency critical --expire-time "${NOTIFY_TIME_ERROR_MS}" "${NOTIFY_LABEL}" "Error: ${1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
_make_screen_select() {
|
||||||
|
#shellcheck disable=SC2317
|
||||||
|
maim --select
|
||||||
|
}
|
||||||
|
|
||||||
|
_make_screen_entire() {
|
||||||
|
#shellcheck disable=SC2317
|
||||||
|
maim
|
||||||
|
}
|
||||||
|
|
||||||
|
_make_screen_current_window() {
|
||||||
|
#shellcheck disable=SC2317
|
||||||
|
maim --window "$(xdotool getactivewindow)"
|
||||||
|
}
|
||||||
|
|
||||||
|
_copy_image_from_stdin_to_clipboard() {
|
||||||
|
#shellcheck disable=SC2317
|
||||||
|
xclip -selection clipboard -t image/png
|
||||||
|
}
|
||||||
|
|
||||||
|
_save_image_from_stdin_to_file() {
|
||||||
|
#shellcheck disable=SC2317
|
||||||
|
cat > "${1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
select_save() {
|
||||||
|
screenshot_file="${SCREENSHOTS_DIR}/$(date +'%d-%m-%Y-%T').png"
|
||||||
|
msg="Selection screenshot save to ${screenshot_file}"
|
||||||
|
if _make_screen_select | _save_image_from_stdin_to_file "${screenshot_file}"; then
|
||||||
|
_notify "${msg}"
|
||||||
|
else
|
||||||
|
_notify_error "${msg}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
select_copy() {
|
||||||
|
msg="Selection screenshot copy to clipboard"
|
||||||
|
if _make_screen_select | _copy_image_from_stdin_to_clipboard; then
|
||||||
|
_notify "${msg}"
|
||||||
|
else
|
||||||
|
_notify_error "${msg}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
window_save() {
|
||||||
|
screenshot_file="${SCREENSHOTS_DIR}/$(date +'%d-%m-%Y-%T').png"
|
||||||
|
msg="Current window screenshot save to ${screenshot_file}"
|
||||||
|
if _make_screen_current_window | _save_image_from_stdin_to_file "${screenshot_file}"; then
|
||||||
|
_notify "${msg}"
|
||||||
|
else
|
||||||
|
_notify_error "${msg}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
window_copy() {
|
||||||
|
msg="Current window screenshot save to clipboard"
|
||||||
|
if _make_screen_current_window | _copy_image_from_stdin_to_clipboard; then
|
||||||
|
_notify "${msg}"
|
||||||
|
else
|
||||||
|
_notify_error "${msg}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
entire_save() {
|
||||||
|
screenshot_file="${SCREENSHOTS_DIR}/$(date +'%d-%m-%Y-%T').png"
|
||||||
|
msg="Entire display screenshot save to ${screenshot_file}"
|
||||||
|
if _make_screen_entire | _save_image_from_stdin_to_file "${screenshot_file}"; then
|
||||||
|
_notify "${msg}"
|
||||||
|
else
|
||||||
|
_notify_error "${msg}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
entire_copy() {
|
||||||
|
msg="Entire display screenshot save to clipboard"
|
||||||
|
if _make_screen_entire | _copy_image_from_stdin_to_clipboard; then
|
||||||
|
_notify "${msg}"
|
||||||
|
else
|
||||||
|
_notify_error "${msg}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
main() {
|
||||||
|
if [ $# -ne 2 ]; then
|
||||||
|
echo "Usage: ${0} {select|window|entire} {save|copy}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
readonly target="${1}"
|
||||||
|
readonly action="${2}"
|
||||||
|
|
||||||
|
case "${target}-${action}" in
|
||||||
|
select-save) select_save &>> "${LOG_FILE}" ;;
|
||||||
|
select-copy) select_copy &>> "${LOG_FILE}" ;;
|
||||||
|
window-save) window_save &>> "${LOG_FILE}" ;;
|
||||||
|
window-copy) window_copy &>> "${LOG_FILE}" ;;
|
||||||
|
entire-save) entire_save &>> "${LOG_FILE}" ;;
|
||||||
|
entire-copy) entire_copy &>> "${LOG_FILE}" ;;
|
||||||
|
*)
|
||||||
|
echo "Invalid options: target=${target}, action=${action}"
|
||||||
|
echo "Available targets: select, window, entire"
|
||||||
|
echo "Available actions: save, copy"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
Loading…
x
Reference in New Issue
Block a user