Hotcorners for the poor

For discussions about programming and projects not necessarily associated with Porteus.
User avatar
M. Eerie
Moderator
Moderator
Posts: 711
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce/MATE x64

Hotcorners for the poor

Post#1 by M. Eerie » 09 Feb 2025, 20:02

A minimal script to launch actions depending on the mouse position (corners). Works for me in XFCE4 (4.20)

Code: Select all

#!/bin/bash
# nohup hotcorners >/dev/null 2>&1 &
# xdotool based script  to fire up different actions 
# M. Eerie @ forum.porteus.org 
# 8-Feb-2025

read screen_width screen_height < <(xrandr --current | awk '/\*/ {split($1, res, "x"); print res[1], res[2]}') # Get screen dimensions
threshold=10 # Define corners threshold in pixels. Adjust as necessary

while true; do
    eval $(xdotool getmouselocation --shell) # Get mouse position

    # Check corners / Do actions
    if [ $X -le $threshold ] && [ $Y -le $threshold ]; then
        xdotool key super+space && sleep 1  # Combo to show hud  ### TOP LEFT CORNER
    elif [ $X -ge $((screen_width - threshold)) ] && [ $Y -le $threshold ]; then  ### TOP RIGHT CORNER
        xdotool exec xfce4-terminal --drop-down && sleep 1  # "Guake" terminal
    elif [ $X -le $threshold ] && [ $Y -ge $((screen_height - threshold)) ]; then  ### BOTTOM LEFT CORNER
        xdotool key super+l && sleep 1  # Lock Screen
    elif [ $X -ge $((screen_width - threshold)) ] && [ $Y -ge $((screen_height - threshold)) ]; then  ### BOTTOM RIGHT CORNER
        xdotool key super+d && sleep 1  # Show Desktop
    fi
    sleep 0.2  # Wait for it
done
Last edited by M. Eerie on 10 Feb 2025, 10:29, edited 1 time in total.
> Does not compute_ 🖖

https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=102066#p102066
https://forum.porteus.org/viewtopic.php?p=102306#p102306
https://forum.porteus.org/viewtopic.php?p=72741#p72741

vinnie
Shogun
Shogun
Posts: 210
Joined: 13 Jun 2024, 08:25
Distribution: alpine

Hotcorners for the poor

Post#2 by vinnie » 10 Feb 2025, 00:23

nice, i didn't know xdotool, but you know that also xfce4-terminal works as a drop-down terminal?

User avatar
M. Eerie
Moderator
Moderator
Posts: 711
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce/MATE x64

Hotcorners for the poor

Post#3 by M. Eerie » 10 Feb 2025, 09:49

vinnie wrote:
10 Feb 2025, 00:23
you know that also xfce4-terminal works as a drop-down terminal?
In fact, this is what I'm doing :)

xdotool is fine because it allows you to fire up actions based on your defined shortcuts or your exec command:
M. Eerie wrote:
09 Feb 2025, 20:02
xdotool key super+space
M. Eerie wrote:
09 Feb 2025, 20:02
xdotool exec xfce4-terminal --drop-down && sleep 1
> Does not compute_ 🖖

https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=102066#p102066
https://forum.porteus.org/viewtopic.php?p=102306#p102306
https://forum.porteus.org/viewtopic.php?p=72741#p72741

roro
Black ninja
Black ninja
Posts: 88
Joined: 04 Aug 2022, 08:41
Distribution: Porteus 5.0 XFCE

Hotcorners for the poor

Post#4 by roro » 10 Feb 2025, 10:22

Hi M. Eerie,

what exactly does this script do?
What parameter do I have to specify, etc.

For me, this script is cryptic, completely incomprehensible

User avatar
M. Eerie
Moderator
Moderator
Posts: 711
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce/MATE x64

Hotcorners for the poor

Post#5 by M. Eerie » 10 Feb 2025, 10:36

Hi roro.

This script, named "hotcorners", is designed to trigger different actions based on the position of the mouse pointer on the screen. It relies on xdotool (needs to be present) to perform these actions.

It calculates the screen dimensions and defines a threshold in pixels to detect when the mouse is in a corner.

Then, it has predefined these actions:
  • Top Left Corner: Triggers the super+space key combination. (In my system, I have this combo key associated to a script to show a dashboard of applications)
  • Top Right Corner: If the mouse is in the top right corner, it opens the XFCE4 terminal in dropdown mode, similar to the "Guake" terminal.
  • Bottom Left Corner: If the mouse is in the bottom left corner, it performs the super+l key combination (in my system it locks the screen).
  • Bottom Right Corner: If the mouse is in the bottom right corner, it shows the desktop with the super+d key combination that is present in XFCE4.
You can, of course, modify these actions/keys to suit up your needs :)
> Does not compute_ 🖖

https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=102066#p102066
https://forum.porteus.org/viewtopic.php?p=102306#p102306
https://forum.porteus.org/viewtopic.php?p=72741#p72741

Post Reply