GithubHelp home page GithubHelp logo

Comments (3)

t-wissmann avatar t-wissmann commented on May 25, 2024 1

I've added an FAQ entry about this: http://herbstluftwm.org/faq.html#_q_how_can_i_have_some_of_the_tags_on_specific_monitors_only

Basically for each tag, you need to save the desired monitor name or index in the tag’s attributes. Before switching to another tag, check whether it has such an attribute, and if so, switch to that monitor first. The code for the autostart is as follows. It allows both static configuration of lockings and dynamically creation of lockings via the Mod-t and Mod-Shift-t keybindings:

# Replace the default section for tags in your autostart by the following:
# This is the default tag section of the autostart, with a single change:
# In the use_index keybinding, check the presence of the my_monitor attribute,
# before focusing the desired tag.
hc rename default "${tag_names[0]}" || true
for i in ${!tag_names[@]} ; do
    hc add "${tag_names[$i]}"
    key="${tag_keys[$i]}"
    if ! [ -z "$key" ] ; then
        # first check if the tag is locked to some monitor.
        # if so, first focus the monitor
        hc keybind "$Mod-$key" \
            chain , silent substitute M tags."$i".my_monitor \
                        focus_monitor M \
                  , use_index "$i"
        hc keybind "$Mod-Shift-$key" move_index "$i"
    fi
done

# Add a keybinding for locking the current tag to the monitor it is displayed
# on. This is done by safing the current monitor index in the my_monitor
# attribute of the focused tag. If the monitor has a (nonempty) name, use the
# monitor name instead of its index.
herbstclient keybind $Mod-t chain \
    , new_attr string tags.focus.my_monitor \
    , substitute M monitors.focus.index set_attr tags.focus.my_monitor M \
    , try and \
        . compare monitors.focus.name != "" \
        . substitute M monitors.focus.name \
                set_attr tags.focus.my_monitor M

# Add a keybinding for removing the lock
herbstclient keybind $Mod-Shift-t \
    remove_attr tags.focus.my_monitor

# Statically define which tag should be send to which monitor
lock_tag_to_monitor() {
    herbstclient chain \
        , new_attr string tags.by-name."$1".my_monitor \
        , set_attr tags.by-name."$1".my_monitor "$2"
}
# Already lock some of the tags to a monitor, for example:
# lock the tag 8 to the monitor with index 1 (i.e. the second monitor)
lock_tag_to_monitor 8 1

from herbstluftwm.

ypnos avatar ypnos commented on May 25, 2024

You can achieve this feature easily by writing your own script that discerns the action based on workspace name. You can then bind to that instead.
You can do this either with an external script or hlwms internal scripting. The latter has some benefits in practice. I am not versed in that so I don't have a concrete example for you. It should only be a one-liner though.

On January 3, 2016 4:11:26 PM GMT+01:00, PureTryOut [email protected] wrote:

Using 2 screens, you can have all workspaces on whatever monitor you
desire. I would like an option so lock a workspace to a specified
monitor. Say workspace 8 to monitor 2.
If you press the key combination to get to that workspace, it would
move your mouse and focus to the workspace on the screen it's locked
to. This makes it for example easy to have a web-browser on a second
monitor at all times (except when you manually move the window to a
different container/workspace of course).


Reply to this email directly or view it on GitHub:
#61

from herbstluftwm.

davidv171 avatar davidv171 commented on May 25, 2024

This does not synergize with:
hc use_index +1 or hc use_index -1
Also issues with hc use_previous can occur. Basically every command to reach a workspace that is not the standard keybind will cause issues. I still believe true locking monitors to workspace is necessary.

from herbstluftwm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.