Skip to content
This repository was archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
sample configs creation
Browse files Browse the repository at this point in the history
  • Loading branch information
nwg-piotr committed Jan 21, 2020
1 parent de97b6e commit e9a2d1d
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 150 deletions.
10 changes: 0 additions & 10 deletions examples/appendices/README.md

This file was deleted.

22 changes: 0 additions & 22 deletions examples/appendices/appendix-i3

This file was deleted.

22 changes: 0 additions & 22 deletions examples/appendices/appendix-ob

This file was deleted.

22 changes: 0 additions & 22 deletions examples/appendices/appendix-swaynagmode

This file was deleted.

22 changes: 0 additions & 22 deletions examples/appendices/appendix-swaynagmode-pl

This file was deleted.

32 changes: 7 additions & 25 deletions examples/style.css
Original file line number Diff line number Diff line change
@@ -1,28 +1,10 @@
#menu {
font-size: 12px;
padding: 10px
}

#submenu {
background: #6699cc
}

#item-favorites {
font-family: Monospace;
}

#item-category {
font-size: 20px;
}

#item {
font-size: 12px;
}

#item-appendix {
font-size: 12px;
}

#separator {
margin: 10px;
}

#button:hover {
border-top: 1px solid #aaa;
border-left: 1px solid #aaa;
border-right: 1px solid #111;
border-bottom: 1px solid #111
}
8 changes: 3 additions & 5 deletions sgtk-menu/sgtk-bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
from gi.repository import Gtk, Gdk, GdkPixbuf, GLib
import cairo

from tools import localized_category_names, additional_to_main, get_locale_string, config_dirs, save_default_appendix, \
load_json, save_json
from tools import config_dirs, load_json, create_default_configs

# Will apply to the overlay window; we can't do so outside the config file on i3.
# We'll do it for i3 by applying commands to the focused window in open_menu method.
Expand Down Expand Up @@ -109,9 +108,8 @@ def main():
if other_wm:
args.d = 0

# Create default appendix file if not found
if not os.path.isfile(build_from_file):
save_default_appendix(build_from_file)
# Create default config files if not found
create_default_configs(config_dir)

# Replace appendix file name with custom - if any
if args.bf:
Expand Down
12 changes: 6 additions & 6 deletions sgtk-menu/sgtk-menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"""

import os
import shutil
import tempfile
import fcntl
import sys
Expand All @@ -24,8 +25,8 @@
from gi.repository import Gtk, Gdk, GdkPixbuf, GLib
import cairo

from tools import localized_category_names, additional_to_main, get_locale_string, config_dirs, save_default_appendix, \
load_json, save_json
from tools import localized_category_names, additional_to_main, get_locale_string, config_dirs, load_json, save_json, \
create_default_configs

# Will apply to the overlay window; we can't do so outside the config file on i3.
# We'll do it for i3 by applying commands to the focused window in open_menu method.
Expand Down Expand Up @@ -134,7 +135,7 @@ def main():

appendix = parser.add_mutually_exclusive_group()
appendix.add_argument("-a", "--append", action="store_true",
help="append custom menu from {}".format(appendix_file))
help="append custom menu from {}".format(build_from_file))
appendix.add_argument("-af", type=str, help="append custom menu from {}".format(os.path.join(config_dir, '<AF>')))

parser.add_argument("-n", "--no-menu", action="store_true", help="skip menu, display appendix only")
Expand Down Expand Up @@ -163,9 +164,8 @@ def main():
if other_wm:
args.d = 0

# Create default appendix file if not found
if not os.path.isfile(appendix_file):
save_default_appendix(appendix_file)
# Create default config files if not found
create_default_configs(config_dir)

# Replace appendix file name with custom - if any
if args.af:
Expand Down
26 changes: 10 additions & 16 deletions sgtk-menu/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
Copyright (C) 2020 Piotr Miller <nwg.piotr@gmail.com>
"""
import os
import shutil
import locale
import json

Expand Down Expand Up @@ -150,22 +151,15 @@ def additional_to_main(category):
else:
return None


def save_default_appendix(path):
content = [{"name": "Lock",
"exec": "swaylock -f -c 000000",
"icon": "lock"},
{"name": "Logout",
"exec": "swaynag -m ' Exit sway session?' -b ' Logout ' 'swaymsg exit'",
"icon": "exit"},
{"name": "Reboot",
"exec": "swaynag -m ' Reboot the machine?' -b ' Reboot ' 'systemctl reboot'",
"icon": "reload"},
{"name": "Shutdown",
"exec": "swaynag -m ' Shutdown the machine?' -b ' Shutdown ' 'systemctl -i poweroff'",
"icon": "window-close"}]

save_json(content, path)

def create_default_configs(config_dir):
# Create default config files if not found
scr_files = os.listdir('config')
for file_name in scr_files:
src_file = os.path.join('config', file_name)
dst_file = os.path.join(config_dir, file_name)
if not os.path.isfile(dst_file):
shutil.copy(src_file, dst_file)


def load_json(path):
Expand Down

0 comments on commit e9a2d1d

Please sign in to comment.