Hello,
A Bash quickie from yours truly:
Hope you find it useful.
Best,
Dmitri
Hello,
A Bash quickie from yours truly:
Hope you find it useful.
Best,
Dmitri
Hi @dmpop, thanks for sharing the script!
I’ve noticed a couple of small typos:
sudo cp resize.desktop /usr/share/kservices5/ServiceMenu/
should be
sudo cp compare.desktop /usr/share/kservices5/ServiceMenus/
If one wants to only compare images side by side without saving an intermediate file, this will resize the result to fit your screen and show it straight away:
IFS=" x" read -r _ w h < <(xrandr | grep -o primary[[:blank:]][[:alnum:]]*)
convert "$1" "$2" +append -filter lanczos -resize "${w}x${h}" show:
You could replace Exec=
with that, or if the desktop file does not allow a compound command then just save those two lines to e.g. ~/scripts/compareShow
, then chmod +x ~/scripts/compareShow
and set Exec=~/scripts/compareShow %F
Fixed. Thank you!
Sorry, don’t want to be pedantic, but also notice “ServiceMenu” ==> “ServiceMenus”
Brilliant!!
The desktop file doesn’t seem to work on Dolphin for me though. The icon appears for a split second on the task bar and then it just disappears. If I run the script from the command line it words perfectly. Thank you.
I went through the Desktop Entry Specification and used desktop-file-validate
to remove all possible errors.
So, to get instant comparison without saving files, put this into
/usr/share/kservices5/ServiceMenus/compare.desktop
[Desktop Entry]
Name=Compare side-by-side
Type=Service
ServiceTypes=KonqPopupMenu/Plugin,image/jpg,image/jpeg
Actions=compare
[Desktop Action compare]
Name=Compare side-by-side
Icon=image-x-applix-graphics
Exec=/home/morgan/scripts/compare-side-by-side %F
Note that you cannot use ~
nor $HOME
in Exec=
, it must either be an absolute path or relative to any of the folders in $PATH
.
Put this into ~/scripts/compare-side-by-side
#!/usr/bin/env bash
IFS=" x" read -r _ w h < <(xrandr | grep -o primary[[:blank:]][[:alnum:]]*)
convert "$1" "$2" +append -filter lanczos -resize "${w}x${h}" show:
Run chmod +x ~/scripts/compare-side-by-side
Done.
Note:
desktop-file-validate
still shows one error:
/usr/share/kservices5/ServiceMenus/compare.desktop: error: key “Actions” is present in group “Desktop Entry”, but the type is “Service” while this key is only valid for type “Application”
I consider that a bug in the specification since the KDE documentation and real-life seem to rely on the action key.
One quick remark: No need to install that file system wide. You can just put it into ~/.local/share/kservices5/ServiceMenu/
. You might have to create the directory.
Side note: I found it easier to have scripts in ‘open with’ menu rather than in a dolphin/ nautilus/whatever service menu because it allows you to run them from any application such as digikam, darktable, geeqie, etc.
If the above isn’t working for you it may be because, like me, you have attached your monitor cable to a connector other than the primary (doh!). The following will work if you can’t be bothered reconnecting cables:
IFS=" x" read -r _ w h < <(xrandr | grep -o current[[:blank:]][[:alnum:]]*[[:blank:]]x[[:blank:]][[:alnum:]]*)
The output of xrandr:
$ xrandr
Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 32767 x 32767
DVI-D-0 disconnected primary (normal left inverted right x axis y axis)
HDMI-0 disconnected (normal left inverted right x axis y axis)
DP-0 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)
DVI-D-1 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 531mm x 299mm
1920x1080 60.00*+ 50.00
1680x1050 59.95 …