Adjusting the panel height in kde based on the connected display

The panel height in kde doesn't scale with the connected display. This means that when I connect my monitor, the panel is suddenly huge. To solve this problem I wrote a small script that changes the panel height based on the current monitor. The next step would be to run the script in the background, and it listening for changes. Though currently I didn't implement this.

#!/bin/fish

set display (xrandr | grep primary)

if string match "*primary 5120x1440*" $display
	echo "Samsung screen detected"
	qdbus6 org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript "p = panelById(panelIds[0]); p.height=30"
else if string match "*primary 3840x2160*" $display
	echo "integrated screen detected"
	qdbus6 org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript "p = panelById(panelIds[0]); p.height=52"
else
	echo "unknown screen -> changing nothing"
end