Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7926143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:37:52+00:00 2026-06-03T18:37:52+00:00

I made this Python script: from gi.repository import Gtk, Gdk, GdkX11, Wnck from subprocess

  • 0

I made this Python script:

from gi.repository import Gtk, Gdk, GdkX11, Wnck
from subprocess import PIPE, Popen


class WindowError(Exception):
    pass


def undecorate(aWindow):
    gdkdis = GdkX11.X11Display.get_default()
    gdkwin = GdkX11.X11Window.foreign_new_for_display(gdkdis, aWindow.get_xid())
    gdkwin.set_decorations(Gdk.WMDecoration.BORDER)

def dropdown(aTitle):
    Gtk.main_iteration()

    screen = Wnck.Screen.get_default()
    screen.force_update()

    for window in screen.get_windows():
        if window.get_name() == aTitle:
            timestamp = Gtk.get_current_event_time()

            undecorate(window)

            window.set_skip_pager(True)
            window.set_skip_tasklist(True)
            window.stick()
            window.pin()

            window.maximize_horizontally()
            window.set_geometry(Wnck.WindowGravity.STATIC, 
                                Wnck.WindowMoveResizeMask.Y, 
                                0, 0, -1, -1)

            window.activate(timestamp)
            window.unminimize(timestamp)

            break
    else:
        raise WindowError('Window with title "{}" not found'.format(aTitle))

def getActive():
    Gtk.main_iteration()

    screen = Wnck.Screen.get_default()
    screen.force_update()

    return screen.get_active_window()


def main():
    active = getActive()

    if active.get_name() == 'Dropdown Terminal':
        if active.is_minimized():
            dropdown('Dropdown Terminal')
        else:
            active.minimize()
            return
    else:
        try:
            dropdown('Dropdown Terminal')
        except WindowError:
            Popen(['roxterm', '--profile=Dropdown'], stdout=PIPE, stderr=PIPE)
            dropdown('Dropdown Terminal')


if __name__ == "__main__":
    main()

What it does is it makes roxterm act like Guake. The only problem I have with it is when I Popen a new roxterm instance and move the window to (0,0) right after, the final y-position of the window is a few visible pixels down. I used the set_geometry function in the wnck library to do this. Any ideas on how to fix it? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T18:37:57+00:00Added an answer on June 3, 2026 at 6:37 pm

    Oops, forgot to mention that I solved this issue. I changed some stuff in the code, but I think using GdkWindow to reposition instead of Wnck fixed the positioning problem. This version keeps the dropdown terminal open until the hotkey is pressed again. BTW, I mapped the hotkey to this script by adding a custom hotkey in Gnome’s keyboard preferences.

    from gi.repository import Gtk, Gdk, GdkX11, Wnck
    from subprocess import PIPE, Popen
    
    
    class WindowError(Exception):
        pass
    
    
    def getScreen():
        Gtk.main_iteration()
    
        screen = Wnck.Screen.get_default()
        screen.force_update()
    
        return screen
    
    def getGDKWindow(aWindow):
        gdkdisplay = GdkX11.X11Display.get_default()
        gdkwindow  = GdkX11.X11Window.foreign_new_for_display(gdkdisplay, aWindow.get_xid())
    
        return gdkwindow
    
    def getWindow(aTitle):
        screen = getScreen()
        active = screen.get_active_window()
    
        if active.get_name() == aTitle:
            return active
    
        for window in screen.get_windows():
            if window.get_name() == aTitle:
                return window
    
        return None
    
    def adjust(aWindow):
        gdkwindow = getGDKWindow(aWindow)
    
        gdkwindow.set_decorations(Gdk.WMDecoration.BORDER)
        gdkwindow.move(0,0)
    
        aWindow.set_skip_pager(True)
        aWindow.set_skip_tasklist(True)
    
        aWindow.maximize_horizontally()
    
        aWindow.stick()
        aWindow.make_above()
    
    
    def onWindowOpen(aScreen, aWindow, aData):
        if aWindow.get_name() == aData:
            adjust(aWindow)
    
            Gtk.main_quit()
    
    
    def main():
        timestamp = Gtk.get_current_event_time()
        window      = getWindow('Dropdown Terminal')
    
        if window:
            if window.is_minimized():
                window.activate(timestamp)
                window.unminimize(timestamp)
            else:
                window.minimize()
        else:
            Popen(['roxterm', '--separate', '--profile=Dropdown', '--directory=.'])
    
            getScreen().connect('window-opened', onWindowOpen, 'Dropdown Terminal')
    
            Gtk.main()
    
    
    if __name__ == "__main__":
        main()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made this python script: # -*- coding: utf-8 -*- from datetime import datetime
I'm trying to use an Objective-C class made in Python to do this but
I've made a quick python script that converts to Unicode from ASCII and back.
This is my first python script, be ye warned. I pieced this together from
This module is part of a simple todo app I made with Python... def
I made this bookmarklet: javascript:(function(){var s=document.createElement('script');s.setAttribute('src','http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js');document.getElementsByTagName('body')[0].appendChild(s);$('#hldIntMain').hide();$('#fadeBackground').hide();return false;})() Formatted code: // Add in jQuery var
I made this little function from code snippets around the net. It does what
I made this Greasemonkey script: var maxpi = 250; var p1 = /html/body/div/div[2]/div/div[2]/table[2]/tbody/tr[1]/td[11]; var
I've been looking to incorporate a Python Script a friend made for me into
I have a PHP script which executes a shell command: $handle = popen('python last',

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.