Add shortcut cheatsheet
This commit is contained in:
parent
5dfae0e5eb
commit
3f7d6c9821
5 changed files with 113 additions and 1 deletions
|
@ -18,3 +18,7 @@ bind = shift, PRINT, exec, hyprshot -m region
|
|||
# Lock
|
||||
bind = $mainMod, L, exec, ~/.config/hypr/scripts/lock.sh
|
||||
bind = $mainMod SHIFT, L, exec, wlogout --protocol layer-shell
|
||||
|
||||
# Cheatsheet
|
||||
bind = $mainMod, F1, exec, ~/.config/hypr/scripts/cheatsheet.py ~/.config/hypr/shortcuts.txt
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
Emoji Picker=emoji-picker.py
|
||||
|
||||
Shortcuts=cheatsheet.py ~/.config/hypr/shortcuts.txt
|
||||
|
|
81
hypr/scripts/cheatsheet.py
Executable file
81
hypr/scripts/cheatsheet.py
Executable file
|
@ -0,0 +1,81 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import gi, sys
|
||||
gi.require_version("Gtk", "4.0")
|
||||
gi.require_version("Adw", "1")
|
||||
from gi.repository import Gtk, Adw, Gdk, Pango, Gio
|
||||
|
||||
class Cheatsheet(Adw.Application):
|
||||
def __init__(self, path):
|
||||
super().__init__(application_id="net.jeena.Cheatsheet")
|
||||
self.path = path
|
||||
|
||||
def do_activate(self):
|
||||
win = self.create_window()
|
||||
container, label = self.create_cheatsheet_label(self.path)
|
||||
self.apply_css(container, label)
|
||||
win.set_content(container)
|
||||
win.present()
|
||||
|
||||
def create_window(self):
|
||||
win = Adw.ApplicationWindow(application=self)
|
||||
win.set_title("Hyprland Cheatsheet")
|
||||
win.set_default_size(980, 400)
|
||||
win.set_resizable(True)
|
||||
win.set_decorated(False)
|
||||
win.set_opacity(0.7)
|
||||
win.add_css_class("cheatsheet")
|
||||
|
||||
key_controller = Gtk.EventControllerKey()
|
||||
key_controller.connect("key-pressed", self.on_key)
|
||||
win.add_controller(key_controller)
|
||||
return win
|
||||
|
||||
def create_cheatsheet_label(self, filepath):
|
||||
container = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
|
||||
container.set_margin_top(10)
|
||||
container.set_margin_bottom(10)
|
||||
container.set_margin_start(10)
|
||||
container.set_margin_end(10)
|
||||
|
||||
label = Gtk.Label()
|
||||
label.set_xalign(0)
|
||||
label.set_yalign(0)
|
||||
label.set_wrap(True)
|
||||
label.set_justify(Gtk.Justification.LEFT)
|
||||
label.set_text(open(filepath).read().rstrip('\n'))
|
||||
label.set_selectable(False)
|
||||
|
||||
container.append(label)
|
||||
return container, label
|
||||
|
||||
def apply_css(self, container, label):
|
||||
css_provider = Gtk.CssProvider()
|
||||
css_provider.load_from_data(b"""
|
||||
window.cheatsheet {
|
||||
background-color: rgba(0,0,0,0.7);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
window.cheatsheet label {
|
||||
font-family: "JetBrains Mono Nerd Font";
|
||||
font-size: 12pt;
|
||||
font-weight: bold;
|
||||
color: #ffffff;
|
||||
}
|
||||
""")
|
||||
Gtk.StyleContext.add_provider_for_display(
|
||||
Gdk.Display.get_default(),
|
||||
css_provider,
|
||||
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
|
||||
)
|
||||
|
||||
def on_key(self, controller, keyval, keycode, state):
|
||||
key_name = Gdk.keyval_name(keyval)
|
||||
if key_name == "Escape":
|
||||
self.get_active_window().close()
|
||||
return True
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = Cheatsheet(sys.argv[1])
|
||||
app.run()
|
21
hypr/shortcuts.txt
Normal file
21
hypr/shortcuts.txt
Normal file
|
@ -0,0 +1,21 @@
|
|||
┌────────────────── Applications ────────────────────┐ ┌───────────── Window Management ───────────┐
|
||||
│ SUPER + T Open terminal │ │ SUPER + W Close focused window │
|
||||
│ SUPER + B Open browser │ │ SUPER + M Exit Hyprland │
|
||||
│ SUPER + E Open file manager │ │ SUPER + V Toggle floating │
|
||||
└────────────────────────────────────────────────────┘ │ SUPER + P Pseudo split (dwindle) │
|
||||
┌───────────────── Focus Movement ───────────────────┐ │ SUPER + J Toggle split (dwindle) │
|
||||
│ SUPER + ←/→/↑/↓ Move focus │ │ SUPER + F Toggle fullscreen │
|
||||
└────────────────────────────────────────────────────┘ └───────────────────────────────────────────┘
|
||||
┌─────────────────── Workspace ──────────────────────┐ ┌────────────────── Menu ───────────────────┐
|
||||
│ SUPER + [1–9,0] Switch to workspace 1–10 │ │ Tap SUPER App menu tofi │
|
||||
│ SUPER + SHIFT + [1–9,0] Move window to workspace │ └───────────────────────────────────────────┘
|
||||
│ SUPER + S Toggle special workspace │ ┌─────────────── Screenshot ────────────────┐
|
||||
│ SUPER + SHIFT + S Move to special workspace │ │ Print Screenshot window │
|
||||
│ SUPER + Mouse wheel Switch workspaces │ │ Shift + Print Screenshot region │
|
||||
│ CTRL + ALT + ←/→ Previous / Next workspace │ └───────────────────────────────────────────┘
|
||||
└────────────────────────────────────────────────────┘ ┌────────────── Lock / Logout ──────────────┐
|
||||
┌──────────── Window Moving/Resizing ────────────────┐ │ SUPER + L Lock screen │
|
||||
│ SUPER + LMB (drag) Move window │ │ SUPER + SHIFT + L Logout menu │
|
||||
│ SUPER + RMB (drag) Resize window │ └───────────────────────────────────────────┘
|
||||
│ SUPER + SHIFT + ←/→/↑/↓ Swap window with neighbor │
|
||||
└────────────────────────────────────────────────────┘
|
|
@ -1,3 +1,9 @@
|
|||
# Librewolf Picture-in-Picture
|
||||
windowrulev2 = float, class:($browser),title:(Picture-in-Picture)
|
||||
windowrulev2 = pin, class:($browser),title:(Picture-in-Picture)
|
||||
|
||||
# Cheatsheet
|
||||
windowrulev2 = float, class:net.jeena.Cheatsheet
|
||||
windowrulev2 = center, class:net.jeena.Cheatsheet
|
||||
windowrulev2 = stayfocused, class:net.jeena.Cheatsheet
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue