mirror of
https://gitlab.com/linuxstuff/dotfiles.git
synced 2026-03-25 07:22:54 +01:00
added screenlayouts menu
This commit is contained in:
@@ -8,16 +8,12 @@ output DP-3
|
||||
off
|
||||
output DP-5
|
||||
off
|
||||
output HDMI-0
|
||||
off
|
||||
output DP-4
|
||||
crtc 0
|
||||
mode 1920x1080
|
||||
pos 0x0
|
||||
primary
|
||||
rate 144.00
|
||||
x-prop-non_desktop 0
|
||||
output HDMI-0
|
||||
crtc 1
|
||||
mode 1600x1200
|
||||
pos 1920x0
|
||||
rate 144.00
|
||||
rate 60.00
|
||||
x-prop-non_desktop 0
|
||||
|
||||
70
.config/rofi/menus/screenlayouts.py
Executable file
70
.config/rofi/menus/screenlayouts.py
Executable file
@@ -0,0 +1,70 @@
|
||||
#!/bin/python
|
||||
|
||||
# Creates a rofi menu to select the current screen layout
|
||||
#
|
||||
# Dependencies:
|
||||
# System: autorandr (with xrandr)
|
||||
|
||||
import subprocess
|
||||
import re
|
||||
import rofi_menu
|
||||
|
||||
class Menu(rofi_menu.Menu):
|
||||
prompt = "Default output sink"
|
||||
items = []
|
||||
|
||||
def addEntries(self, entries):
|
||||
for entry in entries:
|
||||
if (entry.isVisible):
|
||||
self.items.append(rofi_menu.ShellItem(
|
||||
str(entry), "autorandr --load " + entry.name))
|
||||
|
||||
class Entry:
|
||||
def __init__(self):
|
||||
self.name = "NULL"
|
||||
self.isDefault = False
|
||||
self.isActive = False
|
||||
self.isVisible = True
|
||||
|
||||
def __repr__(self, showIndex=False):
|
||||
result = ("▸ " if (self.isActive) else " ")
|
||||
if (showIndex):
|
||||
result += str(self.index) + ": "
|
||||
return result + self.name
|
||||
|
||||
def fetchEntries(printEntries=False):
|
||||
entries = []
|
||||
entry = None
|
||||
|
||||
# fetch currently available config(s)
|
||||
detected = subprocess.check_output(["autorandr", "--detected"]).decode('utf-8').split("\n")[:-1]
|
||||
|
||||
for line in detected:
|
||||
# New entry
|
||||
entry = Entry()
|
||||
entries.append(entry)
|
||||
|
||||
entry.IsVisible = True
|
||||
entry.isActive = False
|
||||
entry.name = line
|
||||
|
||||
# fetch currently active config(s)
|
||||
current = subprocess.check_output(["autorandr", "--current"]).decode('utf-8').split("\n")[:-1]
|
||||
|
||||
for line in current:
|
||||
for detectedEntry in entries:
|
||||
if detectedEntry.name == line:
|
||||
detectedEntry.isActive = True
|
||||
|
||||
if (printEntries):
|
||||
print("Entries:")
|
||||
for entry in entries:
|
||||
print(entry)
|
||||
|
||||
return entries
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
menu = Menu()
|
||||
menu.addEntries(fetchEntries())
|
||||
rofi_menu.run(menu, rofi_version="1.6")
|
||||
Reference in New Issue
Block a user