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>
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+
1725DISABLE_SHADOWS=$( defaults read com.apple.screencapture disable-shadow 2> /dev/null)
1826TYPE=$( 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
2130if [ -z " $DISABLE_SHADOWS " ]; then
22- DISABLE_SHADOWS=" false "
31+ DISABLE_SHADOWS=$FALSE
2332fi
2433
2534if [ -z " $TYPE " ]; then
26- TYPE=" png"
35+ TYPE=$PNG
36+ fi
37+
38+ if [ -z " $LOCATION " ]; then
39+ LOCATION=$DEFAULT_LOCATION
2740fi
2841
2942# Convert to bool
3043if [ " $DISABLE_SHADOWS " = " 1" ]; then
31- DISABLE_SHADOWS=" true "
44+ DISABLE_SHADOWS=$TRUE
3245else
33- DISABLE_SHADOWS=" false "
46+ DISABLE_SHADOWS=$FALSE
3447fi
3548
3649# Determine the new value
3750if [ " $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
4558elif [ " $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
5370fi
5471
5572SET_DISABLE_SHADOWS=" $0 disable-shadows"
@@ -60,3 +77,4 @@ echo ":camera:"
6077echo " ---"
6178echo " Disable shadows: $DISABLE_SHADOWS | shell=$0 param1=disable-shadows terminal=false"
6279echo " Save as type: $TYPE | shell=$0 param1=type terminal=false"
80+ echo " Save to: $LOCATION | shell=$0 param1=location terminal=false"
0 commit comments