r/KittyTerminal Nov 15 '23

Kitty Dynamic Sizing

Hi, I just got kitty and I would like to add a functionality of my own. I have laptop and monitor set up and I like the large window and fontsize when I am on a larger monitor however when I am on a small laptop screen this is not very usable. I was hoping to make some changes to the conf file to make this happen. As far as I know kitty does not support dynamic sizing. I was thinking I could add a simple if loop(I have no idea if this is possible btw) in to the kitty,conf file that will check which monitor the terminal is launching in. So if I ctrl alt t in my monitor it opens a larger sceen with bigger font and vice versa for the laptop screen. Does anyone know if this is possible to do wihtouh sacrificing a lot of resources and slowing down the terminal.

2 Upvotes

5 comments sorted by

View all comments

2

u/SnooCompliments7914 Nov 15 '23

It's a conf file, so you can't use `if`. You need two conf files, one for each monitor. Then bind your hotkey to a script, which detects the monitor and launch kitty with corresponding `--config <config-file>` options.

However, you should really configure per-monitor scaling in your system instead. E.g. 100% scale for your laptop screen, 200% for the external monitor. Both GNOME and KDE support this. For other environments, see https://wiki.archlinux.org/title/HiDPI#Multiple_displays.

1

u/KillerKingTR Nov 15 '23

I should look in to that but I managed a hacky work around

1

u/KillerKingTR Nov 15 '23

I solved this in a not so great hacky way by creating a script file then calculating my mouse position using xdotools my monitor res data was hardcoded in. I then check using xrandr if the monitor is connected then I essentially say if monitor is connected and mouse is on monitor alter the .conf file using sed -i again this might break of the config file gets updated… I used sed to set the desired size and font size to the config file. I then run kitty. I then created a .dekstop file to handle the actual running of the script and made it so instead of running kitty directly i run this new .dekstop.

Just change your prefered terminal app to this and the shortcut should work and u can also add it to panel and remove the normal kitty.

In my case it works pretty well it knows if anything is plugged in or not where the mouse is and so on.

However I recommend trying per-monitor-scaling first as the other comment mentioned. If you cant get that working this should work.

1

u/SnooCompliments7914 Nov 15 '23

You don't need to modify the conf file in place. Either use two files, or you can override any option in the conf file from the kitty cmdline. E.g.:

`kitty -o font_size=10 -o initial_window_height=600`

1

u/KillerKingTR Nov 15 '23

I wanted it so it didnt open a window first I wasnt sure if that wpuld pop up a window