File tree Expand file tree Collapse file tree 2 files changed +34
-18
lines changed Expand file tree Collapse file tree 2 files changed +34
-18
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/sh
2
- # require xclip(see http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script/677212#677212)
3
- command -v xclip > /dev/null 2>&1 || { echo >&1 " no xclip" ; exit 1; }
4
-
5
- # write image in clipboard to file (see http://unix.stackexchange.com/questions/145131/copy-image-from-clipboard-to-file)
6
- filePath=` xclip -selection clipboard -o 2> /dev/null | grep ^file:// | cut -c8-`
7
- if [ ! -n " $filePath " ] ; then
8
- if
9
- xclip -selection clipboard -target image/png -o > /dev/null 2>&1
10
- then
11
- xclip -selection clipboard -target image/png -o > $1 2> /dev/null
12
- echo $1
2
+ if [ " $XDG_SESSION_TYPE " = " x11" ]; then
3
+ # require xclip(see http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script/677212#677212)
4
+ command -v xclip > /dev/null 2>&1 || { echo >&1 " no xclip" ; exit 1; }
5
+ # write image in clipboard to file (see http://unix.stackexchange.com/questions/145131/copy-image-from-clipboard-to-file)
6
+ filePath=` xclip -selection clipboard -o 2> /dev/null | grep ^file:// | cut -c8-`
7
+ if [ ! -n " $filePath " ] ; then
8
+ if
9
+ xclip -selection clipboard -target image/png -o > /dev/null 2>&1
10
+ then
11
+ xclip -selection clipboard -target image/png -o > $1 2> /dev/null
12
+ echo $1
13
+ else
14
+ echo " no image"
15
+ fi
13
16
else
14
- echo " no image"
17
+ echo $filePath
18
+ fi
19
+ elif [ " $XDG_SESSION_TYPE " = " wayland" ]; then
20
+ command -v wl-copy > /dev/null 2>&1 || { echo >&1 " no wl-clipboard" ; exit 1; }
21
+ filePath=` wl-copy -o 2> /dev/null | grep ^file:// | cut -c8-`
22
+ if [ ! -n " $filePath " ] ; then
23
+ if
24
+ wl-copy -t image/png -o > /dev/null 2>&1
25
+ then
26
+ wl-copy -t image/png image/png -o > $1 2> /dev/null
27
+ echo $1
28
+ else
29
+ echo " no image"
30
+ fi
31
+ else
32
+ echo $filePath
15
33
fi
16
- else
17
- echo $filePath
18
34
fi
Original file line number Diff line number Diff line change @@ -93,12 +93,12 @@ const getClipboardImage = async (ctx: IPicGo): Promise<IClipboardImage> => {
93
93
94
94
execution . stdout . on ( 'data' , ( data : Buffer ) => {
95
95
if ( platform === 'linux' ) {
96
- if ( data . toString ( ) . trim ( ) === 'no xclip' ) {
96
+ if ( data . toString ( ) . trim ( ) === 'no xclip or wl-clipboard ' ) {
97
97
ctx . emit ( IBuildInEvent . NOTIFICATION , {
98
- title : 'xclip not found' ,
99
- body : 'Please install xclip before run picgo'
98
+ title : 'xclip or wl-clipboard not found' ,
99
+ body : 'Please install xclip(for x11) or wl-clipboard(for wayland) before run picgo'
100
100
} )
101
- return reject ( new Error ( 'Please install xclip before run picgo' ) )
101
+ return reject ( new Error ( 'Please install xclip(for x11) or wl-clipboard(for wayland) before run picgo' ) )
102
102
}
103
103
}
104
104
const imgPath = data . toString ( ) . trim ( )
You can’t perform that action at this time.
0 commit comments