Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """This is a simple python extension allows you to easily switch between monitors
- It is supposed to be used like `stand up` and `stand down`
- To install, create a folder called `standup` in
- ~/.local/share/albert/org.albert.extension.python/modules/
- and then add this file to it, along with the icons of your choice"""
- from time import sleep
- import os
- from albertv0 import *
- up_monitor = 'DVI-I-1-1'
- down_monitor = 'HDMI-1'
- monitor_on = '--auto'
- monitor_off = '--off'
- standup_icon = os.path.dirname(__file__)+"/desk.svg"
- sitdown_icon = os.path.dirname(__file__)+"/chair.svg"
- __iid__ = "PythonInterface/v0.1"
- __prettyname__ = "Standup"
- __version__ = "1.0"
- __trigger__ = "stand"
- __author__ = "luksfarris"
- __dependencies__ = ["whatever"]
- # Can be omitted
- def initialize():
- pass
- # Can be omitted
- def finalize():
- pass
- def handleQuery(query):
- if not query.isTriggered:
- return
- stand_item = Item()
- stand_item.icon = standup_icon
- stand_item.text = 'Stand Up'
- stand_item.subtext = 'Moves to upper screen'
- def stand_command():
- return os.system(f"xrandr --output {up_monitor} {monitor_on} && xrandr --output {down_monitor} {monitor_off}")
- stand_item.addAction(FuncAction("Standup", stand_command))
- sit_item = Item()
- sit_item.icon = sitdown_icon
- sit_item.text = 'Sit Down'
- sit_item.subtext = 'Moves to lower screen'
- def sit_command():
- os.system(f"xrandr --output {up_monitor} {monitor_off} && xrandr --output {down_monitor} {monitor_on}")
- sit_item.addAction(FuncAction("Sitdown", sit_command))
- if 'u' in query.string:
- return [stand_item]
- elif 'd' in query.string:
- return [sit_item]
- else:
- return [stand_item, sit_item]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement