2

This question is related to another that I asked How do I execute a program in Xfce and make it use another xfwm4 theme other than the default one?

However, I'm now trying to get an answer that will work for any desktop - or in other words - one answer for each desktop, not just Xfce. Here, I am trying to solve the same problem as the previous question: allowing a user to grab a window border for resizing even if they are using extra thin borders and even if they don't know the hot-key used by their desktop for grabbing the window border.

I want to open a window from a bash script and have the title of the window be Resize with.... On my desktop that would be Resize with Alt+F8. I'm writing an application mostly in bash that requires the user to resize a transparent window. Many people have a theme with very thin window borders which when combined with a transparent interior becomes almost impossible to grab with a mouse. I want the user to be able to resize the window with the mouse without having to struggle with grabbing the border. I've posted this question also on the Xfce forum because I'm personally using Xfce. From there, I got a solution working for me with Xfce, but I want a general solution.

From comments below, I see there is not a general solution, so then I'd like as many solutions as are available, one for each Desktop. I already have Xfce, and would like expert users of other desktops to give answers for those desktops.

Here is a solution for Xfce, all in bash:

$ xfconf-query -c xfce4-keyboard-shortcuts -lv | grep resize_window_key | \
    grep custom | cut -d' ' -f1 | sed -e 's/.*\///g'

Since I'm using python code for a transparent window from Python - how to make transparent window with gtk.Window but not with Gtk, I actually just used the xconf-query and then gave the full output of that to the python script to use regex for the match I was looking for. Here is how I actually have done it so far:

Bash code:

all_keys=`xfconf-query -c xfce4-keyboard-shortcuts -lv`
python2 /usr/share/silentcast/transparent_window.py \""$all_keys"\" & \
    transparentPID=$!

Python code:

import os,sys,re
...
    self.set_title("PID:" + str(os.getpid()) + " Resize with " + self.get_resize_hotkey(str(sys.argv[1])))
....
  def get_resize_hotkey(self, all_hotkeys):
    try: 
      resize_hotkey=re.search('(?<=custom\/)<.+>\w*(?=.+resize_window_key)', all_hotkeys).group()
    except AttributeError:
      resize_hotkey=""
  return resize_hotkey

I'm looking for solutions either all in bash or part in bash and part in python that will give me the user's key-binding (if any) for grabbing the border of the active window with the mouse for resizing.

  • 2
    Which window manager? Different ones use very different shortcuts and different ways of listing them. You might want to consider whether it is worth the trouble versus having your user simply resize using the mouse. – terdon Sep 17 '14 at 18:09
  • There is no standard way of listing window manager keybindings. Which window manager do you want this for? If you want that for all of them, it's impossible; some window managers have no keybinding to resize a window, some even have no way to resize a window. What problem are you actually trying to solve? – Gilles 'SO- stop being evil' Sep 17 '14 at 21:07
  • 1
    Ok, I have provided a great deal more information. I hope this question can be posted now. – Colin Keenan Sep 18 '14 at 19:52
  • 1
    On Unity the default shortcut is the same, Alt+F8. You can double check this with: gsettings get org.gnome.desktop.wm.keybindings begin-resize. The default value is ['<Alt>F8']. Hopefully tomorrow I can test KDE and GNOME, but I am fairly certain they will be the same. – Seth Sep 26 '14 at 04:37
  • I just tested gsettings get org.gnome.desktop.wm.keybindings begin-resize in Xfce, and the good news is that it also works in Xfce. The bad news is that it only reports the default. I changed it to Alt+1, but it still reported Alt+F8. – Colin Keenan Sep 26 '14 at 15:00
  • @ColinKeenan No that won't work with Xfce (notice it is org.gnome). I see now where I should have been more clear. I think the default shortcut (Alt+F8) is the same across most desktop environments, but they key and access methods usually aren't. (Now that I think about it, Gnome might use the same key as Unity, but KDE and Xfce most definitely won't.) Apologies I wasn't clear enough. – Seth Sep 26 '14 at 17:23
  • OK - I tested changing org.gnome.desktop.wm.keybindings begin-reize in Xfce and Unity. For Xfce, no good. For Unity, yes, it changed the keybinding. So, you should provide your answer below then I can mark it as correct. Thanks for your help. – Colin Keenan Sep 26 '14 at 18:44

1 Answers1

2

On Unity the default window resize shortcut is Alt+F8. You can check this by running:

gsettings get org.gnome.desktop.wm.keybindings begin-resize  

The default value being ['<Alt>F8'].

I checked KDE out as well, but they have no keyboard shortcut for window resizing, that I could find.

Seth
  • 1,631
  • You can also change the default value and it will show that value as well. So, this is the correct answer for Unity. Turns out Unity does a good job making it easy to grab the edge of a window with the mouse because it has a concept of "input area" around the window - usually 10px wide. So, even though they don't have any borders, it's as if there's a 10 px wide border. – Colin Keenan Sep 28 '14 at 05:17