mylinuxforwork / dotfiles

The ML4W Dotfiles for Hyprland - An advanced and full-featured configuration for the dynamic tiling window manager Hyprland including an easy to use installation script for Arch based Linux distributions.
GNU General Public License v3.0
498 stars 51 forks source link

[FEATURE] Allow configuring screenshot directory and file name format #90

Closed beaver700nh closed 3 weeks ago

beaver700nh commented 1 month ago

Is your feature request related to a problem? Please describe. The screenshot utility seems to always place screenshots into $HOME despite what I put in .config/user-dirs.dirs like the comment says:

# Screenshots will be stored in $HOME/Pictures by default.
# Add this to ~/.config/user-dirs.dirs to save screenshots in a custom folder: 
# XDG_SCREENSHOTS_DIR="$HOME/Screenshots"

Describe the solution you'd like I'd like to be able to customize the screenshot directory using the aforementioned way. Also, it would be nice if there was an option to change the format of the screenshot itself, as I prefer ISO 8601.

Describe alternatives you've considered I mean I could modify the script but then I'd have to exclude it from updates and then other people would face the same issue... Unless there is no issue and I'm just using it wrong, but I couldn't for the life of me get it working without modifications.

Additional context I'm attaching my working modifications here (including spelling changes, feel free to ignore):

--- dotfiles-versions/2.9.5RL/hypr/scripts/screenshot.sh    2024-07-31 09:22:37.895337434 -0400
+++ dotfiles/hypr/scripts/screenshot.sh 2024-07-31 10:50:05.197668451 -0400
@@ -8,13 +8,11 @@
 # Based on https://github.com/hyprwm/contrib/blob/main/grimblast/screenshot.sh 
 # ----------------------------------------------------- 

-# Screenshots will be stored in $HOME/Pictures by default.
+# Screenshots will be stored in $HOME by default.
 # Add this to ~/.config/user-dirs.dirs to save screenshots in a custom folder: 
 # XDG_SCREENSHOTS_DIR="$HOME/Screenshots"

-prompt='Screenshot'
-mesg="DIR: ~/Screenshots"
-NAME="screenshot_$(date +%d%m%Y_%H%M%S).jpg"
+NAME="$(xdg-user-dir SCREENSHOTS)/screenshot-$(date +%Y%m%d-%H%M%S).jpg"
 export GRIMBLAST_EDITOR="$(cat ~/dotfiles/.settings/screenshot-editor.sh)"

 # Example for keybindings
@@ -24,12 +22,12 @@
 # bind = SUPER CTRL, p, exec, grimblast save screen

 # Options
-option_1="Capture"
-option_2="Timer Capture"
+option_1="Immediate"
+option_2="Delayed"

-option_capture_1="All Screen"
-option_capture_2="Capture Active Screen"
-option_capture_3="Capture Area/Window/Application"
+option_capture_1="Capture Everything"
+option_capture_2="Capture Active Display"
+option_capture_3="Capture Selection"

 option_time_1="5s"
 option_time_2="10s"
@@ -44,11 +42,11 @@
 copy='Copy'
 save='Save'
 copy_save='Copy & Save'
-edit='Edit Screenshot'
+edit='Edit'

 # Rofi CMD
 rofi_cmd() {
-    rofi -dmenu -replace -config ~/dotfiles/rofi/config-screenshot.rasi -i -no-show-icons -l 2 -width 30 -p "Take Screenshot"
+    rofi -dmenu -replace -config ~/dotfiles/rofi/config-screenshot.rasi -i -no-show-icons -l 2 -width 30 -p "Take screenshot"
 }

 # Pass variables to rofi dmenu
@@ -96,7 +94,7 @@
 # Chose Screenshot Type
 # CMD
 type_screenshot_cmd() {
-    rofi -dmenu -replace -config ~/dotfiles/rofi/config-screenshot.rasi -i -no-show-icons -l 3 -width 30 -p "Type of Screenshot"
+    rofi -dmenu -replace -config ~/dotfiles/rofi/config-screenshot.rasi -i -no-show-icons -l 3 -width 30 -p "Type of screenshot"
 }

 # Ask for confirmation
@@ -157,13 +155,13 @@

 timer() {
     if [[ $countdown -gt 10 ]]; then
-        notify-send -t 1000 "Taking Screenshot in ${countdown} seconds"
+        notify-send -t 1000 "Taking screenshot in ${countdown} seconds"
         countdown_less_10=$((countdown - 10))
         sleep $countdown_less_10
         countdown=10
     fi
     while [[ $countdown -ne 0 ]]; do
-        notify-send -t 1000 "Taking Screenshot in ${countdown}"
+        notify-send -t 1000 "Taking screenshot in ${countdown}"
         countdown=$((countdown - 1))
         sleep 1
     done

Currently it doesn't seem to query XDG_SCREENSHOTS_DIR anywhere so I added a call to xdg-user-dir. For the record, I also removed some redundant variables. And I don't know what the preferred way would be to configure the date format so I just hardcoded that modification.

mylinuxforwork commented 1 month ago

I will check and try to add this feature to 2.9.5. Keep you posted.

mylinuxforwork commented 3 weeks ago

@beaver700nh - Folder and filename format for screenshots can be defined in screenshot-filename.sh and screenshot-folder.sh in ~/.config/ml4w/settings/ on rolling release.

beaver700nh commented 3 weeks ago

Fantastic, thanks so much!

eljejer commented 2 weeks ago

@mylinuxforwork Hi Stephan. My pictures are stored in ~/afbeeldingen in stead of ~/Pictures. Why did you not choose to use the XDG_SCREENSHOTS_DIR in ~/.config/user-dirs.dirs? Now the script ~/dotfiles/.config/ml4w/settings/screenshot-folder.sh needs to be updated after each fresh install.