Commit 8b2c2016 authored by onny's avatar onny
Browse files

add flake file

parent 0917f3dd
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1642961095,
"narHash": "sha256-RLatktZmvwFBOyqdoIk4qdS4OGKB7aKIvvs4ZP2L8D8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "604c44137d97b5111be1ca5c0d97f6e24fbc5c2c",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-21.11",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}
{
description = "wl-togglescreens script for toggle screens on Wayland";
inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-21.11;
outputs = { self, nixpkgs }: {
defaultPackage.x86_64-linux =
# Notice the reference to nixpkgs here.
with import nixpkgs { system = "x86_64-linux"; };
stdenv.mkDerivation {
name = "wl-togglescreens";
version = "0.1";
src = self;
buildInputs = [
python3
];
nativeBuildInputs = with python3Packages; [
wrapPython
];
dontBuild = true;
installPhase = ''
install -vD main.py $out/bin/wl-togglescreens
'';
postFixup = "
wrapPythonPrograms
";
};
};
}
......@@ -13,10 +13,11 @@ class Screen:
@state.setter
def state(self, value):
if self._state != None and value:
subprocess.run(['wlr-randr', '--output', self.name, '--on'])
else:
subprocess.run(['wlr-randr', '--output', self.name, '--off'])
if self._state != None:
if value:
subprocess.run(['wlr-randr', '--output', self.name, '--on'])
else:
subprocess.run(['wlr-randr', '--output', self.name, '--off'])
self._state = value
class wlScreens:
......@@ -40,7 +41,12 @@ class wlScreens:
screen.state = False
def toggleModes(self):
if (len(self.screens) == 2):
if (len(self.screens) == 1):
if (self.screens[0].state == True):
self.screens[0].state = False
else:
self.screens[0].state = True
elif (len(self.screens) == 2):
if (self.screens[0].state == True and self.screens[1].state == True):
self.screens[0].state = False
elif (self.screens[0].state == False and self.screens[1].state == True):
......@@ -48,11 +54,6 @@ class wlScreens:
self.screens[0].state = True
elif (self.screens[0].state == True and self.screens[1].state == False):
self.screens[1].state = True
if (len(self.screens) == 1):
if (self.screens[0].state == True):
self.screens[0].state = False
else:
self.screens[0].state = True
def __len__(self):
return len(self.screens)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment