Last active
August 29, 2015 14:20
-
-
Save cscutcher/da6a0d694ab6f32dfa29 to your computer and use it in GitHub Desktop.
My setup for tmux. Its all terrible hacked. Need to make a python module.
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
#!/bin/bash | |
tmux -S /tmp/tmux-shared $* |
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
# -*- coding: utf-8 -*- | |
""" | |
Utility functions for tmux | |
""" | |
import grp | |
import logging | |
import os | |
import os.path | |
import stat | |
DEV_LOGGER = logging.getLogger(__name__) | |
def get_server_socket(): | |
""" | |
Get server socket from current environment | |
""" | |
tmux_env = os.environ["TMUX"] | |
tmux_path, _, _ = tmux_env.split(",") | |
return tmux_path | |
def enable_screen_sharing_on_server(socket_path, share_group_name): | |
""" | |
Enable sharing on server by socket_path | |
""" | |
group = grp.getgrnam(share_group_name) | |
os.chown(socket_path, -1, group.gr_gid) | |
stat_result = os.stat(socket_path) | |
mode = stat_result.st_mode | |
new_mode = mode | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP | |
os.chmod(socket_path, new_mode) | |
def disable_screen_sharing_on_server(socket_path): | |
""" | |
Disable sharing on server by socket path | |
""" | |
stat_result = os.stat(socket_path) | |
mode = stat_result.st_mode | |
new_mode = mode & ~(stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP) | |
os.chmod(socket_path, new_mode) | |
disable_write_sharing_on_server(socket_path) | |
def enable_write_sharing_on_server(socket_path): | |
""" | |
Enable write access to sharing | |
""" | |
file(socket_path + "-rw", 'w').write(" ") | |
def disable_write_sharing_on_server(socket_path): | |
""" | |
Disable write sharing | |
""" | |
path = socket_path + "-rw" | |
if os.path.isfile(path): | |
os.unlink(path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment