lanoxx / tilda

A Gtk based drop down terminal for Linux and Unix
GNU General Public License v2.0
1.28k stars 161 forks source link

Separate config per desktop settings (or possibility to replace config file) #429

Open moby04 opened 4 years ago

moby04 commented 4 years ago

When running Tilda on laptop that sometimes gets connected to external monitors app gets kinda lost in terms of window location. It basically remembers location relative to entire desktop even if its size changes.

Here's how it looks on my system with 3 screens attached (laptop and 2 external screens): 3 screens

And the same system with just laptop screen: 1 screen

Suggested solutions:

  1. Enable multiple configurations that could be easily changed - preferably automatically selected depending on active monitor configuration (on Debian with Cinnamon it would be section of ~/.config/monitors.xml
  2. Allow easy replace and reload of config files. Currently config file is store in ~/.config/tilda/config_0 but AFAIK it is loaded on app startup only and overwritten on application close. It would be enough to allow dynamic reload of this file with some shortcut/signal so that one could store multiple config files and write simple script symlink the one that should be in use at the moment.
lanoxx commented 4 years ago

Here is some background regarding this issue. In version 1.5 tilda learned to use percentages to configure the window size (before it was absolute in pixels), this makes it easier to apply the same size if tilda moves between monitors with different resolutions. I am also considering to apply the same change to the position and use a position relative to the currently configured monitor. The global screen coordinates are deprecated anyway and will eventually go away.

Now back to your suggestion. Using profiles could be a solution of course, but I am wondering if this could also be achieved if we allow something like a "preferred" monitor to be configured that helps tilda to automatically move to a different monitor when an external monitor is being plugged in. Assuming we implement a relative positioning logic for the tilda window, then it would be enough to have some mechanism to manually or automatically switch the configured window when an external monitor is plugged in.

Another thing to note, is that tilda already supports multiple configuration files. You can open a second tilda process which will store its configuration as config_1 and could contain the configuration for an external monitor. But that would require that you start a new tilda process when you plugin your external monitor, so I understand that is not optimal.

dash-xd commented 1 year ago

i wrote a basic bash script that sort of mimics profiles. this has made using tilda on xfce4 much better switching between office and home since i have access to different monitor setups (or just my laptop when i'm on-the-go). i typically use tmux or gnu-screen so i have no need for tilda's tabs which is why it is so basic. the reason why i went this route is because even with the different configs for each tilda instance, tilda and xfce4's display settings never quite worked together the way i wanted them to. therefore it made more sense to save the configs in a state where i knew they worked correctly and swap them as needed.

#!/bin/bash

config_dir="$HOME/.config/tilda/"

if [ "$1" == "--save" ]; then
    if [ -z "$2" ]; then
        echo "Please provide a directory name after --save"
        exit 1
    fi

    dir_name="$2"
    profile_dir="$config_dir"profiles/"$dir_name"

    if [ ! -d "$profile_dir" ]; then
        mkdir -p "$profile_dir"
    fi

    if [ -d "$profile_dir" ]; then
        cp "$config_dir"config_* "$profile_dir"
        echo "Files copied to $profile_dir"
    else
        echo "Directory $profile_dir does not exist or could not be created."
        exit 1
    fi

elif [ "$1" == "--load" ]; then
    if [ -z "$2" ]; then
        echo "Please provide a directory name after --load"
        exit 1
    fi

    dir_name="$2"
    profile_dir="$config_dir"profiles/"$dir_name"

    if [ ! -d "$profile_dir" ]; then
        echo "tilda profile was not found"
        exit 1
    fi

    # Find and kill running instances of tilda from /usr/bin/tilda
    pids=$(pgrep -f "/usr/bin/tilda")
    if [ -n "$pids" ]; then
        echo "Terminating running instances of tilda..."
        echo "$pids" | while IFS= read -r pid; do
            kill "$pid"
        done
    fi

    sleep 1 # necessary to kill tilda fully before swapping config files
    rm "$config_dir"config_*
    cp "$profile_dir"/config_* "$config_dir"
    echo "Files copied from $profile_dir to $config_dir"

else
    echo "Invalid flag. Please use --save or --load"
    exit 1
fi

then in your .bashrc or .bash_aliases file you can add something like:

tilda-profile() {
    nohup ~/.scripts/tilda-profile.sh "$1" "$2" > ~/.config/tilda/profiles/output.log 2>&1 & 
}

usage looks like:

# make some manual tilda preferences edits
tilda-profile --save laptop-only
# make more manual tilda preferences edits
tilda-profile --save extend-left-1080p
tilda-profile --load laptop-only                # sets to laptop-only profile
tilda-profile --load extend-left-1080p    # sets to extend-left-1080p profile

--load works for me from within a tilda shell. it kills all existing tilda shells and then i can open the new tilda instances with my keyboard shortcut.