Added version command to swaync (#67)
* Added version command to swaync * Added version arg to client * Prints to stdout * Replaced GetServerInformation version with the generated one * Updated shell completions
This commit is contained in:
@@ -4,12 +4,14 @@ _swaync() {
|
|||||||
|
|
||||||
short=(
|
short=(
|
||||||
-h
|
-h
|
||||||
|
-v
|
||||||
-s
|
-s
|
||||||
-c
|
-c
|
||||||
)
|
)
|
||||||
|
|
||||||
long=(
|
long=(
|
||||||
--help
|
--help
|
||||||
|
--version
|
||||||
--style
|
--style
|
||||||
--config
|
--config
|
||||||
)
|
)
|
||||||
|
@@ -4,6 +4,7 @@ _swaync-client() {
|
|||||||
|
|
||||||
short=(
|
short=(
|
||||||
-h
|
-h
|
||||||
|
-v
|
||||||
-R
|
-R
|
||||||
-rs
|
-rs
|
||||||
-t
|
-t
|
||||||
@@ -20,6 +21,7 @@ _swaync-client() {
|
|||||||
|
|
||||||
long=(
|
long=(
|
||||||
--help
|
--help
|
||||||
|
--version
|
||||||
--reload-config
|
--reload-config
|
||||||
--reload-css
|
--reload-css
|
||||||
--toggle-panel
|
--toggle-panel
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
complete -f -c swaync-client
|
complete -f -c swaync-client
|
||||||
complete -c swaync-client -s h -l help --description "Show help options"
|
complete -c swaync-client -s h -l help --description "Show help options"
|
||||||
|
complete -c swaync-client -s v -l version --description "Prints version"
|
||||||
complete -c swaync-client -s R -l reload-config --description "Reload the config file" -r
|
complete -c swaync-client -s R -l reload-config --description "Reload the config file" -r
|
||||||
complete -c swaync-client -s rs -l reload-css --description "Reload the css file. Location change requires restart" -r
|
complete -c swaync-client -s rs -l reload-css --description "Reload the css file. Location change requires restart" -r
|
||||||
complete -c swaync-client -s t -l toggle-panel --description "Toggle the notificaion panel" -r
|
complete -c swaync-client -s t -l toggle-panel --description "Toggle the notificaion panel" -r
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
complete -f -c swaync
|
complete -f -c swaync
|
||||||
complete -c swaync -s h -l help --description "Show help options"
|
complete -c swaync -s h -l help --description "Show help options"
|
||||||
|
complete -c swaync -s v -l version --description "Prints version"
|
||||||
complete -c swaync -s s -l style --description "Use a custom Stylesheet file" -r
|
complete -c swaync -s s -l style --description "Use a custom Stylesheet file" -r
|
||||||
complete -c swaync -s c -l config --description "Use a custom config file" -r
|
complete -c swaync -s c -l config --description "Use a custom config file" -r
|
||||||
|
@@ -2,5 +2,6 @@
|
|||||||
|
|
||||||
_arguments -s \
|
_arguments -s \
|
||||||
'(-h --help)'{-h,--help}'[Show help options]' \
|
'(-h --help)'{-h,--help}'[Show help options]' \
|
||||||
|
'(-v --version)'{-v,--version}'[Prints version]' \
|
||||||
'(-s --style)'{-s,--style}'[Use a custom Stylesheet file]:files:_files' \
|
'(-s --style)'{-s,--style}'[Use a custom Stylesheet file]:files:_files' \
|
||||||
'(-c --config)'{-c,--config}'[Use a custom config file]:files:_files' \
|
'(-c --config)'{-c,--config}'[Use a custom config file]:files:_files' \
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
_arguments -s \
|
_arguments -s \
|
||||||
'(-h --help)'{-h,--help}'[Show help options]' \
|
'(-h --help)'{-h,--help}'[Show help options]' \
|
||||||
|
'(-v --version)'{-v,--version}'[Prints version]' \
|
||||||
'(-R --reload-config)'{-R,--reload-config}'[Reload the config file]' \
|
'(-R --reload-config)'{-R,--reload-config}'[Reload the config file]' \
|
||||||
'(-rs --reload-css)'{-rs,--reload-css}'[Reload the css file. Location change requires restart]' \
|
'(-rs --reload-css)'{-rs,--reload-css}'[Reload the css file. Location change requires restart]' \
|
||||||
'(-t --toggle-panel)'{-t,--toggle-panel}'[Toggle the notificaion panel]' \
|
'(-t --toggle-panel)'{-t,--toggle-panel}'[Toggle the notificaion panel]' \
|
||||||
|
@@ -27,6 +27,7 @@ private void print_help (string[] args) {
|
|||||||
print (@"\t $(args[0]) <OPTION>\n");
|
print (@"\t $(args[0]) <OPTION>\n");
|
||||||
print (@"Help:\n");
|
print (@"Help:\n");
|
||||||
print (@"\t -h, \t --help \t\t Show help options\n");
|
print (@"\t -h, \t --help \t\t Show help options\n");
|
||||||
|
print (@"\t -v, \t --version \t\t Prints version\n");
|
||||||
print (@"Options:\n");
|
print (@"Options:\n");
|
||||||
print (@"\t -R, \t --reload-config \t Reload the config file\n");
|
print (@"\t -R, \t --reload-config \t Reload the config file\n");
|
||||||
print (@"\t -rs, \t --reload-css \t\t Reload the css file. Location change requires restart\n");
|
print (@"\t -rs, \t --reload-css \t\t Reload the css file. Location change requires restart\n");
|
||||||
@@ -66,6 +67,10 @@ public int command_line (string[] args) {
|
|||||||
case "-h":
|
case "-h":
|
||||||
print_help (args);
|
print_help (args);
|
||||||
break;
|
break;
|
||||||
|
case "--version":
|
||||||
|
case "-v":
|
||||||
|
stdout.printf ("%s\n", Constants.version);
|
||||||
|
break;
|
||||||
case "--reload-config":
|
case "--reload-config":
|
||||||
case "-R":
|
case "-R":
|
||||||
cc_daemon.reload_config ();
|
cc_daemon.reload_config ();
|
||||||
|
@@ -1,4 +0,0 @@
|
|||||||
namespace SwayNotificatonCenter {
|
|
||||||
public class Constants {
|
|
||||||
}
|
|
||||||
}
|
|
4
src/constants.vala.in
Normal file
4
src/constants.vala.in
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
public class Constants {
|
||||||
|
public const string version = @VERSION@;
|
||||||
|
public const string versionNum = @VERSION_NUM@;
|
||||||
|
}
|
@@ -8,10 +8,6 @@ namespace SwayNotificatonCenter {
|
|||||||
Hdy.init ();
|
Hdy.init ();
|
||||||
|
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
if ("-h" in args || "--help" in args) {
|
|
||||||
print_help (args);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (uint i = 1; i < args.length; i++) {
|
for (uint i = 1; i < args.length; i++) {
|
||||||
string arg = args[i];
|
string arg = args[i];
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
@@ -23,6 +19,12 @@ namespace SwayNotificatonCenter {
|
|||||||
case "--config":
|
case "--config":
|
||||||
config_path = args[++i];
|
config_path = args[++i];
|
||||||
break;
|
break;
|
||||||
|
case "-v":
|
||||||
|
case "--version":
|
||||||
|
stdout.printf ("%s\n", Constants.version);
|
||||||
|
return;
|
||||||
|
case "-h":
|
||||||
|
case "--help":
|
||||||
default:
|
default:
|
||||||
print_help (args);
|
print_help (args);
|
||||||
return;
|
return;
|
||||||
@@ -66,6 +68,7 @@ namespace SwayNotificatonCenter {
|
|||||||
print (@"\t $(args[0]) <OPTION>\n");
|
print (@"\t $(args[0]) <OPTION>\n");
|
||||||
print (@"Help:\n");
|
print (@"Help:\n");
|
||||||
print (@"\t -h, --help \t\t Show help options\n");
|
print (@"\t -h, --help \t\t Show help options\n");
|
||||||
|
print (@"\t -v, --version \t\t Prints version\n");
|
||||||
print (@"Options:\n");
|
print (@"Options:\n");
|
||||||
print (@"\t -s, --style \t\t Use a custom Stylesheet file\n");
|
print (@"\t -s, --style \t\t Use a custom Stylesheet file\n");
|
||||||
print (@"\t -c, --config \t\t Use a custom config file\n");
|
print (@"\t -c, --config \t\t Use a custom config file\n");
|
||||||
|
@@ -1,3 +1,28 @@
|
|||||||
|
# Sets the version to a vala variable in Contants.vala
|
||||||
|
version = '@0@'.format(meson.project_version())
|
||||||
|
git = find_program('git', native: true, required: false)
|
||||||
|
if git.found()
|
||||||
|
git_commit = run_command([git, 'rev-parse', '--short', 'HEAD'])
|
||||||
|
git_branch = run_command([git, 'rev-parse', '--abbrev-ref', 'HEAD'])
|
||||||
|
if git_commit.returncode() == 0 and git_branch.returncode() == 0
|
||||||
|
version = '@0@ (git-@1@, branch \'@2@\')'.format(
|
||||||
|
meson.project_version(),
|
||||||
|
git_commit.stdout().strip(),
|
||||||
|
git_branch.stdout().strip(),
|
||||||
|
)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
version = 'swaync @0@'.format(version)
|
||||||
|
message('Building version:', version)
|
||||||
|
const_config_data = configuration_data()
|
||||||
|
const_config_data.set_quoted('VERSION', version)
|
||||||
|
const_config_data.set_quoted('VERSION_NUM', meson.project_version())
|
||||||
|
constants = configure_file(
|
||||||
|
input : 'constants.vala.in',
|
||||||
|
output : 'constants.vala',
|
||||||
|
configuration : const_config_data
|
||||||
|
)
|
||||||
|
|
||||||
app_sources = [
|
app_sources = [
|
||||||
'main.vala',
|
'main.vala',
|
||||||
'configModel/configModel.vala',
|
'configModel/configModel.vala',
|
||||||
@@ -8,8 +33,8 @@ app_sources = [
|
|||||||
'ccDaemon/ccDaemon.vala',
|
'ccDaemon/ccDaemon.vala',
|
||||||
'controlCenter/controlCenter.vala',
|
'controlCenter/controlCenter.vala',
|
||||||
'controlCenter/topAction/topAction.vala',
|
'controlCenter/topAction/topAction.vala',
|
||||||
'constants.vala',
|
|
||||||
'functions.vala',
|
'functions.vala',
|
||||||
|
constants,
|
||||||
]
|
]
|
||||||
|
|
||||||
app_deps = [
|
app_deps = [
|
||||||
@@ -51,7 +76,7 @@ executable('swaync',
|
|||||||
)
|
)
|
||||||
|
|
||||||
executable('swaync-client',
|
executable('swaync-client',
|
||||||
['client.vala', 'constants.vala'],
|
['client.vala', constants],
|
||||||
vala_args: args,
|
vala_args: args,
|
||||||
dependencies: app_deps,
|
dependencies: app_deps,
|
||||||
install: true,
|
install: true,
|
||||||
|
@@ -182,7 +182,7 @@ namespace SwayNotificatonCenter {
|
|||||||
throws DBusError, IOError {
|
throws DBusError, IOError {
|
||||||
name = "SwayNotificationCenter";
|
name = "SwayNotificationCenter";
|
||||||
vendor = "ErikReider";
|
vendor = "ErikReider";
|
||||||
version = "0.3";
|
version = Constants.versionNum;
|
||||||
spec_version = "1.2";
|
spec_version = "1.2";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user