[~] Refactor

This commit is contained in:
Siarhei Siniak 2023-03-19 15:12:44 +03:00
parent 8da6332743
commit 1fe02aa2f7
2 changed files with 63 additions and 13 deletions

@ -1770,15 +1770,6 @@ def desktop_services(argv):
'"%s"' % options.background_image,
]
)
subprocess.check_call([
'swaymsg',
'--',
'output',
'*',
'bg',
options.background_image,
'fill',
])
self.commands = dict(
swaylock_cmd2=' '.join(swaylock_cmd),
@ -1819,6 +1810,28 @@ def desktop_services(argv):
self.events = []
self.data = []
self.backlight = Backlight()
self.bg = None
self.bg_terminate = False
def background_check(self):
if (
self.bg is None or \
not self.bg.poll() is None
) and not self.bg_terminate:
self.bg = subprocess.Popen([
'swaybg',
'--output',
'*',
'--image',
options.background_image,
'--mode',
'fill',
])
def background_terminate(self, *args, **kwargs):
if not self.bg is None:
self.bg_terminate = True
self.bg.terminate(*args, **kwargs)
def poll(self):
return self.swayidle.poll()
@ -1837,6 +1850,8 @@ def desktop_services(argv):
return False
def terminate(self, *args, **kwargs):
self.background_terminate()
return self.swayidle.terminate(*args, **kwargs)
def wait(self, *args, **kwargs):
@ -1924,6 +1939,10 @@ def desktop_services(argv):
elif o == 't2':
print('started lock')
if self.force_idle():
custom_notify(
title='swayidle',
msg='loginctl lock started',
)
subprocess.check_call(self.commands['lock'], shell=True)
subprocess.call(self.commands['timeout2'], shell=True)
subprocess.check_call(self.commands['timeout1'], shell=True)
@ -1976,6 +1995,8 @@ def desktop_services(argv):
self.backlight.check()
self.background_check()
services.extend([
subprocess.Popen(['ibus-daemon']),
start_swayidle(),

@ -67,11 +67,22 @@ input type:touchpad {
natural_scroll enabled
}
bindgesture swipe:4:left workspace next
bindgesture swipe:4:right workspace prev
set $lock_cmd \
loginctl list-sessions | \
tail '-n' +2 | head -n -2 | awk '{print $1}' | \
xargs loginctl lock-session
bindgesture swipe:4:up exec $lock_cmd
### Key bindings
#
# Basics:
#
bindsym $mod+Shift+l exec loginctl list-sessions | tail '-n' +2 | head -n -2 | awk '{print $1}' | xargs loginctl lock-session
bindsym $mod+Shift+l exec $lock_cmd
bindsym XF86KbdBrightnessDown \
exec commands \
@ -256,14 +267,32 @@ bar {
sleep 1; \
done
status_edge_padding 0
status_padding 0
height 16
colors {
statusline #ffffff
background #323232aa
inactive_workspace #323232aa #323232aa #ffffff
statusline #565656
background #dfdfdf
inactive_workspace #dfdfdf #dfdfdf #000000
active_workspace #dfdfdf #efefef #000000
focused_workspace #dfdfdf #efefef #000000
}
}
client.focused #f3f3f3 #dfdfdf #565656 #f3f3f3 #f3f3f3
client.unfocused #f3f3f3 #dfdfdf #565656 #f3f3f3 #f3f3f3
#font pango:Helvetica Neue 10
font pango:Terminus 10
titlebar_padding 1 4
title_align center
#for_window [class=".*"] title_format "<b>%title</b>"
for_window [class="^firefox$"] floating enable
input * {
xkb_layout "us,ru"
xkb_options "grp:win_space_toggle"