[~] Refactor

This commit is contained in:
Siarhei Siniak 2023-01-04 15:09:17 +03:00
parent a9b6d37a75
commit 604ea53c6b
3 changed files with 113 additions and 90 deletions

@ -692,6 +692,24 @@ def resilient_vlc(stream=None):
pass pass
time.sleep(1.0) time.sleep(1.0)
def sway_sock():
import glob
uid = os.stat(os.environ['HOME']).st_uid
t1 = glob.glob(
os.path.join(
'/run',
'user',
'%d' % uid,
'sway-ipc.%d*.sock' % uid,
)
)
t2 = [
os.stat(o).st_mtime
for o in t1
]
t3 = sorted(enumerate(t1), key=lambda x: t2[x[0]])[-1][0]
return t1[t3]
def eternal_firefox( def eternal_firefox(
tabs=None, tabs=None,
profile=None, profile=None,
@ -1180,6 +1198,8 @@ def desktop_services(argv):
options, args = parser.parse_args(argv) options, args = parser.parse_args(argv)
os.environ['SWAYSOCK'] = sway_sock()
assert all([ assert all([
env_name in os.environ env_name in os.environ
for env_name in [ for env_name in [
@ -1190,7 +1210,7 @@ def desktop_services(argv):
'SWAYSOCK', 'SWAYSOCK',
'WAYLAND_DISPLAY', 'WAYLAND_DISPLAY',
] ]
]) ]) and os.environ['SWAYSOCK'] == sway_sock()
services = [] services = []
try: try:
if options.cpufreq == 0: if options.cpufreq == 0:
@ -1331,7 +1351,10 @@ def desktop_services(argv):
if line in [ if line in [
't1', 't2', 't3', 't4', 't1', 't2', 't3', 't4',
't5', 't5', 't6', 't7', 't5', 't5', 't6', 't7',
] ] or (
'idle state' in line or \
'active state' in line
)
]) ])
if len(self.events) > 0: if len(self.events) > 0:

@ -69,7 +69,7 @@ input type:touchpad {
# #
# Basics: # Basics:
# #
bindsym $mod+Shift+l exec loginctl lock-session bindsym $mod+Shift+l exec loginctl lock-session --no-ask-password
# Start a terminal # Start a terminal
bindsym $mod+t exec $term bindsym $mod+t exec $term

@ -22,5 +22,5 @@ eval `keychain --eval --quiet`
if [[ $TTY == "/dev/tty1" ]] { if [[ $TTY == "/dev/tty1" ]] {
#exec startx #exec startx
exec sway exec sh -c $'sway 2>&1 | logger -d --tag sway --id=$(pgrep -i \'sway$\');'
} }