diff --git a/user/.config/qutebrowser/config.py b/user/.config/qutebrowser/config.py index 7a50a7c4e..2eeef5774 100644 --- a/user/.config/qutebrowser/config.py +++ b/user/.config/qutebrowser/config.py @@ -165,7 +165,7 @@ config.set('content.javascript.enabled', True, 'qute://*/*') # Directory to save downloads to. If unset, a sensible OS-specific # default is used. # Type: Directory -c.downloads.location.directory = '~/Temporal/Downloads' +c.downloads.location.directory = '~/var/downloads' # When to show the tab bar. # Type: String diff --git a/user/.config/suckless/dmenu/scripts/dmenu_scrot b/user/.config/suckless/dmenu/scripts/dmenu_scrot index 7c735f924..2e733ed66 100755 --- a/user/.config/suckless/dmenu/scripts/dmenu_scrot +++ b/user/.config/suckless/dmenu/scripts/dmenu_scrot @@ -4,17 +4,18 @@ # - Description: A simple screenshot/screencast dmenu script # - Dependencies: maim, splop, ffmpeg, dmenu, libnotify -########################### -## Screenshots Directory ## -########################### +####################################### +## Screenshot & Screencast Directory ## +####################################### SHOTDIR="$XDG_PICTURES_DIR/screenshots" -mkdir -p "$SHOTDIR" - -########################### -## Screencasts Directory ## -########################### CASTDIR="$XDG_VIDEOS_DIR/screencasts" -mkdir -p "$CASTDIR" +[ ! -d "$SHOTDIR" ] && [ ! -d "$CASTDIR" ] && mkdir -p "$SHOTDIR" "$CASTDIR" || echo + +###################### +## Format Variables ## +###################### +image_formats="jpg\npng" +video_formats="mp4\nmkv" ####################### ## Main menu choices ## @@ -25,22 +26,22 @@ mcho3="󰙧 Stop recording" mcho4="󱎘 Exit" mchos="$mcho1\n$mcho2\n$mcho3\n$mcho4" -############################# -## Screenshot menu choices ## -############################# -scho1="󱣴 Entire screen" -scho2="󱎫 Entire screen with delay" -scho3="󱕻 Select area" -scho4="󰖯 Active window" -scho5="󱎘 Exit" -schos="$scho1\n$scho2\n$scho3\n$scho4\n$scho5" +########################## +## Main submenu choices ## +########################## +mscho1="󱣴 Capture the entire screen" +mscho2="󱎫 Capture the entire screen (With delay)" +mscho3="󱕻 Capture area" +mscho4="󰖯 Capture active window" +mscho5="󱎘 Exit" +mschos="$mscho1\n$mscho2\n$mscho3\n$mscho4\n$mscho5" -######################## -## Screenshot submenu ## -######################## -sscho1="󰆏 Copy to clipboard" -sscho2="󰠘 Save to $SHOTDIR" -sschos="$sscho1\n$sscho2" +############################### +## Save/clip submenu choices ## +############################### +svcho1="󰆏 Copy to clipboard" +svcho2="󰠘 Save to $SHOTDIR" +svchos="$svcho1\n$svcho2" ################################# ## Screenshot delay subsubmenu ## @@ -51,11 +52,24 @@ del3="󱑇 10 sec delay" dels="$del1\n$del2\n$del3" ##### -## This function uses the sschos variable to ask the user what to do with the +## This function will check for dependencies +##### +check_dependencies() { + local dependencies=("maim" "ffmpeg" "dmenu" "notify-send" "xclip" "xdotool") + for dep in "${dependencies[@]}"; do + if ! command -v "$dep" &>/dev/null; then + echo "$dep is required but not installed. Please install it and try again." + exit 1 + fi + done +} + +##### +## This function uses the svchos variable to ask the user what to do with the ## screenshot ##### -fsschos() { - sschoice=$(echo -e "$sschos" | dmenu -i -l 2 -p " What do you want to do with this screenshot?") +fsvchos() { + svchoice=$(echo -e "$svchos" | dmenu -i -l 2 -p " What do you want to do with this screenshot?") } ##### @@ -66,17 +80,32 @@ fdel() { del=$(echo -e "$dels" | dmenu -i -p " Select Delay") } +##### +## This function allows the user to choose the screenshot format +##### +fimage_format() { + image_format=$(echo -e "$image_formats" | dmenu -i -p " Choose screenshot format") +} + +##### +## This function allows the user to choose the recording format +##### +fvideo_format() { + video_format=$(echo -e "$video_formats" | dmenu -i -p " Choose video format") +} + ##### ## This function does a full screen screenshot without delay, depending on what -## the user chooses on the fsschos function, the screenshot will be saved to the +## the user chooses on the fsvchos function, the screenshot will be saved to the ## clipboard or to $SHOTDIR ##### shot_screen() { - fsschos - if [ "$sschoice" = "$sscho1" ]; then - maim | xclip -selection clipboard -t image/png && notify-send "Screenshot saved to clipboard" - elif [ "$sschoice" = "$sscho2" ]; then - maim -f jpg "$SHOTDIR/$(date +%s).jpg" && notify-send "Screenshot saved" + fimage_format + fsvchos + if [ "$svchoice" = "$svcho1" ]; then + maim | xclip -selection clipboard -t image/"$image_format" && notify-send "Screenshot saved to clipboard" + elif [ "$svchoice" = "$svcho2" ]; then + maim -f "$image_format" "$SHOTDIR/$(date +%s).$image_format" && notify-send "Screenshot saved" else exit 0 fi @@ -84,36 +113,42 @@ shot_screen() { ##### ## This function does a full screen screenshot with delay, depending on what the -## user chooses on the fsschos function, the screenshot will be saved to the +## user chooses on the fsvchos function, the screenshot will be saved to the ## clipboard or to $SHOTDIR. And depending on what the user chooses on the fdel ## function, the delay will be between 3 and 10 seconds ##### shot_screen_delay() { - fsschos; - if [ "$sschoice" = "$sscho1" ]; then - fdel; - case $del in - "$del1") - sleep 3 && maim | xclip -selection clipboard -t image/png && notify-send "Screenshot saved to clipboard"; - ;; - "$del2") - sleep 5 && maim | xclip -selection clipboard -t image/png && notify-send "Screenshot saved to clipboard"; - ;; - "$del3") - sleep 10 && maim | xclip -selection clipboard -t image/png && notify-send "Screenshot saved to clipboard"; - esac - elif [ "$sschoice" = "$sscho2" ]; then - fdel; - case $del in - "$del1") - sleep 3 && maim -f jpg "$SHOTDIR/$(date +%s).jpg" && notify-send "Screenshot saved to $SHOTDIR"; - ;; - "$del2") - sleep 5 && maim -f jpg "$SHOTDIR/$(date +%s).jpg" && notify-send "Screenshot saved to $SHOTDIR"; - ;; - "$del3") - sleep 10 && maim -f jpg "$SHOTDIR/$(date +%s).jpg" && notify-send "Screenshot saved to $SHOTDIR"; - esac + fimage_format + fsvchos + fdel + case $del in + "$del1") + for i in 3 2 1 + do + notify-send -d 1 "Capturing in $i.." + sleep 0.1 + done + ;; + "$del2") + for i in 5 4 3 2 1 + do + notify-send -d 1 "Capturing in $i.." + sleep 0.1 + done + ;; + "$del3") + for i in 10 9 8 7 6 5 4 3 2 1 + do + notify-send -d 1 "Capturing in $i.." + sleep 0.1 + done + ;; + esac + + if [ "$svchoice" = "$svcho1" ]; then + maim | xclip -selection clipboard -t image/"$image_format" && notify-send "Screenshot saved to clipboard"; + elif [ "$svchoice" = "$svcho2" ]; then + maim -f "$image_format" "$SHOTDIR/$(date +%s).$image_format" && notify-send "Screenshot saved to $SHOTDIR"; else exit 0 fi @@ -121,15 +156,16 @@ shot_screen_delay() { ##### ## This function allows the user to select the area on the screen to screenshot -## depending on what the user chooses on the fsschos function, the screenshot will +## depending on what the user chooses on the fsvchos function, the screenshot will ## be saved to the clipboard or to $SHOTDIR ##### shot_area() { - fsschos; - if [ "$sschoice" = "$sscho1" ]; then - maim -s | xclip -selection clipboard -t image/png && notify-send "Screenshot saved to clipboard"; - elif [ "$sschoice" = "$sscho2" ]; then - maim -s -f jpg "$SHOTDIR/$(date +%s).jpg" && notify-send "Screenshot saved to $SHOTDIR"; + fimage_format + fsvchos + if [ "$svchoice" = "$svcho1" ]; then + maim -s | xclip -selection clipboard -t image/"$image_format" && notify-send "Screenshot saved to clipboard"; + elif [ "$svchoice" = "$svcho2" ]; then + maim -s -f "$image_format" "$SHOTDIR/$(date +%s).$image_format" && notify-send "Screenshot saved to $SHOTDIR"; else exit 0 fi @@ -137,15 +173,16 @@ shot_area() { ##### ## This function does a screenshot of the currently active window, depending -## on what the user chooses on the fsschos function, the screenshot will be +## on what the user chooses on the fsvchos function, the screenshot will be ## saved to the clipboard or to $SHOTDIR ##### shot_window() { - fsschos; - if [ "$sschoice" = "$sscho1" ]; then - maim -i "$(xdotool getactivewindow)" | xclip -selection clipboard -t image/png && notify-send "Screenshot saved to clipboard"; - elif [ "$sschoice" = "$sscho2" ]; then - maim -i "$(xdotool getactivewindow)" -f jpg "$SHOTDIR/$(date +%s).jpg" && notify-send "Screenshot saved to $SHOTDIR"; + fimage_format + fsvchos + if [ "$svchoice" = "$svcho1" ]; then + maim -i "$(xdotool getactivewindow)" | xclip -selection clipboard -t image/"$image_format" && notify-send "Screenshot saved to clipboard"; + elif [ "$svchoice" = "$svcho2" ]; then + maim -i "$(xdotool getactivewindow)" -f "$image_format" "$SHOTDIR/$(date +%s).$image_format" && notify-send "Screenshot saved to $SHOTDIR"; else exit 0 fi @@ -157,17 +194,58 @@ shot_window() { ## another ffmpeg instance, if it's not running, it will grab the screen ## resolution with xdpyinfo and use it to record the screen with ffmpeg. ##### -start_recording() { +rec_screen() { + fvideo_format if pgrep -x "ffmpeg" > /dev/null; then notify-send "A screen recording is already in progress." else - filename="$CASTDIR/$(date +%s).mp4" + filename="$CASTDIR/$(date +%s).$video_format" resolution="$(xdpyinfo | grep dimensions | awk '{print $2}')" ffmpeg -f x11grab -s "$resolution" -i :0.0 -c:v libx264 -preset ultrafast -qp 0 "$filename" & notify-send "Screen recording started." fi } +##### +## This function will record the screen with a given delay +##### +rec_screen_delay() { + fvideo_format + fdel + case $del in + "$del1") + for i in 3 2 1 + do + notify-send -d 1 "Starting in $i.." + sleep 0.1 + done + ;; + "$del2") + for i in 5 4 3 2 1 + do + notify-send -d 1 "Starting in $i.." + sleep 0.1 + done + ;; + "$del3") + for i in 10 9 8 7 6 5 4 3 2 1 + do + notify-send -d 1 "Starting in $i.." + sleep 0.1 + done + ;; + esac + + if pgrep -x "ffmpeg" > /dev/null; then + notify-send "A screen recording is already in progress." + else + filename="$CASTDIR/$(date +%s).$video_format" + resolution="$(xdpyinfo | grep dimensions | awk '{print $2}')" + ffmpeg -f x11grab -s "$resolution" -i :0.0 -c:v libx264 -preset ultrafast -qp 0 "$filename" & + notify-send "Screen recording started" + fi +} + ##### ## This function stops screen recording, it first checks if ffmpeg is already ## running (already recording), to only stop a recording if there's an ffmpeg @@ -185,29 +263,48 @@ stop_recording() { ########## ## main ## ########## +check_dependencies; mchoice=$(echo -e "$mchos" | dmenu -i -l 4 -p " Screen Capture Menu") # main menu prompt case $mchoice in "$mcho1") - schoice=$(echo -e "$schos" | dmenu -i -l 9 -p " Screenshot Menu") # screenshot menu prompt - case $schoice in - "$scho1") + mschoice=$(echo -e "$mschos" | dmenu -i -l 9 -p " Screenshot Menu") # screenshot menu prompt + case $mschoice in + "$mscho1") shot_screen; ;; - "$scho2") + "$mscho2") shot_screen_delay; ;; - "$scho3") + "$mscho3") shot_area; ;; - "$scho4") + "$mscho4") shot_window; ;; - "$scho5") + "$mscho5") exit 0 esac ;; "$mcho2") - start_recording; + mschoice=$(echo -e "$mschos" | dmenu -i -l 9 -p " Screencast Menu") # screenshot menu prompt + case $mschoice in + "$mscho1") + rec_screen; + ;; + "$mscho2") + rec_screen_delay; + ;; + "$mscho3") + #rec_area; + notify-send "not implemented yet" + ;; + "$mscho4") + #rec_window; + notify-send "not implemented yet" + ;; + "$mscho5") + exit 0 + esac ;; "$mcho3") stop_recording; diff --git a/user/.config/suckless/dwm/dependencies.txt b/user/.config/suckless/dwm/dependencies.txt index 0bdadfb20..5dffff67f 100644 --- a/user/.config/suckless/dwm/dependencies.txt +++ b/user/.config/suckless/dwm/dependencies.txt @@ -5,7 +5,7 @@ libxft libxinerama # extra dependencies -xbacklight # brightness control +brightnessctl # brightness control pamixer # volume control arandr # display config st # terminal @@ -13,10 +13,10 @@ dmenu # run launcher dwmblocks # status bar scripts slock # lockscreen herbe # notifications -emacs # text editor +lunarvim # text editor # scratchpads -musikcube # music player +cmus # music player ani-cli # watch anime flix-cli # watch movies ytfzf # watch/listen to youtube @@ -24,3 +24,4 @@ vifm # file manager btop # process viewer pulsemixer # audio mixer 1 alsamixer # audio mixer 2 +tut # mastodon client diff --git a/user/.config/suckless/herbe/config.h b/user/.config/suckless/herbe/config.h index 2f6c0ae86..ed63834ac 100644 --- a/user/.config/suckless/herbe/config.h +++ b/user/.config/suckless/herbe/config.h @@ -13,7 +13,7 @@ static const unsigned int pos_y = 60; enum corners { TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT }; enum corners corner = TOP_RIGHT; -static const unsigned int duration = 5; /* in seconds */ +static unsigned int duration = 5; /* in seconds */ #define DISMISS_BUTTON Button1 #define ACTION_BUTTON Button3 diff --git a/user/.config/suckless/herbe/herbe.c b/user/.config/suckless/herbe/herbe.c index 8bfdbc172..6448752b1 100644 --- a/user/.config/suckless/herbe/herbe.c +++ b/user/.config/suckless/herbe/herbe.c @@ -115,8 +115,28 @@ int main(int argc, char *argv[]) sigaction(SIGUSR1, &act_ignore, 0); sigaction(SIGUSR2, &act_ignore, 0); + int opt; + while ((opt = getopt(argc, argv, "d:")) != -1) + { + switch (opt) + { + case 'd': + duration = atoi(optarg); // Parse the duration from the command line + break; + default: + die("Usage: %s [-d duration] body", argv[0]); + } + } + + if (optind >= argc) + { + die("Usage: %s [-d duration] body", argv[0]); + } + if (!(display = XOpenDisplay(0))) - die("Cannot open display"); + { + die("Cannot open display"); + } int screen = DefaultScreen(display); Visual *visual = DefaultVisual(display, screen); @@ -142,7 +162,7 @@ int main(int argc, char *argv[]) XftFont *font = XftFontOpenName(display, screen, font_pattern); - for (int i = 1; i < argc; i++) + for (int i = optind; i < argc; i++) { for (unsigned int eol = get_max_len(argv[i], font, max_text_width); eol; argv[i] += eol, num_of_lines++, eol = get_max_len(argv[i], font, max_text_width)) { @@ -191,8 +211,10 @@ int main(int argc, char *argv[]) sigaction(SIGUSR1, &act_expire, 0); sigaction(SIGUSR2, &act_expire, 0); - if (duration != 0) - alarm(duration); + if (duration > 0) + { + alarm(duration); + } for (;;) { diff --git a/user/.config/suckless/herbe/notify-send b/user/.config/suckless/herbe/notify-send index 3a3872b6d..21ba637dc 100755 --- a/user/.config/suckless/herbe/notify-send +++ b/user/.config/suckless/herbe/notify-send @@ -1,6 +1,6 @@ #!/bin/sh # Shell script to redirect notify-send calls to herbe. The purpose is to ignore -# options passed to notify-send. +# options passed to notify-send and wait for herbe to finish. # # Option parser generated by getoptions # URL: https://github.com/ko1nksm/getoptions @@ -10,11 +10,18 @@ usage() { printf '%s\n' "${0##*/}: notify-send replacement for herbe" "accepts but ignores all notify-send options." } -REST='' +# Default duration value +duration="" + parse() { OPTIND=$(($#+1)) while [ $# -gt 0 ] && OPTARG=; do case $1 in + -d) # Parse the duration option and its value + [ $# -le 1 ] && set -- "$1" required && break + duration=$2 + _=$duration + shift 2 ;; # Shift both the option and its value --?*=*) OPTARG=$1; shift eval 'set -- "${OPTARG%%\=*}" "${OPTARG#*\=}"' ${1+'"$@"'} ;; @@ -78,4 +85,13 @@ parse() { parse "$@" eval set -- "$REST" -herbe "$@" & + +# Pass the duration option to herbe if it's specified +if [ -n "$duration" ]; then + herbe -d "$duration" "$@" & +else + herbe "$@" & +fi + +# Wait for the herbe process to finish +wait