Skip to content

Commit

Permalink
Merge pull request #6 from nwg-piotr/shell-v2
Browse files Browse the repository at this point in the history
line up with the latest swaync release
  • Loading branch information
nwg-piotr authored May 16, 2022
2 parents 3318573 + bc1e750 commit c0a6bbc
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 11 deletions.
20 changes: 16 additions & 4 deletions nwg_shell_config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,10 @@ def on_apply_btn(b):
"custom": preset_custom
}
preset = presets[settings["panel-preset"]]
update_swaync_config(preset["swaync-positionX"], preset["swaync-positionY"])
update_swaync_config(preset["swaync-positionX"],
preset["swaync-positionY"],
preset["swaync-control-center-width"],
preset["swaync-notification-window-width"])

save_includes()
f = os.path.join(data_dir, "settings")
Expand Down Expand Up @@ -679,7 +682,9 @@ def load_preset(file_name):
"dock-css": "",
"dock-on": False,
"swaync-positionX": "right",
"swaync-positionY": "top"
"swaync-positionY": "top",
"swaync-control-center-width": 500,
"swaync-notification-window-width": 500
}
preset_file = os.path.join(data_dir, file_name)
if os.path.isfile(preset_file):
Expand Down Expand Up @@ -727,15 +732,22 @@ def save_presets():
save_json(preset_custom, f)


def update_swaync_config(pos_x, pos_y):
def update_swaync_config(pos_x, pos_y, cc_width, window_width):
settings_file = os.path.join(config_home, "swaync/config.json")
if os.path.isfile(settings_file):
print("Loading swaync settings from {}".format(settings_file))
swaync_settings = load_json(settings_file)
swaync_settings["positionX"] = pos_x
swaync_settings["positionY"] = pos_y
swaync_settings["control-center-width"] = cc_width
swaync_settings["notification-window-width"] = window_width
else:
swaync_settings = {"positionX": pos_x, "positionY": pos_y}
swaync_settings = {
"positionX": pos_x,
"positionY": pos_y,
"control-center-width": cc_width,
"notification-window-width": window_width
}
print("Saving swaync settings to {}".format(settings_file))
save_json(swaync_settings, settings_file)

Expand Down
4 changes: 3 additions & 1 deletion nwg_shell_config/shell/custom
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@
"dock-css": "",
"dock-on": false,
"swaync-positionX": "right",
"swaync-positionY": "top"
"swaync-positionY": "top",
"swaync-control-center-width": 500,
"swaync-notification-window-width": 500
}
4 changes: 3 additions & 1 deletion nwg_shell_config/shell/preset-0
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@
"dock-css": "preset-0.css",
"dock-on": false,
"swaync-positionX": "right",
"swaync-positionY": "top"
"swaync-positionY": "top",
"swaync-control-center-width": 500,
"swaync-notification-window-width": 500
}
4 changes: 3 additions & 1 deletion nwg_shell_config/shell/preset-1
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@
"dock-css": "preset-1.css",
"dock-on": true,
"swaync-positionX": "center",
"swaync-positionY": "top"
"swaync-positionY": "top",
"swaync-control-center-width": 500,
"swaync-notification-window-width": 500
}
4 changes: 3 additions & 1 deletion nwg_shell_config/shell/preset-2
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@
"dock-css": "preset-2.css",
"dock-on": false,
"swaync-positionX": "right",
"swaync-positionY": "bottom"
"swaync-positionY": "bottom",
"swaync-control-center-width": 400,
"swaync-notification-window-width": 400
}
4 changes: 3 additions & 1 deletion nwg_shell_config/shell/preset-3
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@
"dock-css": "preset-3.css",
"dock-on": true,
"swaync-positionX": "right",
"swaync-positionY": "top"
"swaync-positionY": "top",
"swaync-control-center-width": 400,
"swaync-notification-window-width": 400
}
20 changes: 19 additions & 1 deletion nwg_shell_config/ui_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ def bar_tab(preset, preset_name):

def notification_tab(preset, preset_name):
frame = Gtk.Frame()
frame.set_label(" {}: Notification placement ".format(preset_name))
frame.set_label(" {}: Notification center ".format(preset_name))
frame.set_label_align(0.5, 0.5)
frame.set_property("hexpand", True)
grid = Gtk.Grid()
Expand Down Expand Up @@ -1076,6 +1076,24 @@ def notification_tab(preset, preset_name):
combo_position_x.set_active_id(preset["swaync-positionY"])
combo_position_x.connect("changed", set_dict_key_from_combo, preset, "swaync-positionY")

lbl = Gtk.Label.new("Control center width:")
lbl.set_property("halign", Gtk.Align.END)
grid.attach(lbl, 0, 3, 1, 1)

sb_cc_width = Gtk.SpinButton.new_with_range(0, 1000, 1)
sb_cc_width.set_value(preset["swaync-control-center-width"])
sb_cc_width.connect("value-changed", set_int_from_spinbutton, preset, "swaync-control-center-width")
grid.attach(sb_cc_width, 1, 3, 1, 1)

lbl = Gtk.Label.new("Notification window width:")
lbl.set_property("halign", Gtk.Align.END)
grid.attach(lbl, 0, 4, 1, 1)

sb_window_width = Gtk.SpinButton.new_with_range(0, 1000, 1)
sb_window_width.set_value(preset["swaync-control-center-width"])
sb_window_width.connect("value-changed", set_int_from_spinbutton, preset, "swaync-notification-window-width")
grid.attach(sb_window_width, 1, 4, 1, 1)

frame.show_all()

return frame
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def read(f_name):

setup(
name='nwg-shell-config',
version='0.3.0',
version='0.3.1',
description='nwg-shell configuration utility',
packages=find_packages(),
include_package_data=True,
Expand Down

0 comments on commit c0a6bbc

Please sign in to comment.