-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
lioaslan
committed
Apr 6, 2022
1 parent
36bc1a5
commit 9541555
Showing
4 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,3 +127,4 @@ dmypy.json | |
|
||
# Pyre type checker | ||
.pyre/ | ||
nohup.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import subprocess | ||
import os | ||
|
||
HOME = os.environ["HOME"] | ||
PLANK_CONFIG_PATH = f'{HOME}/.config/dconf/user.conf' | ||
|
||
def main(): | ||
monitors = subprocess.run( | ||
'xrandr | grep " connected "', shell=True, stdout=subprocess.PIPE | ||
).stdout.decode("utf-8") | ||
number_monitors = len(monitors.split("\n")) - 1 | ||
|
||
subprocess.run(f"dconf dump / >{PLANK_CONFIG_PATH}", shell=True) | ||
|
||
plank_config = "" | ||
with open(f"{PLANK_CONFIG_PATH}") as fin: | ||
for line in fin.readlines(): | ||
if line.__contains__("enabled-docks="): | ||
dock_arr = ["dock".__add__(str(x + 1)) for x in range(number_monitors)] | ||
dock_arr = '"{0}"'.format('","'.join(dock_arr)) | ||
line = f"enabled-docks=[{dock_arr}]" | ||
plank_config += line | ||
print(plank_config) | ||
|
||
fout = open(f'{PLANK_CONFIG_PATH}', 'w') | ||
fout.write(plank_config) | ||
|
||
subprocess.run(f'dconf load / <{PLANK_CONFIG_PATH}', shell=True) | ||
subprocess.run('sudo killall plank', shell=True) | ||
subprocess.run('nohup plank &', shell=True) | ||
|
||
if number_monitors == 2: | ||
subprocess.run( | ||
"xrandr --output eDP-1 --mode 1920x1080 --pos 0x0 --output DP-3 --mode 1920x1080 --pos 1920x0", | ||
shell=True, | ||
) | ||
if number_monitors == 3: | ||
subprocess.run( | ||
"xrandr --output DP-1 --mode 1920x1080 --pos 0x0 --output DP-3 --mode 1920x1080 --pos 1920x0 --output eDP-1 --mode 1920x1080 --pos 3840x0", | ||
shell=True, | ||
) | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pyinstaller==4.10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
PWD=$(pwd) | ||
INSTALL_DIR='/usr/local/monitors-chosen' | ||
pyinstaller --onedir --noconfirm $PWD/monitors-chosen.py | ||
sudo rm -rf $INSTALL_DIR | ||
sudo mkdir -p $INSTALL_DIR | ||
sudo cp -r $PWD/dist $INSTALL_DIR | ||
sudo ln -sf $INSTALL_DIR/dist/monitors-chosen/monitors-chosen /usr/local/bin/monitors-chosen |