### Easyland Configuration: Initialization Function Source: https://github.com/juienpro/easyland/blob/main/README.md The `init` function is executed once when Easyland starts. It's typically used for initial setup tasks, such as configuring monitors. ```Python def init(): set_monitors() ``` -------------------------------- ### Launch Easyland CLI Source: https://github.com/juienpro/easyland/blob/main/README.md Launches the Easyland command-line interface, specifying a custom Python configuration file to load. This is how Easyland is started with user-defined settings. ```Shell easyland -c ~/home/.config/hyprland/myconfig.py ``` -------------------------------- ### Install Easyland Source: https://github.com/juienpro/easyland/blob/main/README.md Installs the Easyland Python package using pip. This is the primary method for getting the tool onto your system. ```Shell pip3 -i easyland ``` -------------------------------- ### Easyland Configuration: Optional Lock/Unlock Handlers Source: https://github.com/juienpro/easyland/blob/main/README.md Commented-out example handlers for screen lock and unlock events. These demonstrate how to integrate with screen lockers like hyprlock or swaylock. ```Python # To use this handler, you need to launch your locker (hyprlock or swaylock) like this: hyprlock && loginctl unlock-session # def on_Unlock(): # logger.info("Unlocking the screen") # To use this handler, you need to launch your locker like this: loginctl lock-session # def on_lock(): # logger.info("Locking the screen") ``` -------------------------------- ### Define on_Lock Handler Source: https://github.com/juienpro/easyland/blob/main/README.md Example of a Python handler function to lock the screen using Hyprland. It logs the action and executes the 'hyprlock' command. ```python def on_Lock(): logger.info("Locking the screen") command.exec('pidof hyprlock || hyprlock', True) # Do other actions if needed ``` -------------------------------- ### Hyprland Command Helpers Source: https://github.com/juienpro/easyland/blob/main/README.md Provides helper methods for interacting with Hyprland. `hyprland_get_monitor` retrieves monitor configurations based on various attributes like name, description, maker, or model. It returns monitor details or None if not found. ```APIDOC hyprland_get_monitor(name: str = None, description: str = None, maker: str = None, model: str = None) -> dict | None Retrieves Hyprland monitor configuration. Parameters: name: The name of the monitor (e.g., 'DP-1'). description: A descriptive name for the monitor (e.g., 'HP 22es'). maker: The manufacturer of the monitor. model: The model name of the monitor. Returns: A dictionary containing the monitor's configuration if found, otherwise None. ``` -------------------------------- ### Easyland Helper Methods Source: https://github.com/juienpro/easyland/blob/main/README.md A collection of utility functions provided by Easyland for common tasks such as executing shell commands, interacting with Hyprland/Sway IPC for monitor information, logging, and configuring idle behavior. ```APIDOC command.exec(cmd: str, background: bool = False, decode_json: bool = False) -> str Executes a shell command. Parameters: cmd: The command string to execute. background: If True, execute the command in the background. decode_json: If True, attempt to decode the command output as JSON. command.hyprland_get_all_monitors() -> list Retrieves all monitor configurations from Hyprland IPC. Returns: A list of monitor dictionaries. command.hyprland_get_monitor(name: str = None, description: str = None, make: str = None, model: str = None) -> dict or None Retrieves the configuration for a specific monitor based on provided attributes. Parameters: name: The name of the monitor. description: The description of the monitor. make: The make of the monitor. model: The model of the monitor. Returns: A dictionary with the monitor's configuration, or None if not found. command.sway_get_all_monitors() -> list Retrieves all monitor configurations from Sway IPC. Returns: A list of monitor dictionaries. command.sway_get_monitor(name: str = None, make: str = None, model: str = None) -> dict or None Retrieves the configuration for a specific monitor based on provided attributes. Parameters: name: The name of the monitor. make: The make of the monitor. model: The model of the monitor. Returns: A dictionary with the monitor's configuration, or None if not found. logger Provides logging capabilities. Usage: logger.info(), logger.error(), etc. idle_config() Sets the idle configuration. ``` -------------------------------- ### Configure Easyland Listeners Source: https://github.com/juienpro/easyland/blob/main/README.md Defines the listeners that Easyland will launch at startup. It includes configurations for Hyprland IPC events, systemd logind events, and idle detection. ```python listeners = { "hyprland": { "socket_path": "/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" }, 'systemd_logind': {}, 'idle': {} } ``` -------------------------------- ### Command Execution Helper Source: https://github.com/juienpro/easyland/blob/main/README.md Provides a helper method for executing shell commands. The `exec` method can run commands synchronously or asynchronously. ```APIDOC exec(command_string: str, background: bool = False) -> None Executes a shell command. Parameters: command_string: The command to execute. background: If True, executes the command in the background and returns immediately. If False, waits for the command to complete. ``` -------------------------------- ### Import Easyland Helpers Source: https://github.com/juienpro/easyland/blob/main/README.md Imports essential helper tools from the Easyland library for logging messages to both console and file, and for executing system commands. ```python from easyland import logger, command ``` -------------------------------- ### Easyland Listener Handler Mappings Source: https://github.com/juienpro/easyland/blob/main/README.md Defines the mapping between different event senders (like Hyprland, Sway, Systemd Logind) and the corresponding handler methods within Easyland, along with their expected arguments. ```APIDOC Sender | Handler method to add to your class | Arguments ------------------|-------------------------------------|---------------------------------------- Hyprland | on_hyprland_event | event, argument Sway | on_sway_event_[type] | payload Systemd Logind | on_systemd_event | sender, signal, payload Systemd Logind | on_[signal] | payload ``` -------------------------------- ### Easyland Configuration: Listeners Source: https://github.com/juienpro/easyland/blob/main/README.md Defines the event listeners that Easyland will subscribe to. This includes Hyprland IPC, Systemd logind events, and native Wayland idle events. ```Python listeners = { "hyprland": { "socket_path": "/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" }, 'systemd_logind': {}, 'idle': {} } ``` -------------------------------- ### Handle Systemd PrepareForSleep Signal Source: https://github.com/juienpro/easyland/blob/main/README.md This function is automatically called by Easyland when the systemd 'PrepareForSleep' signal is received. It logs the event and locks the screen using `hyprlock` before the system suspends. ```python def on_PrepareForSleep(payload): if 'true' in payload: logger.info("Locking the screen before suspend") command.exec("pidof hyprlock || hyprlock", True) ``` -------------------------------- ### Handle Hyprland Monitor Events Source: https://github.com/juienpro/easyland/blob/main/README.md Defines a callback function that reacts to Hyprland IPC events, specifically 'monitoradded' and 'monitorremoved'. When a monitor is added or removed, it triggers the `set_monitors` function to reconfigure display settings. ```python def on_hyprland_event(event, argument): if event in [ "monitoradded", "monitorremoved" ]: logger.info('Handling hyprland event: ' + event) set_monitors() ``` -------------------------------- ### Configure Idle Actions Source: https://github.com/juienpro/easyland/blob/main/README.md Sets up actions to be executed after periods of user inactivity. Each action consists of a timeout duration, commands to run on timeout, and optional commands to run upon resuming activity. ```python def idle_config(): return [ [150, ['brightnessctl -s set 0'], ['brightnessctl -r']], [600, ['pidof hyprlock || hyprlock']], [720, ['hyprctl dispatch dpms off'], ['hyprctl dispatch dpms on']] ] ``` -------------------------------- ### Easyland Configuration: Idle Management Source: https://github.com/juienpro/easyland/blob/main/README.md Configures idle timeouts and the commands to execute when the system becomes idle or resumes. This allows for automatic actions like dimming screens or locking. ```Python def idle_config(): return [ [150, ['brightnessctl -s set 0'], ['brightnessctl -r']], [600, ['pidof hyprlock || hyprlock']], [720, ['hyprctl dispatch dpms off'], ['hyprctl dispatch dpms on']] ] ``` -------------------------------- ### Easyland Configuration: Hyprland Event Handler Source: https://github.com/juienpro/easyland/blob/main/README.md A callback function that handles events received from the Hyprland IPC interface. It can react to events like monitor additions or removals. ```Python def on_hyprland_event(event, argument): if event in [ "monitoradded", "monitorremoved" ]: logger.info('Handling hyprland event: ' + event) set_monitors() ``` -------------------------------- ### Handle Systemd Unlock Signal Source: https://github.com/juienpro/easyland/blob/main/README.md This function is called when the systemd 'Unlock' signal is received. It logs the unlock event. To trigger this signal, the screen locker must be launched with `hyprlock && loginctl unlock-session`. ```python def on_Unlock(): logger.info("Unlocking the screen") ``` -------------------------------- ### Define on_systemd_event Handler Source: https://github.com/juienpro/easyland/blob/main/README.md An alternative handler method to listen for Systemd events. It accepts sender, signal, and payload, allowing conditional logic for different signals like 'Lock' or 'PrepareForSleep'. ```python def on_systemd_event(sender, signal, payload) if signal == 'Lock': ... if signal == 'PrepareForSleep': ... ``` -------------------------------- ### Set Hyprland Monitors Source: https://github.com/juienpro/easyland/blob/main/README.md Configures Hyprland monitor settings. It checks for a specific monitor ('HP 22es') and disables the laptop's built-in display if found, otherwise it enables the laptop display and sets brightness to minimum. ```python def set_monitors(self): logger.info('Setting monitors') if command.hyprland_get_monitor(description="HP 22es") is not None: command.exec('hyprctl keyword monitor "eDP-1,disable"') else: command.exec('hyprctl keyword monitor "eDP-1,preferred,auto,2"') command.exec("brightnessctl -s set 0") ``` -------------------------------- ### Generate Wayland Protocols Source: https://github.com/juienpro/easyland/blob/main/README.md Generates necessary Wayland protocol files required for PyWayland to function correctly. This command should be run before using PyWayland-dependent features. ```Shell python -m pywayland.scanner ``` ```Shell pywayland-scanner ``` -------------------------------- ### Python Project Dependencies Source: https://github.com/juienpro/easyland/blob/main/requirements.txt This snippet lists the Python packages and their exact versions required for the Easyland project. These dependencies are typically managed using tools like pip or poetry. ```Python cffi==1.16.0 pycparser==2.22 pywayland==0.4.17 ``` -------------------------------- ### Systemd Logind Signals Source: https://github.com/juienpro/easyland/blob/main/README.md Lists common signals emitted by Systemd Logind, which can be captured by Easyland handlers. These signals relate to system state changes like shutdown, sleep, lock, and unlock. ```APIDOC Member | Description -----------------------|------------------------------------------------------------------- PrepareForShutdown | Sent before a shutdown PrepareForSleep | Sent before suspend Lock | Sent when a lock is requested, eg `loginctrl lock-session` Unlock | Sent when an unlock is requested SessionNew | When a session is created ``` -------------------------------- ### Easyland Configuration: Systemd Logind Event Handler Source: https://github.com/juienpro/easyland/blob/main/README.md Handles Systemd logind events, such as preparing for sleep. This function can be used to perform actions like locking the screen before the system suspends. ```Python def on_PrepareForSleep(payload): if 'true' in payload: logger.info("Locking the screen before suspend") command.exec("pidof hyprlock || hyprlock", True) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.