Skip to content

Commit fff0dad

Browse files
committed
Adds location option
1 parent feee994 commit fff0dad

File tree

5 files changed

+31
-14
lines changed

5 files changed

+31
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A collection of person plugins for [xbar][xbar], [SwiftBar][swiftbar], etc.
44

55
## Screenshot Settings
66

7-
Provides you with an easy way to change screenshot settings.
7+
Provides you with an easy way to change macOS' native screenshot settings.
88

99
![Screenshot Settings](./assets/screenshot-settings-preview.png)
1010

19.8 KB
Loading

assets/screenshot-settings.png

395 KB
Loading

assets/screenshot-settings.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/screenshot-settings.sh

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# <bitbar.version>v1.0</bitbar.version>
44
# <bitbar.author>João Carmo</bitbar.author>
55
# <bitbar.author.github>joaocarmo</bitbar.author.github>
6-
# <bitbar.desc>Provides you with an easy way to change screenshot settings.</bitbar.desc>
7-
# <bitbar.image>https://raw.githubusercontent.com/joaocarmo/xbar-plugins/main/assets/screenshot-settings-preview.png</bitbar.image>
6+
# <bitbar.desc>Provides you with an easy way to change macOS' native screenshot settings.</bitbar.desc>
7+
# <bitbar.image>https://raw.githubusercontent.com/joaocarmo/xbar-plugins/main/assets/screenshot-settings.png</bitbar.image>
88
# <bitbar.dependencies>bash</bitbar.dependencies>
99
# <bitbar.abouturl>https://github.com/joaocarmo/xbar-plugins</bitbar.abouturl>
1010
# <swiftbar.hideAbout>false</swiftbar.hideAbout>
@@ -14,42 +14,59 @@
1414
# <swiftbar.hideSwiftBar>true</swiftbar.hideSwiftBar>
1515
# <swiftbar.refreshOnOpen>true</swiftbar.refreshOnOpen>
1616

17+
FALSE="no"
18+
TRUE="yes"
19+
20+
PNG="png"
21+
JPEG="jpg"
22+
23+
DEFAULT_LOCATION="~/Desktop"
24+
1725
DISABLE_SHADOWS=$(defaults read com.apple.screencapture disable-shadow 2>/dev/null)
1826
TYPE=$(defaults read com.apple.screencapture type 2>/dev/null)
27+
LOCATION=$(defaults read com.apple.screencapture location 2>/dev/null)
1928

2029
# Set the default values if they are not set
2130
if [ -z "$DISABLE_SHADOWS" ]; then
22-
DISABLE_SHADOWS="false"
31+
DISABLE_SHADOWS=$FALSE
2332
fi
2433

2534
if [ -z "$TYPE" ]; then
26-
TYPE="png"
35+
TYPE=$PNG
36+
fi
37+
38+
if [ -z "$LOCATION" ]; then
39+
LOCATION=$DEFAULT_LOCATION
2740
fi
2841

2942
# Convert to bool
3043
if [ "$DISABLE_SHADOWS" = "1" ]; then
31-
DISABLE_SHADOWS="true"
44+
DISABLE_SHADOWS=$TRUE
3245
else
33-
DISABLE_SHADOWS="false"
46+
DISABLE_SHADOWS=$FALSE
3447
fi
3548

3649
# Determine the new value
3750
if [ "$1" = "disable-shadows" ]; then
38-
if [ "$DISABLE_SHADOWS" = "true" ]; then
39-
DISABLE_SHADOWS="false"
51+
if [ "$DISABLE_SHADOWS" = $TRUE ]; then
52+
DISABLE_SHADOWS=$FALSE
4053
else
41-
DISABLE_SHADOWS="true"
54+
DISABLE_SHADOWS=$TRUE
4255
fi
4356
defaults write com.apple.screencapture disable-shadow -bool $DISABLE_SHADOWS
4457
killall SystemUIServer
4558
elif [ "$1" = "type" ]; then
46-
if [ "$TYPE" = "png" ]; then
47-
TYPE="jpg"
59+
if [ "$TYPE" = $PNG ]; then
60+
TYPE=$JPEG
4861
else
49-
TYPE="png"
62+
TYPE=$PNG
5063
fi
5164
defaults write com.apple.screencapture type $TYPE
5265
killall SystemUIServer
66+
elif [ "$1" = "location" ]; then
67+
LOCATION=$(osascript -e 'set theOutputFolder to POSIX path of (choose folder with prompt "Please select a screenshot output folder")')
68+
defaults write com.apple.screencapture location $LOCATION
69+
killall SystemUIServer
5370
fi
5471

5572
SET_DISABLE_SHADOWS="$0 disable-shadows"
@@ -60,3 +77,4 @@ echo ":camera:"
6077
echo "---"
6178
echo "Disable shadows: $DISABLE_SHADOWS | shell=$0 param1=disable-shadows terminal=false"
6279
echo "Save as type: $TYPE | shell=$0 param1=type terminal=false"
80+
echo "Save to: $LOCATION | shell=$0 param1=location terminal=false"

0 commit comments

Comments
 (0)